PDA

View Full Version : How to detect variable decrease moment?



CuriousOne
- 4th February 2014, 05:04
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:



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?

aerostar
- 4th February 2014, 07:01
Have a look at the PB manual

http://melabs.com/resources/pbpmanual/5_75-5_76.htm#572

While..Wend

Amoque
- 4th February 2014, 13:14
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.

aratti
- 4th February 2014, 15:56
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.

Acetronics2
- 4th February 2014, 16:20
@ 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

Demon
- 4th February 2014, 22:02
(nevermind)

Robert