Hello,
I'm trying to control a motorised fader and using the potentiometer as a position feedback. Everything works fine beside that the movement is very jitterish. Even though I made sure that it is not just a analogRead issue.
The way the motor gets new position is via serial communication. A python tool is sending new Postions frame by frame. So the "animation" is create from after effects.
My assumption is that the jitter comes from the fact that the Arduino is driving the motor to the desired position, decelerate, stop, notify about arrival, get new position value, accelerate ........
I'm not sure if this is really the case but maybe someone faced the same issue.
And in generel my question is how to tackle those issues?
Buffer the next few positions and calculate if the motor need to decelerate or not?
This means that the whole Arduino need to have and understanding of time to know when to go to a new position and some magic code to calculate accel/decel.
Or just sending the keyFrames with handle for the motion curve.
This seams to be even more complex.
3D printers use your first suggestion. They get commands that only specify straight-line movements but by reading ahead a few lines, they can identify curves and drive the printer in a curve that joins up the straight lines. There always has to be a buffer, otherwise the printer would have to stop and wait for each command and the print will look terrible.
Unless you have good timestamps so that the thing knows in advance when and where it's going to be, then you probably can't afford buffering. The original sender is likely to expect that the motor arrives at the commanded position as soon as the command is sent.
The keyframes idea sounds like it's close to predicting the future locations. Try to make that work.
@MarkT you were right the control loop was one of the major problems here. I implemented a PID control and now the motion is much smoother. Still some little jitter moments here and there but this seam to be related to the hardware itself.
But I think this topic is still very interesting how to get from an Animation to a physical movement.
Glad the loop is working - jitter can be due to noise in the measurement of position, time-jitter in when
you read position, or an over agressive D-term (D-term tends to amplify noise). If you aren't using a D-term
then you could try reducing overall loop gain (which will slow down response though). Running the loop faster
will push the noise to higher frequencies and the mechanical inertia then filters it out more too I suspect.