-
Notifications
You must be signed in to change notification settings - Fork 671
Fix DCMotor equations to use freeCurrent #8395
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
a2baa06 to
06ae8fa
Compare
| * @return The angular speed of the motor. | ||
| */ | ||
| public double getSpeed(double torqueNm, double voltageInputVolts) { | ||
| return voltageInputVolts * KvRadPerSecPerVolt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't seem right, since plugging in a torque and voltage of zero results in a nonzero speed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
free current scales with voltage right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know. I was only ever taught about free current with respect to the free speed at the test voltage. I'm unable to find more info online either.
|
Shouldn't these equations also technically be multiplying the free current by the sign of the velocity? Otherwise, the free current makes the model behavior asymmetric for positive and negative speeds. The problem with doing that is the DC motor model becomes nonlinear instead of linear, which violates modeling assumptions everywhere else in the library. |
probably, yes, in ReCalc I simply pretend negative speeds don't exist so i overlooked this. will fix |
| */ | ||
| public double getTorque(double currentAmpere) { | ||
| return currentAmpere * KtNMPerAmp; | ||
| return (currentAmpere - freeCurrentAmps) * KtNMPerAmp; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This returns a negative torque at 0 A, but at 0 velocity, 0 A actually corresponds to 0 torque. (This and getSpeed() are what makes accounting for free current so difficult/annoying.)
DCMotorwasn't usingfreeCurrent; this meant that trying to get the torque of a motor at freeSpeed would be a nonzero torque. This fixes it and adds a handful of possibly over-parameterized tests. (Wanted to make sure the math works on a variety of motor specs.)Draft until I can fix all the tests.