Quote:
Originally Posted by AriMindell
I am working on programming a motor simulator for FRC motors, which allows a user to input a set of motors, a gear reduction, and an attachment in the form of a moment of inertia.
The simulator should calculate the angle, angular velocity, and angular acceleration of the attachment at any time.
Currently, I calculate the angular acceleration (alpha) of the attachment, then add alpha(*dt) to the angular velocity (omega), and omega to the position (theta).
I had determined the following formula for torque of the motor, given voltage and current speed: stallTorque * (percentVoltage - (omega / freeSpeed)
and I know from physics that: alpha=torque/moment.
This does not work as expected, and I think it's because my formula for torque is wrong, and I don't fully understand DC motors.
How are speed and torque related? by most explanations, speed should have an inverse relationship with torque, but this system would indicate that it does not. Am I making a false assumption?
|
Hi Ari,
I love how you think, your instincts are spot on. The devil's in the details as they say, and you just need to scale the right terms. I started out 30 years ago as a brushless DC motor guy, and it's all too easy (for me) to recite equations but I really struggle to explain DC motors in a clear and understandable way.
If you assume that the motor torque when stalled is the "stall torque" (given a full input command) then when the motor reaches the no-load speed the torque reaches zero (hence max speed with no torque). Look at the factor (no-load speed - speed)/no-load speed and you'll get a term that starts at 1 and linearly goes to 0 at the no-load speed. let torque = stall_torque*(no-load speed - speed)/no-load speed and you've got it.
let alpha = torque/inertia, and velocity = velocity + alpha*deltatime, and your done. BTW, if you're using a motor command of let's say: cmd = k, where k is between + and - 1, torque becomes = stall_torque*(cmd*no-load speed - speed)/no-load speed.
If you publish what you have, we have about 17 hours before build season starts to sort it out
Sincerely,
Steve Spoldi.