Communication protocols
PROGRAMMING MANUAL
216
R
e
vi
si
o
n
1
.0
Examples
In these examples we assume this set-up:
•
A Trajexia system with a TJ2-MC64.
•
A slave PC, with node address 13.
•
A connection from the serial port of the TJ2-MC64 to the PC. The serial
port uses RS422 communication.
/i
/i
/i
/i
/i
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)
Example
Send
TS
(test) command to PC using
HLM_COMMAND
.
BASIC code
HLM_COMMAND(HLM_TEST,2,13)
Host Link
communication
•
From Host Link master to Host Link slave:
@13TSMCW151 TEST STRING2A*
•
From Host Link slave to Host Link master:
@13TSMCW151 TEST STRING2A*
Result
HLM_STATUS PORT(2) = 0
, which implies correct communication.
Example
Set PC in MON mode using
HLM_COMMAND
.
BASIC code
HLM_COMMAND(HLM_STWR,2,13,2)
Host Link
communication
•
From Host Link master to Host Link slave:
@13SC0250*
•
From Host Link slave to Host Link master:
@13SC0052*
Result
The PC runs in MON mode. Note that this is necessary for writing data
to the PC using
HLM_WRITE
.
Example
Reading PC model code using
HLM_COMMAND
(timeout).
BASIC code
HLM_TIMEOUT=500
' Destination address: VR(100)
HLM_COMMAND(HLM_MREAD,2,13,MC_VR,100)
Host Link
communication
•
From Host Link master to Host Link slave:
@13MM42*
•
From Host Link slave to Host Link master:
no response
Result
Because the master has not received a response from the PC,
HLM_STATUS PORT(2)
has value 256 (bit 8 is set) after 500 servo
cycles.