02-26-2014 07:29 AM
Hello Mr.Andy
I have gone through the loop time and the PID sample time and increased the precision of my PID coefficients
and finally could get a closer output but with a maximum error of +/- 1% in reaching the setpoint
and error in terms of RPM its Units difference
and I have a reason why this happens
while measuring the speed updates for every [10*50ms]
what happens is........ For every 50ms number of counts from the tachometer are counted and these counts are added for 10 times and the average value is taken
that means for every 500ms ill get the average speed
here's how I calculate speed per minute i.e...., RPM = [(average number of counts for 500ms *2*60)/2("TWO" PULSES PER REVOLUTION)]
RPM=[average no of counts for 500ms *60]
so the number '60' RPM is fluctuating for every +/- 1 count for avg no of counts per 500ms
from the above analysis when I keep a setpoint which is multiple of 60 (3000,2100... Etc) there will no deviation for process variable
for the rest the set points there will be deviation ..But maximum of 60 rpm or 1%
please find the supporting attachments
how can I solve this?
02-26-2014 08:17 AM
OK - so it looks like you now have the RPM under control. Well done!!
The switching either side of the setpoint, seems as you suggest due to way the you are calculating the speed (averaging over ten 50msec samples). You could create a sliding window - create an array / buffer and every sample shift it one sample left (discard oldest data) and add new sample - so you can then calculate a new value every 50msec. Or you could use a simple moving average filter - I'm sure you can find how to construct one on internet / help somewhere.
BUT - it is probably a different problem. Why are your average values all the same - either 3300 or 3360 rpm ? Is it because that is the smallest speed increment you can detect (i.e. the resolution) based on your counts ? I suspect it is. In which case the switching is due to the system not being able to measure speed to a high enough resolution. In which case the only way you can stop the oscillating is to use gap control action - essentially a deadband in the controller - but you will never exactly attain the setpoint (well you do, but subject to the speed measurement resolution).
BY THE WAY - I have only looked at you image, as I don't have time to look at the data in detail.