• AVR Freaks

Helpful ReplyHot!Stepper motor driving with half-bridge H IC driver DRV8844

Author
davide6893
New Member
  • Total Posts : 4
  • Reward points : 0
  • Status: offline
2019/10/21 08:15:35 (permalink)
0

Stepper motor driving with half-bridge H IC driver DRV8844

Hello to the whole forum.
I just signed up to hope I could clear up some doubts that came over me while I was defining the specifications for my new personal project so please don't hesitate to move this thread to another section if you think it is more appropriate. I'm an electrical engineer and I'm fascinated by the world of microcontrollers, but I have little experience in this regard.
I have already programmed some 8 bit MCUs in assembler, but for simple projects. I know the C language but I'm not expert at all.
 
What I would like to do would be to design a board capable of driving in all possible ways (wave control, full step drive, half step drive, microstepping, current control as chopper and fixed decay mode and alternating decay mode, of which the mode that I will use principally will be the chopper microstepping with alternating decay mode) of the small stepper motors, but that it is the most versatile possible, that is that it can be adapted through software or better without any modification to drive even stepper motors with different characteristics between them, but the user always has the position, speed and acceleration and maximum current for winding controls available.
 
I have adequately inquired about the stepper motors and the driving and control techniques, reading the Microchip AN822, AN906, AN907, AN1307 and also other documentation and the one that comes closest to my needs is the AN1307.
In essence, the card should drive two stepper motors through a microcontroller and a dedicated driver. Furthermore, it is available for each winding of the motors the reading of various analogue quantities such as the current that circulates there, the common winding voltage of the winding for each of the two half-bridges and a voltage divided and proportional to that of DC BUS's voltage that feeds the half-bridges H. Eventually I will also provide comparators that disable bridges when the current exceeds a winding limit due to a problem.
 
For the current reading I thought I would use an integrated shunt like TI's IN253, but I would put the shunt in series with the winding unlike other schemes that provide it at the bottom between the low mosfet sources and the ground. In this way I could also read the recirculation current.
 
As a driver for motors I decided to use TI's DRV8844, which contains 4 half-bridges whose mosfets are controlled by an internal logic that prevents the two mosfets of the half-bridge from being run simultaneously and from input and enable inputs. How it works is similar to the popular L293, but it is more powerful, allows more control and is also recommended for stepper motors.
 
As for the choice of the microcontroller, I would be oriented to a 16 bit, specifically to a dsPIC, in particular the dsPIC33CK256MP508 family. I would have chosen the dsPIC33CK256MP506, but I am willing to choose another if you have a more appropriate model to recommend.
 
The questions I want to ask the community are:
1) What do you think about my project? Do you have any advice for me to improve it?
2) Given my control needs, which peripherals of an MCU will be indispensable to me and what kind of signals will I have to generate to drive the DRV8844 in a similar way to what is shown in the AN1307?
3) Could the MCU I have chosen be good for this type of application and peripherals owned or would you recommend another model?
 
Thank you in advance.
#1
Mysil
Super Member
  • Total Posts : 3488
  • Reward points : 0
  • Joined: 2012/07/01 04:19:50
  • Location: Norway
  • Status: offline
Re: Stepper motor driving with half-bridge H IC driver DRV8844 2019/10/21 12:50:19 (permalink)
5 (1)
Hi,
Seem to me that your suggestions seem reasonable.
but usually Stepper motor control is done by smaller microcontrollers than 16 bit dsPIC signal processors.
The motor control peripheral in the microcontroller you are planning to use,
have controls for a total of 8 half bridges with separate outputs for High-side and Low-side switches.
 
Still, controlling 2 separate motors from the same microcontroller,
may cause a more complicated program structure, than dedicating a separate microcontroller for each motor,
especially if you do not have a lot of experience from similar projects.
 
Much of the work will be related to the motor control peripheral in the microcontroller device you select,
so mch the software you make, may possibly be adapted to any PIC microcontroller with the same motor control PWM peripheral.
 
In 3 phase synchronous motors, a lot of research have gone into optimizing drive current, by sensing phase shift between applied voltage and sensed current, and generated back EMF from the motor. At low commutation freq frequency, or while stationary, this doesn't work
For Stepper motors, this is not so common, so stepper motors are often driven with higher current, and thus higher power losses than optimally needed.
This is needed for stepper motor to achieve high acceleration without loosing steps.
 
