I would like for the robot to stop and/or brake with something in between so it isn't so hard on the gears. Is that possible with these small motors and this motor controller?
OK. Any suggestions how I do that? Is that possible with the type of motor controller that I'm using?
I have searched this term and haven't found anything meaningful or relevant to slowing down a motor by means of synchronous rectification.
An H-bridge motor driver has 4 switches. Most often one switch is held on, another is PWM'd. This
switches from current to open-circuit, and allows the free-wheel diodes to come into play and is called
slow-decay mode.
You can switch both switchs on and off in synchrony, which is fast-decay mode as the current has to
go through 2 free-wheel diodes at full supply voltage, causing much fast current decay.
But what you need to do is hold one side of the winding constant, and switch the other with PWM between 0V to +V. Thus one switch is held on, two others are alternating (with a little dead time between to avoid shoot
through).
So you need to see what the inputs to your H-bridge do to each of the switchs (on or off), and figure out
how you can arrange this mode.
Some H-bridges have only two input pins and can only do synchronous rectification mode.
The name "synchronous rectification" is not a good name, but there doesn't seem to be a better one. Perhaps
"no decay mode"...
TeslaIaint:
OK. Any suggestions how I do that? Is that possible with the type of motor controller that I'm using?
Well it looks like you can control all the inputs how you like, so yes, but you probably need
to program the Arduino timer units directly to get antiphase PWM drive.
In the previous code, the 250ms of previousCoastMillis always already pass before allStop is ever called so the hard stop only is engaged when the function is called. Now every time the allStop is called, the motors coast while stuck in the while loop for 150ms. That's just enough to slow down and split the difference between coasting too far and locking up the motors.