- #include
- #include "freertos/FreeRTOS.h"
- #include "freertos/task.h"
- #include "driver/gpio.h"
- #include "esp_log.h"
- #include "led_strip.h"
- #include "sdkconfig.h"
- #include "driver/ledc.h"
- #include "driver/mcpwm.h"
- printf("start.......");
- //初始化pwm引脚
- mcpwm_gpio_init(MCPWM_UNIT_0, MCPWM0A, 18);
- //初始化pwm配置结构
- mcpwm_config_t pwm_config = {
- .frequency = 100, // frequency = 50Hz, i.e. for every servo motor time period should be 20ms
- .cmpr_a = 0, // duty cycle of PWMxA = 0
- .counter_mode = MCPWM_UP_COUNTER,
- .duty_mode = MCPWM_DUTY_MODE_1,//
- };
- //初始化pwm配置
- mcpwm_init(MCPWM_UNIT_0, MCPWM_TIMER_0, &pwm_config);
- //设置对应 pwm单位、定时器、通道的空占比
- mcpwm_set_duty_type(MCPWM_UNIT_0, MCPWM_TIMER_0, MCPWM_GEN_A, MCPWM_DUTY_MODE_0);
- int t = 0;
- bool dir = true;
- bool predir = false;
- mcpwm_set_duty_in_us(MCPWM_UNIT_0, MCPWM_TIMER_0, MCPWM_GEN_A, 1833);
我发生的问题是这样的,舵机已经稳定在某个角度,这时候我想试一下舵机的力度,于是手动去转动舵机的轴……然后舵机就开始不稳定,触发了看门狗,舵机一直在校正(控制台能看见,系统一直在快速重启),大概过了几秒才稳定下来。
在使用micropython都没有发生这样的问题…… 是不是哪里没有配置到?