This question is for JonnyMac or any one else
sam_sam_sam
Posts: 2,286
Here is the question let say that your using an ADC chip and you have voltage result
mVolts like let say 1,2 volts
And you what to see if that value stay the same for let say 2 minutes then exit the routine how would write or the value start going then you want it to stay in that routine
some thing like for inputs that you wrote a while back for me
cntr_S = cntr_S + 1 * Chg_S
IF (cntr_S = 6 ) THEN GOSUB resetData
or am I asking for the impossible and it can not be done that way
any thought on how I could do something along the same idea that would work
I know that I could do something like
GOSUB Get_Time
DEBUG HOME, HEX2 mins, ":", HEX2 secs
IF mVolts >120 and < 125 THEN EXIT
IF mins = $03 AND secs = $15 THEN EXIT
I have not try this but I have the feel that may this may not work the that I want it to work
LOOP
mVolts like let say 1,2 volts
And you what to see if that value stay the same for let say 2 minutes then exit the routine how would write or the value start going then you want it to stay in that routine
some thing like for inputs that you wrote a while back for me
cntr_S = cntr_S + 1 * Chg_S
IF (cntr_S = 6 ) THEN GOSUB resetData
or am I asking for the impossible and it can not be done that way
any thought on how I could do something along the same idea that would work
I know that I could do something like
GOSUB Get_Time
DEBUG HOME, HEX2 mins, ":", HEX2 secs
IF mVolts >120 and < 125 THEN EXIT
IF mins = $03 AND secs = $15 THEN EXIT
I have not try this but I have the feel that may this may not work the that I want it to work
LOOP
Comments
Place the current value in a currentValue global variable.
Get the currentTime or set a time counter
Start timer loop
Get the next reading and put it into newValue
compare currentValue to newValue
[ if the values are equal keep looping - update any time counters if needed]
[ if the values are not equal place the new value in current value and exist the loop. ]
Has time expired? if so exit, else continue
I don't know Basic, but if you can make an array, you could make a histogram.
Make an integer array the size of your ADC value, initialize it to zeroes, then for a few minutes, increment the array contents where ADC values equal the indexes:
repeat i from 1 to 1000
array[adc_value]++
Then display the array. You should see a peak at your expected value, with maybe a scatterring of entries on either side of your value.