Output voltage regulation by SetMotor functions

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

piborg's picture

The power values given to the SetMotor functions 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 the SetMotor commands, e.g:

                # Set the motors to the new speeds
                TB.SetMotor1(driveRight * maxPower)
                TB.SetMotor2(driveLeft * maxPower)

In this case the driveLeft and driveRight values can be anything from -1.0 to +1.0 and the output to the motors will not exceed the specified limits.

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.

Subscribe to Comments for "Output voltage regulation by SetMotor functions"