Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

MOTIX™ MCU Forum Discussions

User16615
Level 1
Level 1
Can anyone help me?

I am trying to modify the code for BLDC_BEMF as below
1) Run the motor forward and reverse.
2) Run to 2 A current limit and stop the motor

I did look into the code but not able to understand where to change the code or which function do the direction and limit the current.

Thanks.
0 Likes
8 Replies
Mc-Key
Employee
Employee
Welcome!
Hi,
The example code is capable to run in reverse direction.

You can change line 101 in the main.c file.
Emo_setspeedreferenz(-2000);

The direction control is selected in Emo.c line 151-158

Easiest way to reverse the direction is to stop the motor, reverse refspeed and start again.

According to your second question.
There is no current limitation implemented to the democode.
The current sense amplifier (CSA) is connected to ADC1/CH1.
If you use one of the TLE9879 Evalkits, you will have a 5mOhm Shunt connected to the CSA.
This results in a current range of +/- 30A at a Gain of 10.

I hope this hints will help you,

Best Regards,
Mc-Key
0 Likes
User16615
Level 1
Level 1
Hi Mc-Key,

I am using KEIL uVision with TLE9879 Evalkits demo code.
I did what you suggested changing Emo_setspeedreferenz(-2000);. The motor run for 0.5 s and stop. Is there anywhere else I need to modify?
When I run forward with load, the motor stop running after heavy load. Is there a overload current set in the demo code?
I wish who write this code create function for speed and current so that user can test the hardware by simply changing the value from positive to negative for speed and integer value for current limit.

Please let me know if you have any other suggestion.

Thank you,
Eugene Ho
0 Likes
Fiz
Moderator
Moderator
Moderator
First solution authored Welcome!
Hi Eugene,

were you able to run the motor in reverse or can we still help you?
Best,
Fiz
0 Likes
User16615
Level 1
Level 1
Hi Fiz,
I did try to changed Emo_setspeedreferenz(-2000); but the motor runs for a second and stop. I think may be the direction error. Can you please help me how to get this working? I am trying to figure how to use the button to run forward for 10 seconds and press the button to run reverse for 10 seconds.

Thanks.
0 Likes
Fiz
Moderator
Moderator
Moderator
First solution authored Welcome!
Hi Eugene,

we are currently working on this problem and will get back to you as soon as possible!

Best,
Fiz
0 Likes
User16615
Level 1
Level 1
Hi Fiz,
Thank you. You can also email me at eugene.ho@mcroiltools.com when you have a good working example.
Eugene Ho
0 Likes
Fiz
Moderator
Moderator
Moderator
First solution authored Welcome!
Hi Eugene,

try decreasing the reference speed and adding a small load to the motor. This will will improve the performance of the closed loop.
When this does not work or is not possible for your setup, you can try to set EMO_RUN to 0 in EMO_BEMF.h.
This way the regulator will stay in open-loop.
Let me know if one of this solutions worked for you.

Best,
Fiz
0 Likes
User16615
Level 1
Level 1
Hi Fiz,
Thank you for your suggestion. I was able to run the motor reverse after set EMO_RUN to 0.

Regards,
Eugene
0 Likes