Using a position encoder connected to the Quadrature Encoder Interface (QEI) peripheral,
it may be possible to reduce drive current, and thus energy loss and heating, or even switch current completely off while motor is stationary, without loosing position.
Then you are into the range of servo control.
 
Generally, a modern microcontroller have more peripheral resources and capabilities than what is actually used in any single project. Use of other peripherals depend on your preferences and requirements for User interface and communication with other devices.
 
    Mysil
 
#2
NorthGuy
Super Member
  • Total Posts : 5817
  • Reward points : 0
  • Joined: 2014/02/23 14:23:23
  • Location: Northern Canada
  • Status: offline
Re: Stepper motor driving with half-bridge H IC driver DRV8844 2019/10/21 17:03:14 (permalink)
5 (1)
Well thought out project.
 
If you simply want to drive a stepper, getting a specialized driver, such as drv8886at (which BTW measures recirculating current too), is certainly the way to go.
 
If you're interested in building the driver yourself (rather than just driving a motor), then you made an excellent choice of the microcontroller. It will have no problem driving two motors.
 
You will have to use PWM modules and adjust duty cycle to produce desired current. You will also need ADC to measure the real current. Aside of these two and various timers, you won't need much.
 
Of course, you will need some means to communicate to your MCU, either from PC or from user interface, depending on your needs. This is done with peripheral modules. Do not overlook this part.
 
Do not forget limit switches, LEDs etc. These things need pins.
 
#3
davide6893
New Member
  • Total Posts : 4
  • Reward points : 0
  • Status: offline
Re: Stepper motor driving with half-bridge H IC driver DRV8844 2019/10/22 01:32:20 (permalink)
0
I sincerely thank both of them for their clear explanation and valuable advice.
 
In summary and replying to your messages I would like to say that I would like to manage the entire application from a single microcontroller, which manages both the motors and the other external contour modules, unless I strongly advise you that it is better to have a motor managed by each microcontroller more compact which in turn is controlled by a main microcontroller. However, isn't the project even more complicated?
 
I would also like to point out that the DRV8844 has non-independent semi-bridge mosfets as a true H-bridge with discrete components, but they can be controlled in push-pull mode via the input and enable inputs (see tables 1 and 2 of the datasheet). Can there be complications in the control with the available peripherals in the MCU? I wanted to choose this driver because it seemed to me quite compact as a solution and that could give me more freedom of control than dedicated ICs for stepper motors.
 
For now I believe that with the motors I will use I will be far within the driver's current limits, as they have a nominal current of less than 0.4A per winding. However, I should be able to adjust the pwm duty cycle to avoid it exceeding this value when it is piloted with voltages much higher than the nominal one. Basically I wouldn't worry too much about dissipative losses.
 
I don't have the possibility to add a position encoder and limit switches in this project.
 
Obviously there will also be a part that will handle the user interface through a UART-RS232 serial communication with the PC or later with an adapter or a simple MCU for UART-USB conversion.
post edited by davide6893 - 2019/10/22 11:19:56
#4
NorthGuy
Super Member
  • Total Posts : 5817
  • Reward points : 0
  • Joined: 2014/02/23 14:23:23
  • Location: Northern Canada
  • Status: offline
Re: Stepper motor driving with half-bridge H IC driver DRV8844 2019/10/22 08:59:14 (permalink)
0
davide6893
In summary and replying to your messages I would like to say that I would like to manage the entire application from a single microcontroller, which manages both the motors and the other external contour modules, unless I strongly advise you that it is better to have a motor managed by each microcontroller more compact which in turn is controlled by a main microcontroller. However, isn't the project even more complicated?

 
IMHO, single microcontroller is the best solution.
 
davide6893
I would also like to point out that the DRV8844 has non-independent semi-bridge mosfets as a true H-bridge with discrete components, but they can be controlled in push-pull mode via the input and enable inputs (see tables 1 and 2 of the datasheet). Can there be complications in the control with the available peripherals in the MCU?

 
No, there will be no complications. However, the PIC's PWM module can produce all the effects by itself - generate complimentary waveforms, produce dead time. Look at its description - it is very sophisticated.
 
