Ryan
What you're looking for is a derivative function. What you can do is something like this
Code:
LastADC var word ' previous error
CurrADC var word ' current error
Threshold con 1 ' can be more if you want
loop:
gosub ReadADC
Error = CurrADC-LastADC
if Error < 0 then Error = -Error ' make absolute error
if Error > Threshold then
High Output
pause 1000 ' wait 1 second
Low Output
endif
LastAdc = CurrAdc
goto loop
This will more or less achieve what you want to. However, this is pure untested code. Use at your own risk.
Jerson
Bookmarks