cancel
Showing results for 
Search instead for 
Did you mean: 

Step motor control and max tork

AI_I
Associate II

Hello. I am doing stepper motor step control. I am using the "HAL_TIM_PWM_PulseFinishedCallback" function for this operation. Is there a more functional usage method than this? I can't get the max torque of the motor. Can you help me? Motor Driver "TB6600" / Step Motor "Nema17"

1 ACCEPTED SOLUTION

Accepted Solutions
Johi
Senior III

@AI_I 

I was experimenting with LL as an alternative for HAL and used your case a test case. The main loop calculates the frequency of the motor (limited as per the spec of the motor) and TIM2 pulses its callback. The callback pulses the 4 coils of the motor using a ULN2003 dalington based driver. If I find the time I will try to make a DMA version as well.

 

View solution in original post

7 REPLIES 7
Johi
Senior III

Possibly you have a TB6600 that has a TB67S109AFTG inside see link below for details.

https://www.makerguides.com/tb6600-stepper-motor-driver-arduino-tutorial/

AI_I
Associate II

I do not have a problem with stepper motor control and connections. I can't get the max torque of the motor. I think the reason for this is ARR and Prescaler values. What are these values ​​for Nema17, I couldn't find it in the documents, so I guess I miscalculated. Apart from this, I want to learn if a more useful stepper motor drive can be made than the "HAL_TIM_PWM_PulseFinishedCallback" function.

Johi
Senior III

Do you have the possibility to measure the signal you are sending to the TB6600 with a scope or similar?

You can even try to make a very slow pulse rate and send it to the TB (1 Hz) or less, then the motor should run very slowly, but the torque should be nominal (as this is a property of stepper motors, enough current == enough torque).

As for your question: I would start with a fixed frequency, so you do not need "HAL_TIM_PWM_PulseFinishedCallback" for this basic start.

As for the prescaler and the like, all depends on the clock configuration, how fast you want to run with the motor and what the load is, so there it is difficult, but if you start with 1 Hz at the output to the TB, for sure this should so something, and then you can gradually increase.

Note: There are RMxxxx reference manuals available for your MCU, these essential manuals are available at the ST site and explain in detail how the timers work.

As for the settings: try PWM Generation CHx where Counter period is n (example 1000) and then use 500 for the pulse so you get a symetrical PWM signal. You can even measure this with a multimeter or an LED.

AI_I
Associate II

Thanks for your answer. I was able to reach the level of using stepper motors by trying the calculation and making changes to it. The purpose of using the "HAL_TIM_PWM_PulseFinishedCallback" function is to control the step count of the motor. I control the number of motor steps with the counter parameter I created with this function. I'm still looking for a more efficient solution to this. The code I created is in the link below. It works fine, but is there a simpler way? I am open to new ideas.

Code = https://github.com/ilbeylia/Stm32_Step_Motor_lib 

Johi
Senior III

All depends on your definition of simple, and is related to the background you have. For sure 1 disadvantage of your strategy is 1 interrupt per pulse as the callback has to be called for each pulse. As the TB goes up to 40KHz this approach could get you in to trouble related to CPU load. But anyway, what kind of application are you building? Depending on this spec, different options are possible. If you want to go full force, there is DMA with al its advantages (and complexity) as explained in: STM application note AN2820 "Driving bipolar stepper motors
using a medium-density STM32F103xx microcontroller"

Johi
Senior III

@AI_I 

I was experimenting with LL as an alternative for HAL and used your case a test case. The main loop calculates the frequency of the motor (limited as per the spec of the motor) and TIM2 pulses its callback. The callback pulses the 4 coils of the motor using a ULN2003 dalington based driver. If I find the time I will try to make a DMA version as well.

 

AI_I
Associate II

@Johi  Thanks for your help.