Looking at the library code for the dual MC99326 Arduino shield, I see that nD2 is kept high throughout and pwm is administered through MxPWM (as the name would imply). Doesn’t this mean that between pulses the motor is braking? Wouldn’t it be better to pulse through nD2?
Drive-brake operation generally works better than drive-coast in that it produces a more linear relationship between PWM duty cycle and motor speed, especially at low duty cycles. In drive-brake mode, the motor current can continue circulating through the motor during the braking phase (this is called “slow decay”); in drive-coast mode, the motor current dies away quickly during the coasting phase (this is called “fast decay”) and needs to be built up from scratch at the start of the next driving phase.
The shield makes it pretty easy to separate the two nD2 pins, and you can wire those to PWM outputs on the Arduino if you want to directly compare drive-coast operation to drive-break operation.
I debated between starting a new thread and replying to this post over a year old but I was so pleased to find a post relating to my question that I’ll reply to this thread.
@Ben, Are you sure? To me it sounds like you’re describing the exact opposite of the way drive/brake vs. drive/coast works.
I have several of your dual MC33926 Motor Driver boards.
I haven’t worked them very hard yet but so far they appear to work great. I was very surprised to see the “2-wire” method suggested as a control option.
I understood this sort of control caused the motor to brake between each high pulse. I had always (for a few years) heard this was a bad idea and the motor should be allowed to coast between high pulses.
I compared the two methods of driving the MC33926 and found a very dramatic difference between the two types of control techniques. Pulsing only the direction pin drew much more current and drove the motor at a slower speed than when pulsing the enable pin. Pulsing the direction pin also caused the motor/gearbox to produce an awful sound.
I was using a relatively low PWM frequency of 200Hz. I suppose a higher PWM might minimize the noise issue but I find it very hard to believe the brake/drive technique is superior to the coast/drive technique of driving motors.
Do you have any empirical data to support the claim of the advantage of the brake/drive technique?
I’m afraid this post is coming across much more argumentative than I intend. I very much prefer this to be a “friendly debate” type of post.
I’ve been very happy with my (many) Pololu purchases and I consider myself a very satisfied Pololu customer.
Yes, in general, we favor drive-brake operation over drive-coast operation, though PWM frequency choice is very important; 200 Hz is very slow, and I would not be surprised if drive-coast works better at that frequency.
Generally speaking, there are two competing things going on: you have the inductance of the motor that wants to keep the current flowing in the direction that it has been, and you have the rotation of the motor, which is trying to drive the current in the opposite direction. When power is removed and the two motor leads are shorted together, it is this reverse current that acts as a brake. If the frequency of your PWM is on a time scale comparable with the inductance effect of the motor, drive-brake (or slow decay) works well because the current is able to continue circulating during the off phase, meaning you do not need to start from zero when the next active period starts. Now, if your PWM frequency is low, you lose this energy preservation benefit since not only will the current go to zero during the off phase, but the motor will slow down faster, taking kinetic energy from the system. We generally recommend using a 20 kHz PWM if your driver supports it.
The main way drive-brake outshines drive-coast is in the linearity of the relationship between PWM duty cycle and output speed. This is especially noticeable at low duty cycles. By letting the current continue circulating during the off periods, the motor is generally able to start turning at lower duty cycles and maintain slower speeds. There are some graphs of this effect here:
With drive-coast control, it can be very difficult to get intermediate speeds, and the motor might not even start turning until you hit a duty cycle of 30% or 40% (depending on the specifics of the system, such as motor inductance, rotor inertia, and coil resistance).
The above link makes it sound like power consumption is much worse when using drive-brake, but I think that could be misleading since it is only referring to no-load current, which is generally very low relative to what the motor will be drawing in a typical application. I do not expect that effect to scale with the load, and if anything, I suspect the benefits of recirculating current will increase as motor speed goes down and motor current goes up.
Thank you very much for your thoughtful answer.
Part of my confusion arises from my earlier experiments with the (infamous) L289N driver chip. Small PCBs with these drivers are ubiquitous on ebay and it hard to resist the extremely low price.
Attempting to use 20kHz PWM on the L298N produced very poor performance. When I switched to 200Hz the performance greatly improved. I was reluctant to try intermediate PWM frequencies because of the very irritating noise the motor/driver produced at these frequencies.
It appears the MC33926 driver should be able to use the 20kHz frequency so I can test the two different drive strategies at a high PWM frequency without causing distressing noises others. I’ll likely temporarily test the motors/drivers at other frequencies but I know from experience, robots are much more welcome in a home if they are not producing annoying sounds.
I’m not overly concerned about the linearity of the PWM duty cycle and speed since I’m using your very nice 70:1 (not 67:1) 37Dx54L gear motors which include encoders. As the article you linked to suggests, a PID algorithm with encoder feedback makes controlling the speed of a motor relatively simple.
I plan to take advantage of the MC33926’s current sense feature so hopefully I can reproduce graphs similar to those in the article and convince myself one way or the other about the advantages of the two drive techniques.
I’ll try to find a good way of providing a consistent load to the motors to hopefully provide data which is more meaningful to real world applications.
Again, thank you for the thoughtful reply.
Tne L298N is a relatively ancient part, so I am not surprised that it performed poorly. I would be very interested to hear what kind of results you get with your MC33926 tests, so I hope you’ll post again with what you find!
Thank you for pointing that out, and I apologize for having the wrong numbers there. Someone will be responding to your other post about this shortly, but I also wanted to mention here that we’ll go through and get that and any other problems like this corrected very shortly.