davide6893
I wanted to choose this driver because it seemed to me quite compact as a solution and that could give me more freedom of control than dedicated ICs for stepper motors.

 
Dedicated ICs for steppers would make it even easier - you only send pulses when you want the motor to move. They're also likely to be cheaper. If you only interested in moving the motor, the dedicated ICs are very hard to beat. Of course, if you're interested in making it work all by yourself, dedicated ICs are not a viable choice.
 


#5
davide6893
New Member
  • Total Posts : 4
  • Reward points : 0
  • Status: offline
Re: Stepper motor driving with half-bridge H IC driver DRV8844 2019/10/22 11:38:55 (permalink)
0
Could you kindly suggest me how to connect the 16 enable and input inputs of the 8 semi-bridges of the two DRV8844 drivers to manage the two motors to the pwm module of the MCU and the driving technique?
I assume the module has no problem generating pwm exactly with duty cycle at 100% or 0% when necessary, correct?
Does the frequency of the pwm vary or "the duty cycle varies with different speeds" to vary the motor speed?
Thank you for your support and for your patience.

post edited by davide6893 - 2019/10/25 02:18:12
#6
NorthGuy
Super Member
  • Total Posts : 5817
  • Reward points : 0
  • Joined: 2014/02/23 14:23:23
  • Location: Northern Canada
  • Status: offline
Re: Stepper motor driving with half-bridge H IC driver DRV8844 2019/10/22 13:12:32 (permalink) ☄ Helpfulby davide6893 2019/10/23 06:36:16
4 (2)
davide6893
Could you kindly suggest me how to connect the enable and input inputs of the 16 semi-bridges of the two DRV8844 drivers to manage the two motors to the pwm module of the MCU and the driving technique?

 
It has a table in the datasheet "Table 2. PWM Function" which explains which pins to set to 0 or 1 and which pins to PWM. You get a full bridge for each winding and you need a single PWM. Increasing duty cycle will increase the current through the winding. Decreasing the duty cycle will decrease the current by letting current to recirculate. You measure the actual current and compare it to the current you want. By changing the duty cycle you make them the same.
 
davide6893
I assume the module has no problem generating pwm exactly with duty cycle at 100% or 0% when necessary, correct?

 
Yes. The PWM has good precision, but you never really get to 100% unless your supply voltage is too low or you're moving the motor too fast (so that back EMF eats all the voltage).
 
davide6893
Does the frequency of the pwm vary or the duty cycle varies with different speeds to vary the motor speed?



No. PWM frequency is typically constant and PWM usually has much higher frequency than the motor stepping.
 
Basically, you have sine and cosine waves. Sine wave for one winding and cosine wave for the other winding. If you plot the two waves together, the X axis will be the position of the motor and Y axis will be current. You simply select the point on the graph where you want your motor to go, you read two currents from the graph, and you drive these currents into the windings by manipulating the PWM duty cycle. As a result, the stepper goes to the selected point and stays there as long as you maintain the current in windings the same. By moving from one point to another you can move motor long distances. Of course there are limitations. If your motor is moving fast (300+ rpm for a motor without load) you cannot stop it abruptly and want to decelerate slowly.
 
The simplest drive is in full steps - when the points you select are 90 degrees apart. This way you only get 1, 0, or -1. If you look at sine/cosine graph, you'll see that full stepping always drives full current into only one winding - this winding pulls the motor some, then you switch to the other winding and it pulls a motor one step more. The full cycle takes 4 steps. Thus, the motor with 400 steps per revolution, will have 100 cycles per revolution.
 
You can do full stepping without PWM - you just drive the winding 100% or you don't. If you do, you must have relatively low voltage (so that it doesn't burn the motor when speed is low). This will work. But controlling current is much better.
 
Driving in half steps (45 degrees) is also easy - you either drive one winding, or two winding with the same current (typically 0.7 of the peak current). When you drive two windings, one of them pulls motor forward while the other tries to stop it. If you leave it that way, the motor will be stuck in the middle  between steps. If you release one of the windings, the other one will pull the motor - that'll be a half step.
 
Driving in smaller increments is called microstepping (22.5 degree will be 1/4 steps, 11.25 degrees will be 1/8 steps, 6.625 degrees - 1/16 steps etc). Microstepping makes movements smoother and decreases noise. You can decrease steps as you want as long as the stepping frequency is somewhat lower than the PWM frequency.
 
The faster you move through the curves, the faster the motor goes. If you want to reverse direction, you just start moving through the curves backwards.
 
