How to detect variable decrease moment?
Hello.
I'm doing a task, where variable presents certain data (changes every second). I have to capture a moment, when it starts to decrease.
My code is here:
Code:
COMPARER:
IF OLD>NEW THEN GOTO OTHER TASK
PAUSE 1
OLD=NEW
GOTO COMPARER
But isn't there some kind of statement, to make this shorter?
Re: How to detect variable decrease moment?
Re: How to detect variable decrease moment?
You did not specify if you mean "shorter" as in with fewer lines of code or "shorter" as in faster...
Here is a thread you may find interesting: http://www.picbasic.co.uk/forum/showthread.php?t=5335
Also, you may look at the Pauseus statement.
Re: How to detect variable decrease moment?
Code:
Code:
COMPARER:
IF OLD>NEW THEN GOTO OTHER TASK
PAUSE 1
OLD=NEW
GOTO COMPARER
If you loop inside the snippet how do you feed the variable "NEW" with the updated value?
Al.
Re: How to detect variable decrease moment?
@ first ... your processor will be able to see a change only AFTER data have been collected ( La Pallice, french philosopher ). ;)
from that, if you collect data once a second ( as written @ post #1 ) no need to scan value @ each millisecond ...
just place your test ONCE after data collection ( ADC conversion or serial value received ) and you won't loose any time !!!
no need to have a watching loop nor ...:rolleyes:
Alain
Re: How to detect variable decrease moment?