I would like to build up a real-time algorithm on the arduino mega to control a motor that will act like a virtual spring-mass-damper system. I'm wondering if the processor is capable of real time control. There will be some calculation necessary and in order to use a model based filter I need a sampling rate of less than 1ms.
Thanks for your help!
Frank
So you need a loop time of 1mS, enough to do some calculations but not many.
How is the simulation going to manifest itself?
Motor control, is it the speed? And what is the input? What form does that take?
The input is position, velocity and acceleration. The torque is controlled by an analog signal. The model is a simple mass spring damper system that allows smoothing the signals with a kalman filter.
Sorry I think that is way too much for an arduino on a 1mS sample loop. It's also hard to get all those parameters in to the machine.
If a "motor" is involved in the action to dampen the spring action, then you probably can use a time period larger than 1ms for sampling data. Motors have physical inerta that probably takes much more time to change than the 1ms realm.
You are describing PID control
Are there better algoritms than that?
If you know your formulas, then maybe you can use some kind of linear interpolation?
thanks a lot for your replies. The formulas are not that many, it's based on a linear model. And I get all the signals over the analog input except the position which is an encoder signal.
Do you have any experience of using a capacitor on the pwm output as a low pass filter to smoothen the signal?
Thanks!
Do you have any experience of using a capacitor on the pwm output as a low pass filter to smoothen the signal?
Just for testings and grins, I've used a series 10k resistor followed by a 10MFD cap from the resistor to ground, then using the junction of the R/C as the true analog output. The R/C time constant of this simple low pass filter would of course effect the response time of this filter. Anyway it worked fine.
Lefty