BNC 630 User Manual

Page 90

Advertising
background image

85

'----------- Make sure a 630 is attached to the serial port --------------
' If we send the 630 a control E character, it will respond with a control C. We use
' this feature to see if a 630 is attached. If a 630 cannot be found, wait until
' one is attached.
' User can abort the program at this point by pressing any key.

' When power is applied to the 630, it prints a menu to the serial port.
' We wish to disregard these characters, so flush them.

GOSUB FlushBuff1 ' Flush all received chars from buffer

' Tell the user to connect up a 630

PRINT "Connect the 630 to the serial port and power the 630"

ConnectLoop:
PRINT #1, CHR$(5); ' Print a control E to 630 (ASCII char 5)

' Wait for the 630 to give us some characters. When they arrive, put them into the
' string a$

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

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

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

' Did we get a control C (ASCII char 3) from the 630?

IF INSTR(a$, CHR$(3)) THEN GOTO GotSg100

GOTO ConnectLoop
GotSg100:

'----------- Switch the 630 to Burst mode --------------
' Send the following command string to the 630:
' A M6 F2 xxX F1 xxX F3 xxX F0
' These characters have the following meaning:

' A - Reset the 630 to Sinewave mode (ensures the state of 630)
' M6 - Go to Burst Mode
' F3 - Move cursor to field 3 (the burst frequency field)
' xxX - Enter a frequency of xx Hz (infrared carrier freq)
' F2 - Move cursor to field 2 (the burst duration field)
' xxX - Enter a duration of xx mS (burst on time)
' F4 - Move cursor to field 4 (the burst delay field)
' xxX - Enter a duration of xx mS (burst off time)
' F0 - Move cursor to field 0 (turns cursor off)

PRINT #1, "A M6 F3";
PRINT #1, CarrierFreq$; "X"; ' Send measured carrier freq
PRINT #1, "F2 ";
PRINT #1, OnTime$; "X"; ' Send burst on time
PRINT #1, "F4 ";
PRINT #1, OffTime$; "X"; ' Send burst off time
PRINT #1, "F0";

' The 630 will now trigger a single burst for each "t" char we sent it. After the
' 630 executes each "t" 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
' processing the last "t". The GetResponse1 subroutine has a time-out feature which will
' accomplish this purpose.

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

Advertising