Communication protocols
PROGRAMMING MANUAL
162
Revi
si
on 3.0
Timeout
The timeout mechanism is implemented to prevent that the BASIC task
pauses for a long time due to bad or no communication. The
HLM_TIMEOUT
parameter specifies the timeout period. This period is the
maximum time the program task waits after it has sent the command to
receive a response.
If the timeout period elapses, the
HLM_STATUS
contains the status of the
command, and the BASIC task continues.
The
HLM_TIMEOUT
parameter specifies the timeout period for all
commands and for all ports.
Status
The
HLM_STATUS
parameter contains the status of the last Host Link
master command sent to the specified port. The parameter indicates the
status for the
HLM_READ
,
HLM_WRITE
and
HLM_COMMAND
commands. The status bits are:
/i
The HLM_STATUS has value 0 when no problems occurred. In case of a
non-zero value you need to program an appropriate action such as a retry or
emergency stop in the user BASIC program. Each port has an
HLM_STATUS parameter. You need the
PORT
modifier to specify the port.
Examples
In these examples we assume this set-up:
•
A Trajexia system with a TJ1-MC__.
•
A slave PC, with node address 13.
•
A connection from the serial port of the TJ1-MC__ to the PC. The serial
port uses RS422 communication.
/i
/i
Bit
Name Description
0-7
End code
The end code is:
•
the end code defined by the Host Link slave, when a prob-
lem occurred in the data string of the sent command, or
•
an end code defined by the Host Link master, when a prob-
lem occurred in the data string of the received response.
8
Timeout error
A timeout error occurs if no response is received within the time-
out period. This indicates that the communication is lost.
9
Command not
recognised
This status indicates that the slave did not recognise the com-
mand and has returned an IC response.
Example
Reading data from the PC using
HLM_READ
.
BASIC code
' Set up Host Link master for port 2
SETCOM(9600,7,2,2,2,6)
' Source address: CIO/IR 002
' Amount of data: 2 words
' Destination address: VR(0)
HLM_READ(2,13,PLC_IR,2,2,MC_VR,0)
Host Link
communication
•
From Host Link master to Host Link slave:
@13RR0002000242*
•
From Host Link slave to Host Link master:
@13RR000101010241*
Result
•
VR address = 0: value = 257.0000
•
VR address = 1: value = 258.0000
Example
Writing data to the PC using
HLM_WRITE
.
BASIC code
' Source address: TABLE(18)
' Amount of data: 2 words
' Destination address: LR 014
TABLE(18,$0701,$0702)
HLM_WRITE(2,13,PLC_LR,14,2,MC_TABLE,18)
Host Link
communication
•
From Host Link master to Host Link slave:
@13WL0014070107025F*
•
From Host Link slave to Host Link master:
@13WL0059*
Result
•
LR address = 0: value = 701 (hex)
•
LR address = 1: value = 702 (hex)
I52E-EN-03.book Seite 162 Freitag, 29. Juni 2007 11:55 11