BNC 630 User Manual

Page 85

Advertising
background image

80

'----------- Set a frequency and level on the 630 --------------
' Send the following command string to the 630:
' A F1 18.432Z F2 0.0Z F0
' These characters have the following meaning:
' A - Reset the 630 to Sinewave mode
' F1 - Move cursor to field 1 (the frequency field)
' 18.432Z - Enter a frequency of 18.432 MHz
' F2 - Move cursor to field 2 (the level field)
' 0.0Z - Enter a level of 0.0 dBm
' F0 - Move cursor to field 0 (turns cursor off)

PRINT #1, "A F1 18.432Z F2 0.0Z F0";

' After the 630 executes each command, it will return a prompt character (">"). We wish
' to wait until after all prompts have
' come in, since that's when the 630 has finished executing the last command. The
' GetResponse1 subroutine has a time-out feature which will accomplish this purpose.

GOSUB GetResponse1 ' Wait for and get response from 630 to a$

' Let the user know what's going on
CLS
PRINT "CW mode selected. Frequency and Level have been set."
PRINT : PRINT
PRINT "Press any key to go to DTMF Detection mode"

' Wait for the user to press a key before we switch to a new mode.
CALL Pause

'----------- Switch to DTMF Detection mode --------------
' This example illustrates how to parse information from the 630

PRINT #1, "M9"; ' Command the 630 to go to DTMF Detection mode

GOSUB PromptWait ' Wait for 630 to finish this command

GOSUB FlushBuff1 ' Flush all received chars from 630

' Let the user know what's going on
CLS
PRINT : PRINT
PRINT "Now in DTMF Detection mode. All DTMF detections will be printed."
PRINT

' When the 630 detects a DTMF digit, it will print the following text
' to the terminal port: CR,LF,"DTMF: 7"

DTMFLoop:
GOSUB GetResponse1 ' Wait for and get response from 630 to a$

' The 630 prints a semicolon (:) character whenever it is reporting data.
' The data follows immediately after the semicolon.

IF INSTR(a$, ":") THEN
a = INSTR(a$, ":") + 1 ' Get the data that follows the ":" character
a$ = MID$(a$, a, 2) ' (Strip off everything else)
PRINT "Detected DTMF digit is: "; a$
END IF

' Allow the user to exit the program by pressing a key.

IF INKEY$ <> "" THEN SYSTEM ' Exit on first terminal keypress

GOTO DTMFLoop ' Otherwise keep looking for more DTMF detections

Advertising