#7
NorthGuy
Super Member
  • Total Posts : 5817
  • Reward points : 0
  • Joined: 2014/02/23 14:23:23
  • Location: Northern Canada
  • Status: offline
Re: Stepper motor driving with half-bridge H IC driver DRV8844 2019/10/23 16:09:26 (permalink)
4 (1)
Another method is to control driver with DAC and comparator instead of PWM.
 
You wire one input of the comparator to the current sensor, and the other input to the output of the DAC. Then you configure DAC to output voltage which corresponds to the desired current. The comparator will automatically turn the signal off when there's too much current, or on when there's not enough current. All you need to do is to adjust DAC. Of course, for this you would need to measure current at all times, even during recirculation.
 
Your PIC has DACs and comparators.
 
#8
ixqprint
New Member
  • Total Posts : 4
  • Reward points : 0
  • Joined: 2019/10/17 17:40:49
  • Location: 0
  • Status: offline
Re: Stepper motor driving with half-bridge H IC driver DRV8844 2019/10/23 18:49:30 (permalink)
0
NorthGuy
davide6893
Could you kindly suggest me how to connect the enable and input inputs of the 16 semi-bridges of the two DRV8844 drivers to manage the two motors to the pwm module of the MCU and the driving technique?

 
It has a table in the datasheet "Table 2. PWM Function" which explains which pins to set to 0 or 1 and which pins to PWM. You get a full bridge for each winding and you need a single PWM. Increasing duty cycle will increase the current through the winding. Decreasing the duty cycle will decrease the current by letting current to recirculate. You measure the actual current and compare it to the current you want. By changing the duty cycle you make them the same.
 
davide6893
I assume the module has no problem generating pwm exactly with duty cycle at 100% or 0% when necessary, correct?

 
Yes. The PWM has good precision, but you never really get to 100% unless your supply voltage is too low or you're moving the motor too fast (so that back EMF eats all the voltage).
 
davide6893
Does the frequency of the pwm vary or the duty cycle varies with different speeds to vary the motor speed?



No. PWM frequency is typically constant and PWM usually has much higher frequency than the motor stepping.
 
Basically, you have sine and cosine waves. Sine wave for one winding and cosine wave for the other winding. If you plot the two waves together, the X axis will be the position of the motor and Y axis will be current. You simply select the point on the graph where you want your motor to go, you read two currents from the graph, and you drive these currents into the windings by manipulating the PWM duty cycle. As a result, the stepper goes to the selected point and stays there as long as you maintain the current in windings the same. By moving from one point to another you can move motor long distances. Of course there are limitations. If your motor is moving fast (300+ rpm for a motor without load) you cannot stop it abruptly and want to decelerate slowly.
 
The simplest drive is in full steps - when the points you select are 90 degrees apart. This way you only get 1, 0, or -1. If you look at sine/cosine graph, you'll see that full stepping always drives full current into only one winding - this winding pulls the motor some, then you switch to the other winding and it pulls a motor one step more. The full cycle takes 4 steps. Thus, the motor with 400 steps per revolution, will have 100 cycles per revolution.
 
You can do full stepping without PWM - you just drive the winding 100% or you don't. If you do, you must have relatively low voltage (so that it doesn't burn the motor when speed is low). This will work. But controlling current is much better.
 
Driving in half steps (45 degrees) is also easy - you either drive one winding, or two winding with the same current (typically 0.7 of the peak current). When you drive two windings, one of them pulls motor forward while the other tries to stop it. If you leave it that way, the motor will be stuck in the middle  between steps. If you release one of the windings, the other one will pull the motor - that'll be a half step.
 
Driving in smaller increments is called microstepping (22.5 degree will be 1/4 steps, 11.25 degrees will be 1/8 steps, 6.625 degrees - 1/16 steps etc). Microstepping makes movements smoother and decreases noise. You can decrease steps as you want as long as the stepping frequency is somewhat lower than the PWM frequency.
 
The faster you move through the curves, the faster the motor goes. If you want to reverse direction, you just start moving through the curves backwards.
 


Good explanation
#9
LdB_ECM
Senior Member
  • Total Posts : 164
  • Reward points : 0
  • Joined: 2019/04/16 22:01:25
  • Location: 0
  • Status: offline
