21
SERIAL COMMUNICATIONS
SERIAL PROGRAM-MODE COMMANDS
ESP — Enter Serial Programming
This command causes the counter to enter the serial pro-
gramming mode. The host must send this command before
the unit will respond to serial programming commands (WPI,
RPI, and XSP). The counter displays the message “LOAD-
ING PROGRAM” when it receives a valid ESP command.
The counter and preset values are saved and the outputs
dropout as when entering the keyboard programming mode.
If the counter is in the serial programming mode and power
is removed, it will enter the keyboard programming mode
when power is re-applied.
EXAMPLE: >00ESP48(cr) Causes unit 00 to enter the serial
programming mode.
XSP — Exit Serial Programming
This command causes the counter to store any new program
data and exit the serial programming mode. It is similar to
exiting the keyboard programming mode.
EXAMPLE: >00XSP5B(cr) Causes unit 00 to exit serial
programming.
WPI(nnn - nnnnnnnn) — Write Program Item
This command allows a host computer to remotely program
an Ambassador unit. The unit must be in the serial program-
ming mode (ESP command). The host must send the WPI
command followed by the two to four digit edit menu number
of the desired function. A one to six digit data value is required
with some edit menus (see diagram on pages 22 and 23 for
edit menu item numbers).
EXAMPLE: >00WPI02360000DB(cr) Sets the rate scaler to
60.000 on unit 00.
RPI(nn - nnn) — Read Program Item
This command allows a host computer to determine the
programming of an Ambassador unit. The unit must be in the
serial programming mode (ESP command). The host must
send the RPI command followed by a two or three digit
number representing the desired sub-menu (see diagram on
pages 22 and 23 for sub-menu numbers). The counter
responds by transmitting a number representing the current
option selected for a sub-menu.
EXAMPLE COMMAND: >00RPI20AD(cr) Read input 1
selection.
EXAMPLE RESPONSE: A200D3(cr) Input 1 is disabled.
SAMPLE COMMUNICATIONS PROGRAM
The following BASIC program can be used to demonstrate
the serial communications capability of the Ambassador
controls. The program requires the user to enter an Ambas-
sador command with the correct unit ID# and format (ex-
ample: 00WP1123456). The program will calculate the
checksum and include it in the command string along with the
preceding “>” character. The command string will then be
printed to the screen and sent to the Ambassador unit
(example: >00WP11234566E). The program then prints the
Ambassador response to the screen (example: A).
Note: This sample program is intended for illustration pur-
poses only and is not guaranteed to work with all computers
and BASIC compilers or interpreters.
100 REM **** INITIALIZE AND INPUT *****
110 DEFINT A - Z
120 DEF SEG = &H40
130 CB = PEEK(1) * &H100 + PEEK(0)
135 DEF SEG
140 MSR = CB + 6
150 LSR = CB + 5
160 MCR = CB + 4
170 RTSON = 8 + 2 + 1 : RTSOFF = 8 + 1
180 OPEN “COM1:19200,N,8,1,RS” AS #1
190 ON TIMER(1) GOSUB 450
200 INPUT “ENTER COMMAND >”, A$
210 REM ***** CALCULATE CHECKSUM *****
220 CS = 0
230 R$ = “”
240 FOR X = 1 TO LEN(A$)
250 CS = CS + ASC(MID$(A$, X, 1))
260 NEXT X
270 CS = CS AND 255
280 CS$ = HEX$(CS)
290 IF CS < 16 THEN CS$ = “0” + CS$
300 T$ = “>” + A$ + CS$ : PRINT T$
310 REM ***** RTS CONTROL AND SEND *****
320 OUT MCR, RTSON
330 PRINT #1, T$
340 IF INP(LSR) <> &H60 THEN 340
350 OUT MCR, RTSOFF
360 REM ********* GET RESPONSE *********
370 TIMER ON
380 IF LOC(1) = 0 THEN 380
390 R$ = R$ + INPUT$(LOC(1), #1)
400 TIMER OFF
410 IF RIGHT$(R$, 1) <> CHR$(13) THEN 370
420 PRINT R$
430 GOTO 200
440 REM ***** NO RESPONSE ROUTINE ******
450 PRINT “NO RESPONSE” : PRINT
460 TIMER OFF : RETURN 200