By erratic, do you mean something like spikes or noise? If so, another approach might be to "filter out" the noise. IOW, sample continuously, but if the signal changes too rapidly, ignore that particular sample. Something as simple as a compare instruction could be used. Compare the new sample to the previous sample, and if the difference is greater than some value you've set, don't transfer the value. Or only allow the value to be increased/decreased by a preset value. Sort of a "smoothing" effect...
Totally unrelated to you problem, but along the lines of this "smoothing", reminded me of a program I did a while ago. It may help explain this "smoothing" I'm describing...
Overview... An indexing machine that transferred product on nests through a hot stamping unit (actually 3, but let's keep it at 1 for this example). The main drive was a barrel-cam drive (AKA Camco), which provided an index, dwell, index, dwell, etc. motion with the motor running continuous, though the motor was stopped every cycle to allow a longer dwell time so the stamper could cycle (The stamping was performed during this dwell time). Therefore, the stamper's cycle time dictated the overall cycle time of the machine (parts per minute).
Since the nests were loaded by hand, the operator loading product would occasionally miss a nest, and when this empty nest reached the stamping station, the stamping cycle was inhibited. This caused the machine to speed up for that cycle, since the stamper didn't cycle.
This made it extremely difficult for an operator to load the nests, because the machine would speed up when the operator wasn't expecting it, causing them to miss even MORE nests as they got "out of rhythm" with the machine.
Simple solution was to stick a timer in the program to simulate the stamper's cycle time when the stamper wasn't cycling. BUT, the stamper's cycle time was adjusted quite often to achieve a "good" stamp as environmental conditions changed (or when they changed products).
I used the most recent "real" cycle time of the stamper as the preset of this timer, so it would "learn" any changes that were made. This worked fine, unless someone made a drastic change to the stamper's cycle time. Not a problem if the time INCREASED, as the machine would just slow down, but if the cycle time was DECREASED, the machine would speed up instantly, once again confusing the poor operator loading nests.
The final solution was to "smooth out" the transition to the faster speed.
Note: I used both the "real" stamper's cycle time AND the timer to inhibit the main indexer cycle. Both had to have finished before allowing an index. When the stamper's cycle time was shorter than the current preset of the timer, I only allowed the timer's preset to decrease by 0.1 second each cycle. This way it S-L-O-W-L-Y crept up to the new, faster speed. Since the speed of the machine increased so slowly, the operator was able to adjust to the speed easily. In fact, it increased so slowly that I think some operators didn't even realize that it was running faster!
For those who watched "I Love Lucy", think of the "Lucy at the chocolate factory" episode...
Hope this helps!
beerchug
-Eric