Monsterborg motor coasting
Forums:
I realise that calling the MotorsOff function actually puts the motor on hard stop, is there any way to allow the motor to coast to a stop instead of hard stopping? I suppose this will be less harmful to the motors and less likely to tip over when carrying load.
- Log in to post comments


piborg
Fri, 05/04/2018 - 22:16
Permalink
Gentle stop
Unfortunately the ThunderBorg does not have the capability to allow the motors to coast.
What you can do instead is create a function which will gradually reduce the motor power to nothing. This is gentler on the motors than a hard stop and should cause your MonsterBorg to slow down in a much more controlled fashion.
Here is an example of how this can be done:
# Needed imports import ThunderBorg import time # Function to perform a gentle stopping of the motors def GentleStopMotors(TB): # Settings for the slow down stepSize = 0.02 # Power reduction per step delay = 0.01 # Delay in seconds between each reduction # Start by getting the current motor power speedMotor1 = TB.GetMotor1() speedMotor2 = TB.GetMotor2() # Determine the direction to change motor power if speedMotor1 < 0: stepMotor1 = -stepSize else: stepMotor1 = stepSize if speedMotor2 < 0: stepMotor2 = -stepSize else: stepMotor2 = stepSize # Step the motors down until they both reach zero while (speedMotor1 != 0) and (speedMotor2 != 0): # Reduce the values towards zero if abs(speedMotor1) > stepSize: speedMotor1 -= stepMotor1 else: speedMotor1 = 0 if abs(speedMotor2) > stepSize: speedMotor2 -= stepMotor2 else: speedMotor2 = 0 # Set the new power levels and wait TB.SetMotor1(speedMotor1) TB.SetMotor2(speedMotor2) time.sleep(delay) # Example usage TB = ThunderBorg.ThunderBorg() TB.Init() TB.SetMotor1(0.7) TB.SetMotor2(0.5) time.sleep(1.0) GentleStopMotors(TB)The function takes the current motor powers and reduces them at a fixed rate until both motors are off. You can change the rate of the slowdown by adjusting the
stepSizeanddelayvalues.robotter
Sat, 05/05/2018 - 06:26
Permalink
Thanks for the quick reply
Thanks for the quick reply and sample code workaround.
Is there any plans to implement coasting in the future?
piborg
Sat, 05/05/2018 - 12:46
Permalink
Coasting support
Unfortunately this is a limitation of the drive chips used on ThunderBorg, they will only go into coasting mode when a fault has been detected with the motors or power supply.
Our more powerful controllers (such as Diablo) have this functionality, so it is possible we will have smaller boards which support this in the future. At the moment we do not have any planned with the feature.