RS-232C Communications
Section 6-2
6-2 RS-232C Communications
This section describes the communications procedure when using the NT20-
ST128 (RS-232C), and program flow using examples in BASIC.
6-2-1
Communications
Procedure
The Host and NT20 communicate according to the following procedure.
1,2,3...
1.
The RS-232C circuit must be opened (i.e., communications enabled) before communications can start.
2.
Commands are used to control the PT and to receive notification from the
NT20.
3.
Close the RS-232C circuit again after communications have been completed.
Host program
RS-232C circuit
NT20 operation
Open circuit
OPEN command
Send instruction
PRINT # command
Receive instruction
Open status
Send instruction
LINE INPUT # command
CLOSE command
Send instruction
Close circuit
After a circuit has been opened, it can be used until it is closed again.
OPEN: Opens the RS-232C circuit. The Host communications conditions are also set.
Refer to 3-5-7 Setting RS–232C Communications Conditions
(NT20-ST128) on page 99.
PRINT#: Sends an instruction via the RS-232C circuit to the NT20.
LINE INPUT#: Receives a command from the NT20. [LINE INPUT] is used when receiving input delimited by commas (,) or double quotation marks (").
CLOSE: Closes the RS-232C circuit.
Refer to the Host's BASIC Manual for more details about the commands.
Operation by Operating
Commands
The operating commands display monitored data from the production line and messages to the factory workers. They are also used for NT20 control and management.
The communications flow between the Host and NT20 differs according to the following three cases:
Message from Host to
NT20
Host program NT20 operation
Message operating command
Message to PT Process message
Enquiry from Host to NT20
Host program NT20 operation
Enquiry operating command
Enquiry Receive command
Send response command
Receive command
Response operating command
213
RS-232C Communications
Section 6-2
Notification of Operation at NT20 to the Host
Operation by Terminal
Commands
Host program NT20 operation
Notification operating command
Receive notification Send notification command
The terminal commands allow the NT20 to be used as a terminal of the Host to display text and graphics independently of the screens stored in the NT20.
The Host sends a command and the NT20 processes the message. The
NT20 does not send back a response to the Host.
Host program NT20 operation
Terminal command
Message to PT Process message
6-2-2 Precautions
Commands
Some important points to consider when using commands are listed below.
If a personal computer is used as the host and a high-level language, such as
BASIC or C, is used for programming, commands are specified with ASCII text strings.
In the descriptions in this section, parameters are given in lowercase letters.
When specifying commands, specify any text given in uppercase letters as is and replace lowercase letters with ASCII text strings to specify the numeric values of the parameters (BCD or hexadecimal) or the text strings for parameters. Any text given in square brackets [ ], however, represents one control code, such as ESC or CR.
In the descriptions of commands, “4-digit BCD” indicates an ASCII text string of a 4-digit BCD value and “4-digit hexadecimal” indicates an ASCII text string of a 4-digit hexadecimal value. Do not specify BCD or hexadecimal values directly. Always use ASCII text strings to represent them.
Example
The command format for the Four-digit Numeral Memory Table Write command is as follows:
[ESC] C d
1 d
2 d
3 n
1 n
2 n
3 n
4
1B 43 * * * * * * * * * * * * * *
Assuming that the following parameters were to be specified, the text string given below would actually be sent.
d
1
d
2
d
3
: 014 (3-digit hexadecimal) n
1
n
2
n
3
n
4
: 1234 (4-digit BCD)
[ESC] C
0 1 4 1 2 3 4
1B 43 30 31 34 31 32 33 34
Command Length
Note
In the descriptions of commands and responses, “**” indicates the specified characters in ASCII (2-digit hexadecimal).
If a mistake during command specification results in a command being too long, the correct length of the command is executed and the remainder is ignored.
A timeout error results if a mistake during command specification results in a command being too short.
214
RS-232C Communications
Interval between
Transmitted Commands
Controlling PT Status with
Operating Commands
Coordinate Specification with the Terminal
Commands
Error Display
Section 6-2
As a small number of bytes is transmitted by the Host, the interval between transmissions should not exceed 5 seconds if a command is divided up for transmission. A timeout error occurs if the interval between transmissions exceeds 5 seconds.
When commands are sent too frequently, a buffer overflow error may occur if the NT20 cannot keep up with the command processing.
In order to prevent buffer overflow, use flow control.
Control of the NT20 status by the operating commands is restricted by the
NT20 memory switch settings as listed below.
Operating command Restriction from memory switch setting
Buzzer control command [ESC] T Effective when “buzzer turned on”
The entire command is ignored if any point specified at coordinates X, Y with the Terminal commands lies outside the screen.
If the “automatic reset after communications” memory switch of the NT20 is set to ON, no message is displayed when a communications error occurs.
However, time-out errors are displayed.
215