Conversation
…d float math; should be a lot faster and maybe with less jitter - Cache pwm min/max and gain and recompute only when pwmMinimum, pwmMaximum, velocityMax, or analogWriteRange change - Replace double paths with single-precision ops (lround→lroundf, fabs→fabsf, use fmaf) -> double precision not crucial and not supported by FPUs - Remove per-tick map() and % → counts work - pwmUpdate fabs-> labs - Generally, shorter and more consistent control-tick critical section. Might reduce preemption impact and free ISR headroom
Add SERVO_HYSTERESIS_ENABLE + SERVO_HYST_ENTER_CPS/SERVO_HYST_EXIT_CPS to prevent PWM chatter near 0 (preserve existing linear mapping)
…esolution - Introduce SERVO_SIGMA_DELTA_DITHERING (residual, non-overflowing implementation) - Dither float PWM counts to integer per tick so long-term average matches target for DC motors - Improve effective torque resolution near sidereal - Reduces bias and micro-jitter vs. trunc/round-only outputs - Reset residual on zero-output/disable to avoid stale carryover - Uses single-precision math
…_HYSTERESIS_ENABLE
314c2bb to
ef76359
Compare
… to pwmMin. Change it so that we map power to 0-pwmMax. If less than pwmMin then set it to pwmMin.
…ion breaking power can be reduced after the motor is moving
…or when changing direction. Implemented as a percentage over the min velocity kick config: SERVO_STICTION_KICK_MS (related to mechanical and electrical time constants and inertia and the SERVO_STICTION_KICK_PERCENT_MULTIPLIER over the countsMin - gate kick by tracking mode via ServoDriver::setTrackingMode(bool) (no-op in base, implemented in ServoDcDriver and called from ServoMotor::poll()). - compute & cache countsBreakCached (SERVO_STICTION_KICK_PERCENT_MULTIPLIER) in recomputeScalingIfNeeded() - Apply kick for SERVO_STICTION_KICK_MS on leave-zero or direction flip. After the SERVO_STICTION_KICK_MS time window then fall back to countsMinCached. - Reset kick state on zero output and clamp to min/max counts.
|
Currently, I am thinking that the acceleration ramping during tracking is a bad idea. In the calibration code it was creating inconsistent results and I think it will be a good idea to remove it also from tracking / guiding. What do you think? P.S. I have implemented it my local branches but unfortunately I can not test it right now due to clouds. P.S.2 It leads to oscillations. We need some kind of ramping. I will experiment by increasing the acceleration value |
|
I'll hang on to merge this until you do more testing. As for the "acceleration ramping during tracking" well this is an acceleration limiter and more about protecting motors/drive systems. At tracking rates it should be so darn fast (even instant as in one pass through the routine is enough to hit the rate change?) and its a setting that can be increased/decreased. I'm generally against that change. |
|
Just now much has changed in OnStepX which regrettably had to break some of this work. One of the big changes is a new Analog class the attempts to deal with global and per-pin resolution and frequency capabilities as well is handling the odd pin38 hack semi-transparently. This also adds deadband support (all Servo child classes) and for DC servo drivers deadtime (on direction change) as runtime parameters. |
|
I will try to check those out and adapt the code. Currently we have very bad skies and I did not have time to progress my work. However, merging things after refactoring usually requires a lot of work. It would help me if we could evaluate/check proposals early. |
|
The latest code has support for an inner velocity PI control loop with DC motors. The encoders have a blended velocity estimator (t/d and d/t.) Testing seemed to show it improves performance vs. operating without it. Disabling should be easy just set the vP and vI to zero or use it. Example config: // using my "DcStick" and "ABStick", both of which are enabled with logic HIGH so the default LOW won't work #define ANALOG_WRITE_RANGE 4095 // 12 bit // the MaxESP4 pinmap is designed to work with my "ABStick" module #define ENCODER_FILTER 200 // allow 200ns until next encoder edge detection to supress spurious signals // the encoder direction must be correct, the motor direction can be changed at runtime to match if needed #define PID_SAMPLE_TIME_US 2000 // normal sample time for the outside DualPID position loop is 10000us // use 0 to immediately switch from the Tracking PID set (at 0% power) to the Slewing PID set when a slewing event occurs // in arc-seconds to provide a little tolerance for the encoder not being EXACTLY on target |
|
That is a nice Christmas present! Thank you Howard! |
Some optimizations for servo DCs I have been working on and for which I would like some input