Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BLDC Driver issue #97

Closed
2 tasks done
guo-max opened this issue Jul 20, 2023 · 3 comments · Fixed by #100
Closed
2 tasks done

BLDC Driver issue #97

guo-max opened this issue Jul 20, 2023 · 3 comments · Fixed by #100
Assignees
Labels
bldc Related to Brushless DC Motors bug Something isn't working

Comments

@guo-max
Copy link

guo-max commented Jul 20, 2023

Answers checklist.

  • I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
  • I have searched the issue tracker for a similar issue and not found a similar issue.

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 gpio high at up direction and low at down direction.
For a counter counting from 0 -> 100->0, if set to 25%, the gpio will set high at 24->25 and set low at 26->25, which will give high time from 25->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.

  1. Step
  2. Step
  3. Step
    ...

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?

@guo-max guo-max added the bug Something isn't working label Jul 20, 2023
@finger563 finger563 self-assigned this Jul 20, 2023
@finger563 finger563 added the bldc Related to Brushless DC Motors label Jul 20, 2023
@finger563
Copy link
Contributor

finger563 commented Jul 31, 2023

@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.

@guo-max
Copy link
Author

guo-max commented Aug 1, 2023

@finger563 I found out that changing the GEN_ACTION does not change the performance of the FOC control if you do a re-calibration.

@finger563
Copy link
Contributor

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 👍

finger563 added a commit that referenced this issue Aug 1, 2023
* Update to set output to low when counting up, and high when counting down. This means that setting a value of 25% will actually have the output high for 25% of the time.
Fixes #97
finger563 added a commit that referenced this issue Aug 1, 2023
* fix(bldc_driver): fix driver level inversion
* Update to set output to low when counting up, and high when counting down. This means that setting a value of 25% will actually have the output high for 25% of the time.
Fixes #97

* feat(bldc): updated examples
* Update examples to always calibrate by setting zero electrical offset to 0.

* example(bldc_motor): update
* Update bldc motor example to 1) always calibrate sensor direction, 2) always calibrate electrical angle, and 3) enable the motor so it actually runs

* fix(bldc_driver): configure low side
* Update bldc driver to configure the compare actions for the low side generators
* Check error of tiemr functions to not enable if they fail (since it wont work anyway). Havent seen those errors, but just in queso.

* example(bldc_haptics): update
* Update example to always calibrate sensor direction (since its a test)
* Updated example to debug log since its a test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bldc Related to Brushless DC Motors bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants