B&K 4070A User Manual

Page 79

Advertising
background image

BK Precision 4070A User Manual Rev.2.2

74

'----------- Set a frequency and level on the 4070A --------------
' Send the following command string to the 4070A:
' A F1 18.432Z F2 0.0Z F0
' These characters have the following meaning:
' A - Reset the 4070A 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 4070A 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 4070A 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 4070A 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 4070A

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

GOSUB PromptWait ' Wait for 4070A to finish this command

GOSUB FlushBuff1 ' Flush all received chars from 4070A

' 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 4070A 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 4070A to a$

' The 4070A 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