Output voltage regulation by SetMotor functions
Forums:
Hi,
do the SetMotor functions set the voltage of the output or is the motor power pwm regulated?
If my power source provides higher voltage than the outputs accepts, would it be best practice to drop the difference at input or on each output? (assuming both consumers a equal)
Thanks for any comments on the matter
- Log in to post comments


piborg
Fri, 09/29/2017 - 10:38
Permalink
Power setting
The power values given to the
SetMotorfunctions are indeed a PWM level to the motor.Generally speaking you should not need to drop the voltage for the motor unless your power source is drastically larger then the motor voltage. This is because the motor will naturally smooth out the input power quite a lot on its own.
For example if you have a 12 V power source and a 6 V motor it should work completely fine just by limiting the maximum power value given to
0.5. No additional hardware or smoothing would be needed :)Most of our code examples already have code for limiting the output:
# Power settings voltageIn = 12.0 # Total battery voltage to the ThunderBorg voltageOut = 12.0 # Maximum motor voltage # Setup the power limits if voltageOut > voltageIn: maxPower = 1.0 else: maxPower = voltageOut / float(voltageIn)This code calculates the maximum value to set the motors to (
maxPower) from the two voltages. The example will then use this to reduce the values sent to theSetMotorcommands, e.g:# Set the motors to the new speeds TB.SetMotor1(driveRight * maxPower) TB.SetMotor2(driveLeft * maxPower)In this case the
driveLeftanddriveRightvalues can be anything from-1.0to+1.0and the output to the motors will not exceed the specified limits.mamue
Fri, 09/29/2017 - 14:57
Permalink
Thank you piborg for that
Thank you piborg for that helpful and explaining comment. I'm quite astounded that the voltage level can be treated that liberally. I thought it ought to be correct within 0.1 Volt! Less work for me - fine.