19 Maintenance of robot program
TrRd (reading tracking data)
[Function]
Read position data for tracking operation, encoder data and so on from the data buffer.
[Format]
TrRd <Position data> [ , <Encoder data>] [ , [<Model number>] [ , [<Buffer number>] [ , <Encoder number>] ] ] ]
[Term]
<Position data> (cannot be omitted):
Specify a variable that contains workpiece positions read from the buffer.
<Encoder data> (can be omitted):
Specify a variable that contains encoder values read from the buffer.
<Model number> (can be omitted):
Specify a variable that contains model numbers read from the buffer.
<Buffer number> (can be omitted):
Specify a number of a buffer from which data is read.
1 is set if the argument is omitted.
Setting range: 1 to 4(The first argument of parameter [TRBUF])
<Encoder number> (can be omitted):
Specify a variable that contains values of external encoder numbers read from the buffer.
[Example]
(1) Tracking operation program
1 TrBase P0 ' Specify the workpiece coordinate origin at the teaching position.
2 TrRd P1,M1,MK ' Read the workpiece position data from the data buffer.
3 Trk On,P1,M1 ' Start tracking of a workpiece whose measured position is P1 and encoder value
at the time of measurement is M1.
4 Mvs P2 ' Setting the current position of P1 as P1c, make the robot operate while following
workpieces with the target position of P1c*P_Zero/P0*PW2.
5 HClose 1 ' Close hand 1.
6 Trk Off ' End the tracking operation.
(2) Sensor data reception program
1 *LOOP
2 If M_In(8)=0 Then GoTo *LOOP ' Jump to *LOOP if input signal No. 8, to which a
photoelectronic sensor is connected, is OFF.
3 M1#=M_Enc(1) ' Acquire data of encoder number 1 at the time when input
signal No. 8 is turned on and store it in M1#.
4 TrWrt P1, M1#,MK ' Write workpiece position data P1, encoder value M1# at the
time an image is acquired and model number MK in the buffer.
[Explanation]
Read the workpiece position (robot coordinates), encoder value, model number and encoder number
stored by the TrWrt instruction from the specified buffer.
If the TrRd instruction is executed when no data is stored in the specified buffer, Error 2540(There is no
read data) occurs.
MELFA-BASIC V Instructions 19-93