Count Execution Question? Solved...
smpl
Posts: 19
Hello all. I am a newbe, new to microcontrollers and this is my first post.
Question: Doesn't the Count command need to finish the count duration before executing the next command?
The debug screen updates every 1/4 of a second using this code.
Test Code:
' {$STAMP BS2p}
' {$PBASIC 2.5}
' {$PORT COM29}
PAUSE 100
SENS CON 0
RPM VAR Word
FREQ VAR Word
SECS VAR Word
DEBUG CLS,"Pulses = ",CR,"RPM = ",CR,"Seconds = "
DO
COUNT SENS, 1000, FREQ
RPM = (FREQ*60)
SECS = (SECS + 1)
DEBUG CRSRXY,9,0, DEC FREQ,CLREOL
DEBUG CRSRXY,6,1,DEC RPM,CLREOL
DEBUG CRSRXY,10,2, DEC SECS,CLREOL
LOOP
Thanks
Question: Doesn't the Count command need to finish the count duration before executing the next command?
The debug screen updates every 1/4 of a second using this code.
Test Code:
' {$STAMP BS2p}
' {$PBASIC 2.5}
' {$PORT COM29}
PAUSE 100
SENS CON 0
RPM VAR Word
FREQ VAR Word
SECS VAR Word
DEBUG CLS,"Pulses = ",CR,"RPM = ",CR,"Seconds = "
DO
COUNT SENS, 1000, FREQ
RPM = (FREQ*60)
SECS = (SECS + 1)
DEBUG CRSRXY,9,0, DEC FREQ,CLREOL
DEBUG CRSRXY,6,1,DEC RPM,CLREOL
DEBUG CRSRXY,10,2, DEC SECS,CLREOL
LOOP
Thanks
Comments
Modified Code:
' {$STAMP BS2p}
' {$PBASIC 2.5}
' {$PORT COM29}
PAUSE 100
SENS CON 0
RPM VAR Word
FREQ VAR Word
SECS VAR Word
#SELECT $STAMP
#CASE BS2, BS2E
Offset CON $100 ' / 1
#CASE BS2SX
Offset CON $280 ' / 0.400
#CASE BS2P, BS2PX
Offset CON $37B ' / 0.287
#CASE BS2PE
Offset CON $163 ' / 0.720
#ENDSELECT
DEBUG CLS,"Pulses = ",CR,"RPM = ",CR,"Seconds = "
DO
COUNT SENS, (1000 */ Offset), FREQ
RPM = (FREQ*60)
SECS = (SECS + 1)
DEBUG CRSRXY,9,0, DEC FREQ,CLREOL
DEBUG CRSRXY,6,1,DEC RPM,CLREOL
DEBUG CRSRXY,10,2, DEC SECS,CLREOL
LOOP
TIP: When your trouble shooting, sometimes you have to walk away from the problem for a while and then when you return to it, the solution stares you straight in the face. I live by this, but in this situation I let it consume me for 2 days. NEED MORE BEER......LOL