-
Notifications
You must be signed in to change notification settings - Fork 91
Bug calibrated sensor + uint16 lut #75
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: dev
Are you sure you want to change the base?
Conversation
|
Memory usage change @ b449248
Click for full report table
Click for full report CSV |
|
I don't think downsampling the LUT is a good idea. I don't think it should be up to the user to set LUT size in this way. User configurable LUT per electrical angle would make more sense I think, that way you never run into the issue of up/downsampling. |
This PR fixes the bug #73 + It fixes the bug of the hard-coded number of samples per motor (
5 * motor.pole_pairs) - see more info in the community.Automatic number of samples given a LUT size
Now the code will automatically choose the number of samples to run in one motor rotation based on the LUT size.
It will always do the closest posible number of samples to the LUT size that is multiple of the motor's pole_pairs number.
That way we guarantee that the sampling is equal for each electrical angle.
Then at the final stage the the samples will be remapped to the user's requested LUT size.
For example if we have a BLDC motor with 7 pole pairs and he wants a LUT size of 200
The calibration will be done with
ceil(200/7) * 7 = 203 positinsAnd then at the end of the calibration process the
203values will be mapped to the200.This mapping at the moment does not implement any interpolation, it only extrapolates. It should work for most use cases.
uint16 LUT rather than float
The main reason is the memory footprint. The LUT now requires half the memory.
The float to uint16 scaling is done with the
encodeOffsetU16anddecodeOffsetU16functions that basically just scale float angle of [-pi, pi] to [0, 65535].For the moment the resolution is ~0.000096 rad (~0.0055 deg) , which is probably fine for most of applications.
For example if we take a stepper motor with 50pp, in one electrical rotation is discretized in
360/50/0.0055=1309elements which amounts the resolution of the electrical angle of around~0.275 deg.The resolution can be greatly improved if we consider that the LUT will have a smaller range than [-pi,pi] (which is probably always the case). In that case we can increase the scaling factor LUT_SCALE in the
CalibratedSensor.hand increase the overall resolution of the LUT.