Communication protocols
PROGRAMMING MANUAL
165
Revi
si
on 3.0
Set up
You need the
SETCOM
command to set up the serial port of the TJ1-MC__
for the Host Link Slave protocol. Set the command as follows:
SETCOM(baudrate, data_bits, stop_bits, parity, port, 5)
After you have set this command, the TJ1-MC__ responds to Host Link
commands from the master with the specified node number. You can set this
node number with the
HLS_NODE
parameter.
Example
In this example we assume this set-up:
•
A Trajexia system with a TJ1-MC__.
•
An NS8 programmable terminal.
•
A connection from the serial port of the TJ1-MC__ to the programmable
terminal. The serial port uses RS232C communication.
/i
4.3.3
User-defined protocol
You can implement a user-defined communication protocol with these
commands:
/i
Example
Assume a set-up with:
•
A Trajexia system with a TJ1-MC__.
•
An OMRON Vision system F500.
•
A connection from the serial port of the TJ1-MC__ to the F500. The
serial port uses RS232 (port 1) communication.
This program sends a Vision command through the serial port, reads the
response from the Vision system, writes it to VR variables and prints the
results in the Terminal window of Trajexia Tools.
A4
Aborted due to
format error in
transmission
data
The command format did not
match the number of bytes in the
second or later frame.
Correct the command
data and transfer the
command again.
A5
Aborted due to
entry number
data error in
transmission
data
There was an entry number data
error in the second or later frame
or a data length error.
Correct the command
data and transfer the
command again.
A8
Aborted due to
frame length
error in trans-
mission data
The length of the second or later
frames exceeded the maximum
of 128 bytes.
Correct the command
data and transfer the
command again.
Example
Configuration of the Host Link slave.
End code
Description
Probable cause
Solution
BASIC code
' Define Host Link slave node
HLS_NODE = 15
' Define Host Link slave model code
HLS_MODEL = $FA
' Set up Host Link slave for port 1
SETCOM(9600,7,2,2,1,5)
Result
The TJ1-MC__ can communicate with the programmable terminal.
BASIC command
Description
SETCOM
SETCOM
configures the serial communication port, and it enables
the Host Link protocols.
GET
GET
assigns the ASCII code of a received character to a variable.
INPUT
INPUT
assigns numerical input string values to the specified varia-
bles.
KEY
KEY
returns
TRUE
or
FALSE
, when a character has been received
or has not been received.
LINPUT
LINPUT
assigns the ASCII code of received characters to an array
of variables.
outputs a series of characters to a serial output device.
I52E-EN-03.book Seite 165 Freitag, 29. Juni 2007 11:55 11