I’m using a jrk controller, with an accelerometer as the feedback device, for a simple platform stabilizer. The accelerometer output changes with tilt, and the motor turns to counteract the tilt. Simple, and it kind of works, but the feedback signal is extremely noisy. The accelerometer is attached using foam tape to help minimize vibrations, but what can I do to smooth the signal? I have tried all kinds of settings on the jrk, and decoupling capacitors on the supply. Can anyone offer any practical suggestions?
You should look into filters. You can make a really simple low-pass filter with just a resistor and a capacitor.
Thanks. I’ve used a low-pass filter, but it’s not that kind of noise. I guess I need to explain a bit better.
It’s caused by the variable output from the accelerometer, often swinging by 5-10% while stationary. When I move the motor target position by dragging the slider bar (or using a pot), the motor follows the target, but with big sawtooth errors with a period of about 5 ms. When I stop and the usual settling has occurred, the acceIerometer signal is still changing slightly. I thought this may be related to the sampling period of the controller, but adjusting the number of samples and the PID cycle time don’t remove it. Each time the accelerometer is “read” it is giving a significantly off-target reading.
I can turn down the P factor to reduce it, or put a fat capacitor across the accelerometer, but then I lose the response.
Any other thoughts how I can smooth the readings?
It is hard to tell from your description whether the problem is with the accelerometer or with the jrk and motor setup. Could you post some screenshots of the graphs window showing the feedback, motor output, and so on so we can see the problem you are talking about? What values were you using for the low-pass filter and for the jrk’s averaging? What have you done to optimize the PID settings?
I’ve attached screenshots of the motor target (blue) and feedback (red), with the PID parameters. This is set to be just below the (in)stability threshold. I was using 256 samples, and 3ms cycle, to achieve good response. For the low pass filter I tried many combinations of R and C, giving drop-off anywhere from about 5Hz to 1500Hz - this did not seem to make any difference.
I’m wondering if the problem is simply the backlash in the motor gearbox (it’s a MFA motor/gearbox, 50:1) - every PID cycle it is given a kick, and responds and the inertia makes it overshoot. Does that seem likely? I did try attaching the accelerometer direct to the motor shaft, but there was no way to achieve stability with the high revs.
jrk graph.docx (53.4 KB)
I think you should try setting the integral coefficient to 0 for now, since that should not be necessary to get basic feedback working. It does not look like overshooting to me - the red line never reaches the blue line at all. I would like to see the same graph but with the “Duty cycle” variable enabled, so we can see whether it is trying to move at all.
Also, to separate the effect of the motor from noise in your sensor, can you show us the same graphs with the motor power disconnected, so that nothing is moving?
Note that you can use “upload attachment” or the Img button to post an image directly instead of posting it as a DOC file.
Thanks. Here are screenshots
- With the motor power off, just rotating the shaft with the accelerometer attached. The sawtooth is still there, so it’s not just backlash
- With the motor power off, but showing duty cycle
For info, the accelerometer is a DE-ACCM2G, but the effect is the same with an ADXL335.
Thanks for posting those graphs. I wouldn’t describe this noise as a “sawtooth” at all - it just looks like random noise to me. And given that the noise clearly has a typical timescale of less than 100ms, I am surprised that you said a 5 Hz RC filter was unable to improve it. Can you post exactly what circuit you used to filter it? (A picture might be the easiest way to show us.)
A big problem with your current setup is that the P term combined with the strength of the motor is not sufficient to move your system close to its target. Do you see how the motor is trying to move with a ~10% duty cycle but is unable to? You might need to go to a higher gear ratio, but I would be interested to see what the graph looks like when you increase the P term a lot. Does it actually become unstable, or does just vibrate because of the noise in your accelerometer?