
LAMBDA DG-4 PLUS & DG-5 PLUS OPERATION MANUAL – REV. 3.05B (20131009)
47
you have used a BASIC language open statement to establish serial communications, the
subsequent 8 bit command values may be sent using a BASIC PRINT # command such as:
PRINT #1, CHR$(DATANUM);
… where #1 is the file number used in the open statement, and DATANUM is the value of
the command to be sent. Note that the CHR$ function allows the actual number to be sent
rather than the ASCII numbers of the characters that represent the number. Sending “;”
disables the automatic addition of characters such as a linefeed or a space.
For most commands sent over the serial interface, a simple form of protocol is provided that
can be used to determine the success or failure of commands and the speed at which
commands are transmitted.
In order to read the responses using BASIC, you can use a statement such as:
IF LOC(1) > 0 THEN SerialInput$ = INPUT$(1, #1)
LOC(1) > 0 indicates that bytes are waiting in the received data buffer. INPUT$(1, #1) reads
one byte from the buffer, which is stored as SerialInput$.
4.2.3
Serial Port Command Echo
In the serial mode, the Lambda DG-4 controller responds to each command by echoing the
command back to the host computer. This indicates that the command was received and will
be executed promptly. If the sent command is the same as the last command received, it will
not be echoed and the controller will take no action. The following subroutine could be used
to hold the computer in a loop until the command is properly echoed.
Listing 4-2. Command echo check routine.
COMMANDCHECK: IF LOC(1) > 0 THEN SerialInput$ = INPUT$(1, #1)
IF DATANUM = ASC(SerialInput$) THEN RETURN
GOTO
COMMANDCHECK
NOTE: The only serial command not echoed back by the Lambda DG-4 is the “Go On Line”
(238 decimal, EE hexadecimal) command.
4.2.4
Serial Port Command Completion Indicator
In the case of filter movement commands (0 through 32), the Lambda DG-4 will send back to
the host computer a byte with the value of 13 decimal (0D hexadecimal), which is an ASCII
CR (carriage return). Nearly the same subroutine can be used to hold the computer in a loop
until the carriage return (13) is received.
Listing 4-3. Command-completion check routine.
BUSYCHECK:
IF LOC(1) > 0 THEN SerialInput$ = INPUT$(1, #1)
IF ASC(SerialInput$)=13 THEN RETURN
GOTO
BUSYCHECK
4.2.5
Reading the Status of the Lambda DG-4
The Lambda DG-4 controller signals that it has completed commands received through its
serial port by sending a carriage return back. The following is an example of a QuickBasic
routine that could be used to monitor the status of the DG-4 (the example assumes that #1
has already been opened as the serial port to which the DG-4 is connected.