Omron TJ2-MC64 - PROGRAMMING Programming Manual page 226

Hide thumbs Also See for TJ2-MC64 - PROGRAMMING:
Table of Contents

Advertisement

Communication protocols
4.3.4
User-defined protocol
You can implement a user-defined communication protocol with these
commands:
/i
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.
PRINT
PRINT outputs a series of characters to a serial output device.
Example
Assume a set-up with:
A Trajexia system with a TJ2-MC64.
An OMRON Vision system F500.
A connection from the serial port of the TJ2-MC64 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.
' In the STARTUP program
' Setting RS232 port for the vision system
SETCOM(38400,8,1,0,1,0)
' In the application program
loop:
' Trigger, rising edge in virtual system
WAIT UNTIL IN(30)=0
PROGRAMMING MANUAL
WAIT UNTIL IN(30)=1
' Clear screen
PRINT CHR(27);"[2J"
' Clear buffer
GOSUB clear_buffer
' Send command to the serial port according to VR(10)
IF vision_command=v_measure THEN
PRINT #1, "M"
PRINT ">> M"
ELSEIF vision_command=v_date THEN
PRINT #1, "DATE"
PRINT ">> DATE"
ELSEIF vision_command=v_scene THEN
PRINT #1,"SCENE ";scene_n
PRINT ">> SCENE"
ENDIF
'Check response
GOSUB read_buffer
GOTO loop
read buffer:
count=0
resp_status=0
k=-1
TICKS=5000
REPEAT
IF KEY#1 THEN
count=count+1
GET#1, k
'PRINT k;count
TABLE(count,k)
'PRINT count
ENDIF
UNTIL TICKS<0 'OR k=13
220

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Tj1-prtTj1-drtTj1-cortTj1-mlGrt1-ml2Tj1-fl02

Table of Contents