Application:
There is one shaft (Roller1) that will be turning at a rate which is open loop, monitored, possibly varying, but not by much. It is simply hooked up to a DC motor and it is monitored with an optical encoder for the purpose of turning another shaft (Roller2) at the appropriate rate. Roller2 must turn at a rate which is a function of Shaft1's current angular velocity AND the total angle it has turned...because the diameter of one of the rollers is changing as film is rolled onto it.
Implementation:
This has to happen fast and be precise or error will stack up. What I was originally going to do, was every "small time interval" of say 50ms, I would
-
grab the small-time-interval-averaged/roughly instantaneous Roller1 angular velocity and its integrated total angle
-
based on this, calculate what we know the Roller2 speed SHOULD be (this will be changing even if Roller1's speed is constant)
-
Use PID to adjust the Roller2's DC motor speed to match the calculated value--Roller2 has an optical encoder as well.
I was going to use the PID_Beta6 library in the Playground. I had assumed that if I ran Compute() once per 50 ms small-time-interval, it would compute me an Output no matter what, so that I would be readjusting Roller2's speed every 50ms, keeping up with the changing diameter. I cannot afford to wait 1s. But now I think the library will only Compute() once per second by default. If you create with advanced options, there is a "SetSampleTime(int NewSampleTime)" method that will let me set the SampleTime down to 1ms. However now I have to ask, if I am doing this at such a high rate, should I be using the PID library at all, or should I write my own PI function?
I could SetSampleTime(1) and then the PID would calculate an Output every time I ran my loop. I'm just wondering if it makes sense to do this, or if I need to operate so fast, if using PID doesn't really make sense anymore.