Closed guo-max closed 1 year ago
@guo-max It definitely doesn't just change the motor direction - as an example, I've changed the GEN_ACTION
for the code in question to invert it (so UP
-> LOW
and DOWN
-> HIGH
), and simply inverting the direction of the motor does not seem to fix it, but the motor stalls when driving output. I'll dig into it some more to see what the cause may be. another option is to simply invert the input provided (so that inputting 25 results in 75 output) but that seems like a kludge to me.
@finger563 I found out that changing the GEN_ACTION
does not change the performance of the FOC control
if you do a re-calibration.
You're correct - if you keep everything else the same (including the sensor_direction
, then there is no discernable difference :) I'll push the fix 👍
Answers checklist.
What is the expected behavior?
I am review the bldc_driver code by comparing to your code and found some issue.
bldc_driver.set_pwm(25,25,25);
// for example I assume the A,B,C high pin should be 25% high, 75% low. But instead, the high pin now is 75% high, 25% low.ESP_ERROR_CHECK(mcpwm_generator_set_actions_on_compare_event( gen_high, MCPWM_GEN_COMPARE_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, comp, MCPWM_GEN_ACTION_HIGH), MCPWM_GEN_COMPARE_EVENT_ACTION(MCPWM_TIMER_DIRECTION_DOWN, comp, MCPWM_GEN_ACTION_LOW), MCPWM_GEN_COMPARE_EVENT_ACTION_END())); }
This function set gpiohigh
atup direction
andlow
atdown direction
. For a counter counting from 0 -> 100->0, if set to 25%, the gpio will sethigh
at24->25
and setlow
at26->25
, which will givehigh
time from25->100->25
which is 75% high.What is the actual behavior?
When set pwm to 25%, the high side at a_high_gpio show be 25% high, 75% low.
Steps to reproduce.
Build or installation Logs.
No response
More Information.
I know it works with your FOC controller. If this is a issue, what will change in the FOC controller? All the highs lows are inverted, May only change the motor direction?