08-23-2014 04:06 PM
hi All ,
im having problems trying to tune my controller , i can get it to go to steady state of any description.
basically im positioning a ping pong ball in a tube with a fan. the fan speed is controlled by a pwm stand alone controller excepting a 0/5v input from a 6008daq.
feed back is via web cam and the vision assistant colour matching.
when the ball over shoots setpoint the error is positive falling to set point once under setpoint error goes negative and controller into saturation , ive played with switching the integrator out but the response is two slow and if i turn up Kp in into saturation again. currently in trying to range the setpoint. and use gain scheduling
am i missing somthing ??
08-23-2014 06:16 PM
You have two while loops that are running a fast as they can and there is no communication(s) between them.
This is just too parallel loop running and as is there is no saying of what may occur at the moment you you expect the control to happen.
Barddya
08-24-2014 03:23 AM
hi barddya,
so am i better will the pid running in the ione while loop ?
08-24-2014 11:32 AM
Your loop timing is controlled by the time it takes for the code inside each loop to execute. I do not have the Vision code so I cannot tell how things are configured. If you are acquiring ~ 30 frames/second, then the loop runs at about that rate (unless the image matching takes longer than that). The DAQ loop likely tries to run faster than that because writing a single value to the DAQ is probably faster than the vision acquisition.
You do have a form a communication between the loops: the cluster local variable. This is not a particulalry good form of interloop communications. Suppose the lower loop runs in 10 ms and the upper loop takes 33 ms. Then the cluster local variable would be read 3 or 4 times for each time new data is written to it. The PID code will see those repeated values. The internal buffers will will cause the PID to operate as though the input does not change for 3-4 calls then jump to a new value. It will probably be easier to tune if it only executed when new data is available. How do you do that? Transfer the data between the loops with a queue.
Two loops in a control system program is common. You could probably get by with just one.
How much time elapses between sending a new voltage to the fan and when the ball actually moves? Delays in the "plant" can create problems for control systems.
Lynn
08-24-2014 01:31 PM
hi lynn
thanks for the info ,the camera is 30fps, releastly im getting between 7/14fps
ill play around with ques and see if i can get it to work any better , there is a lag of initaly 1.8v before the fan starts to move , im compensated this by setting the min output on the controler, probably not the best way to do it but its helping for the moment.
stephen
08-24-2014 01:55 PM
stephen,
With a queue you will only get one iteration of the PID loop for each iteration of the vision loop. That will assure that the PID is always operating on current data.
The PID controller internally probably works on the basis of 0 to 100% although I have not checked the code. For your fan it appears that 0% is 1.8 V and 100 % is 5 V. You can put a simple linear scaling in the PID loop to compensate. You definitely do not want the PID generating outputs less than 1.8 V because this would put your control system in a non-linear operating region.
Lynn
08-24-2014 02:02 PM
stephen,
I did not adequately address the issue of delay that I had asked about earlier. Let me try an example.
Suppose the Analog Output from the USB-6008 is 3 V and that the ping pong ball is stable or moving very slowly. If you disable the PID and manually change the output voltage to 4 V, how many iterations of the vision loop are required before you detect a change in position of the ball?
A related question is: What it the smallest change in output voltage which produces a measurable change in the position of the ball?
Lynn
08-25-2014 09:44 AM
hi lynn ,
thanks again for your response.
i changed the controller to 0-100% and i seems to be adjusting better.
im still working on getting the queue to work once i have it sorted i can find out how many iterations of the vision loop are required before you detect a change in position of the ball .
thanks again
stephen