No AND/OR command! How-To decode DTMF board ???
Posted: Wed Mar 13, 2013 5:29 pm
Hi Daniel,
I just noticed that there is no AND or OR command in Control BASIC.
That is an important part of a conditional branch in the BASIC language.
I wrote this code for the ARMweb to create a <send$> of DTMF tones decoded.
How would you write this in Control BASIC ???
I have another 5-bit RF remote 4-ch. button input to the controller.
So there are 10-bits in a row I want to examine for processing.
Thats 5-bits for the DTMF board and 5-bits for the 4-ch. remote keys.
The 5th bit on each is VT(data valid).
The other 4-bits are a nibble for the DTMF board.
Your help on this is greatly appreciated Daniel.
Robert
.
I just noticed that there is no AND or OR command in Control BASIC.
That is an important part of a conditional branch in the BASIC language.
I wrote this code for the ARMweb to create a <send$> of DTMF tones decoded.
Code: Select all
' Read DTMF tones and create a SEND$ for processing on the ARMweb controller
'===== SETUP =================
INPUT (9) ' Set pin 9 as an input FOR DTMF DETECTED (data valid)
INPUT (10) ' Q4 nibble output
INPUT (11) ' Q3 " "
INPUT (12) ' Q2 " "
INPUT (13) ' Q1 " "
'===== MAIN LOOP =============
WHILE 1 ' Main program loop...
'Goto label..."DTMFDetected:"
DTMFDetected:
IF IN(9) AND 1 THEN ' wait for DTMF valid "1" to decode digits Q4 Q3 Q2 Q1
IF IN(10)=0 AND IN(11)=0 AND IN(12)=0 AND IN(13)<>0 THEN DIGIT$="1"
IF IN(10)=0 AND IN(11)=0 AND IN(12)<>0 AND IN(13)=0 THEN DIGIT$="2"
IF IN(10)=0 AND IN(11)=0 AND IN(12)<>0 AND IN(13)<>0 THEN DIGIT$="3"
IF IN(10)=0 AND IN(11)<>0 AND IN(12)=0 AND IN(13)=0 THEN DIGIT$="4"
IF IN(10)=0 AND IN(11)<>0 AND IN(12)=0 AND IN(13)<>0 THEN DIGIT$="5"
IF IN(10)=0 AND IN(11)<>0 AND IN(12)<>0 AND IN(13)=0 THEN DIGIT$="6"
IF IN(10)=0 AND IN(11)<>0 AND IN(12)<>0 AND IN(13)<>0 THEN DIGIT$="7"
IF IN(10)<>0 AND IN(11)=0 AND IN(12)=0 AND IN(13)=0 THEN DIGIT$="8"
IF IN(10)<>0 AND IN(11)=0 AND IN(12)=0 AND IN(13)<>0 THEN DIGIT$="9"
IF IN(10)<>0 AND IN(11)=0 AND IN(12)<>0 AND IN(13)=0 THEN DIGIT$="0"
IF IN(10)<>0 AND IN(11)=0 AND IN(12)<>0 AND IN(13)<>0 THEN DIGIT$="*"
IF IN(10)<>0 AND IN(11)<>0 AND IN(12)=0 AND IN(13)=0 THEN DIGIT$="#"
IF IN(10)<>0 AND IN(11)<>0 AND IN(12)=0 AND IN(13)<>0 THEN DIGIT$="A"
IF IN(10)<>0 AND IN(11)<>0 AND IN(12)<>0 AND IN(13)=0 THEN DIGIT$="B"
IF IN(10)<>0 AND IN(11)<>0 AND IN(12)<>0 AND IN(13)<>0 THEN DIGIT$="C"
IF IN(10)=0 AND IN(11)=0 AND IN(12)=0 AND IN(13)=0 THEN DIGIT$="D"
WHILE (IN(9) AND 1) 'wait for data valid release
LOOP
START = TIMER ' start timer
WHILE (TIMER-START < 3000000) ' wait for 3 seconds
IF IN(9) AND 1 THEN EXIT ' if new valid data then exit loop
LOOP
IF TIMER-START < 3000000 THEN ' if valid data before 3 seconds, process...
WORD$ = WORD$ + DIGIT$ ' add digit to word and...
GOTO DTMFDetected ' go back to label "DTMFDetected:" above and get new digit
ENDIF
WORD$ = WORD$ + DIGIT$ ' add digit to word after timeout...
SEND$ = WORD$ ' copy word to send string...
WORD$ = "" ' clear word string...
'Send "SEND$" word data to PC...
'...(put code here)...
ENDIF
LOOP ' end of program, loop back to top
I have another 5-bit RF remote 4-ch. button input to the controller.
So there are 10-bits in a row I want to examine for processing.
Thats 5-bits for the DTMF board and 5-bits for the 4-ch. remote keys.
The 5th bit on each is VT(data valid).
The other 4-bits are a nibble for the DTMF board.
Your help on this is greatly appreciated Daniel.
Robert
.