Drivetrain acceleration model with loss of traction (wheel slip), motor voltage drop due circuit resistance, accel based on reduced-voltage motor curves, and torque-dependent, speed-dependent, and constant friction losses.
Full C source code.
2nd-order numerical integration using Heunās Method.
CSV output file can be directly imported into Excel for graphing acceleration, speed, distance, motor amps, and motor voltage vs time.
Very cool. Now if only we could convince you to use variable names longer than 2 characters
Am I correct in assuming that Tm = Ts*(1-V/Vfree); on line 55 could also be used to figure out approximate current draw? Or am I over simplifying this?
Yes. Kt, the motor torque constant, is Newton_meters per amp. So you can calculate the motor amps A=Tm/Kt*. For a CIM, Ktā0.018 Nm/A. You could modify the C code to output amps so it could be plotted.
However, the model does not account for voltage drops due to heavy currents through the wires, the wire connection points, the batteryā s internal resistance, changes in motor resistance due to temperature, etc so the accuracy of Tm (and the current) will be affected. Also, Kt is not strictly constant - it varies somewhat with motor temperature.
Very cool. Now if only we could convince you to use variable names longer than 2 characters
Iāve been programming since 1969 and Iāve never liked long variable names. To me it makes the code much less readable. I like the code to look like the way I would write the equations. I know opinions differ on this matter.
when not slipping. when slipping, youād have to use the kinetic friction force and back-calculate the motor torque.
So, close enough for determining if itās bad or not but not close enough to be an āaccurate modelā.
Twas just a joke, I know the equations look like this but Iāve always found annotating them with english names helped me understand what was going on. Course, that was the second thing I did with this (first was read what heun integration was). Thanks for sharing this.
This is cool. I wouldnāt have looked up Heunās method if I hadnāt seen this thing. I also wouldnāt have looked up rolling resistance. This white paper has given me some homework. Hopefully I can include those two things into the calculator Iāve been playing with. Thanks very much for posting goodies like this.
Canāt look at this in-depth right now⦠but thank you very much for another great resource! This looks quite useful⦠particularly if k1, k2, and k3 are given real, semi-accurate values (not just assumptions)!
Thanks for doing this. Iām hoping your user-friendly interface will generate more interest and technical discussion, and maybe even inspire teams to conduct tests and make their data available.
I put together this āDrag Estimatorā for my HS supermileage team years ago. It is based off of the Empirical rolling resistance and wind resistance test given in the Bosch automotive handbook.
I structured the code to make it very simple to change the rolling resistance model if you want to. It takes only 2 keystrokes to change the rolling resistance model from
L = Kro+KrvV; (line #68 in the 9/19/2013_1112a code)
to
L = Kro+KrvV*V;
In fact, you could make the rolling resistance any function of V, or even use a look-up table if you have experimental data.
However, I think the V*V term only comes into play due to air resistance at speeds much higher than FRC robot speeds. It would be enlightening to see some actual data of rolling resistance vs speed for a typical FRC robot (with drivetrain mechanically disengaged from wheels) on FRC carpet surface.