Re: Stepper motor driving with half-bridge H IC driver DRV8844 2019/10/23 22:06:30 (permalink)
0
You cant meet the timing requirements to do serious microstepping on a PIC, you will also have noise immunity issues with the flyback. To explain for something like 128 or 256 microsteps per step you are going to face a pulse rate of around 1Mhz.
 
You are aware of the sine and cosine tables and you need those table values to change with the least jitter possible relative to the step pulse.
 
We used to build commercial versions using FPGA ( Xilinx XC95144), I still have a couple of hundred if you want one :-)
 
They have no commercial value these days so I have put the schematic and the VHDL code up online if it interests you.
https://github.com/LdB-ECM/CIMS
 
The VHDL code will sort of show you what your C code would be required to do.
https://github.com/LdB-EC...lob/master/cims4v0.vhd
 
post edited by LdB_ECM - 2019/10/23 22:08:44
#10
NorthGuy
Super Member
  • Total Posts : 5817
  • Reward points : 0
  • Joined: 2014/02/23 14:23:23
  • Location: Northern Canada
  • Status: offline
Re: Stepper motor driving with half-bridge H IC driver DRV8844 2019/10/24 07:51:33 (permalink)
5 (1)
LdB_ECM
You cant meet the timing requirements to do serious microstepping on a PIC, you will also have noise immunity issues with the flyback. To explain for something like 128 or 256 microsteps per step you are going to face a pulse rate of around 1Mhz.



You can vary the level of microstepping depending on the speed of the motor. At low speed you can use finer microstepping. When the motor is cruising at high speed you can switch to full steps. And everything in between. This way, you can maintain manageable pulse rates.
#11
davide6893
New Member
  • Total Posts : 4
  • Reward points : 0
  • Status: offline
Re: Stepper motor driving with half-bridge H IC driver DRV8844 2019/10/25 02:56:09 (permalink)
0
I would like to configure the micro only once and then check all the operation by software and I would like to maintain the maximum freedom of control over the motor driving technique (type of decay, type of step, etc.) if possible.
I connect each motor winding to each pair of half-bridge, so I'll have to use all the 8 pwm modules of the pwm peripheral, right?
 
For the first H bridge, I connect pwm1h and pwm1l signals to in1 and in2 and pwm2h and pwm2l signals to en1 and en2 so on then to all others, then I can decide by software if that output must be at level 0 (duty cycle 0% ) or level 1 (100% duty cycle), right?
 
From the "Table 2. PWM Function" of the datasheet in fast decay mode, pwm is indicated twice. Does it mean that I have to send the exact same signal (not phase shifted and not denied) to both inputs indicated? Even this can be done without difficulty, right?

Could you kindly advise me on the best MCC configuration for the pwm generator peripheral for my type of application, please?
 
Thank you so much.
post edited by davide6893 - 2019/10/27 08:09:41
#12
NorthGuy
Super Member
  • Total Posts : 5817
  • Reward points : 0
  • Joined: 2014/02/23 14:23:23
  • Location: Northern Canada
  • Status: offline
Re: Stepper motor driving with half-bridge H IC driver DRV8844 2019/10/25 06:03:45 (permalink)
0
davide6893
I connect each motor winding to each pair of half-bridge, so I'll have to use all the 8 pwm modules of the pwm peripheral, right?

 
You need only one PWMs to drive one full bridge with drv8844. You connect its output to several pins, as per the table. You need two full bridges for each motor (one for each winding).
 
davide6893 ... then I can decide by software if that output must be at level 0 (duty cycle 0% ) or level 1 (100% duty cycle), right?

 
Yes. You can also disable the PWM output and drive the pin manually.
 
These PICs also have PPS (peripheral pin select) which may let you map the module's output. Some of the PWM modules may be PPS-able (look at the datasheet). There are also logic cells which may be used to re-route signals. It's important to make sure you can route the signals to the desired pins before making PCB.
 
davide6893
From the "Table 2. PWM Function" of the datasheet in fast decay mode, pwm is indicated twice. Does it mean that I have to send the exact same signal (not transferred in phase and not denied) to both inputs indicated? Even this can be done without difficulty, right?

 
Yes. you just run two traces from the output pin.
 
davide6893
Could you kindly advise me on the best MCC configuration for the pwm generator device for my type of application, please?



I don't know. I never use MCC.
#13
Jump to:
© 2019 APG vNext Commercial Version 4.5