In this example, a program is presented in which HORST can be controlled by specifying external poses (on the PLC side). TCP coordinates in the form x, y, z, rx, ry, rz are transferred from the PLC to HORST.
1. PLC Program
The PLC program in which the external coordinates are transferred to CONTROL is described here. The program consists of a function block (FB "External_positioning").
The FB is assigned a data block (DB5) in which the local variables are defined. The FB has two input variables. The FB is executed via the Boolean input variable "start", which is controlled here via a simple switch with flag bit assignment. The TCP coordinates are transferred at the "Pose" input. The required data structure is predefined in a global DB:
The output "is_moving" indicates whether the transmitted pose is currently being approached (=true). The output "ready_for_data" indicates if a new pose can be transferred. This output can be used to regulate the data transfer between an external device (e.g., camera system) and CONTROL.
The internal function sequence is divided into 6 networks:
Network 1:
If the input variable #start has a positive edge, the local start variable #start_detected is set and the rest of the program is started.
Network 2:
This network checks whether the coordinates currently present at the #Pose input differ from the coordinates last transferred to CONTROL. If one of the coordinates differs, the local variable #new_pose is set - a new pose has been transferred to the FB.
Network 3:
In this network, the pose transferred externally to CONTROL is overwritten. To do this, #new_pose is first used to query whether a new pose has been transferred. If so, the pose is assigned to the predefined registers in CONTROL via a MOVE block. The pose is then transferred by setting the corresponding masks.
Network 4:
This checks whether the current pose has been transferred to CONTROL and whether the robot is moving (#is_moving). For this purpose, a Bool register is read out on CONTROL ("HORST_IN".Bool_Tegister[1]), which is set in horstFX after the pose has been read in and before the movement is started. If this status bit is set, #new_pose is reset and #is_moving is set. When the pose is reached, the status bit in horstFX is reset and the PLC is notified that the pose has been reached (#is_moving=false).
Network 5:
If a new pose has been transferred, a status bit is set here, which is read into horstFX and triggers the querying and starting of the new pose.
Network 6:
This checks whether the last pose passed was read in by horstFX (#new_pose=false). If this is the case, the output variable #ready_for_data is set. New poses can now be transferred from the PLC, even while the robot is still moving to the last transferred pose.
2. Textual program horstFX
The associated horstFX program is divided into two parts. In the first part, the status bits for communication with the PLC are assigned and initialized.
The second part, the actual program sequence, consists of an endless loop within which the transferred poses are read in and approached.
configuration();
{
config("robot.horstproto", "HorstS1Rev3Black");
config("tool", "No Tool");
config("scripttype", "textual");
config("version", "2020.10");
config("tcp.weight", "2.0");
}
//************Statusbits assignement and initialisation**************************************************
var bit_is_moving = 1; //Status bit for robot movement
var bit_new_pose = 2; //Status bit, whether new pose available
setBoolRegister(bit_is_moving,0);
setBoolRegister(bit_new_pose,0);
//*************Infinite loop in which the transferred poses are approached one after the other*************
while (true) {
if (getBoolRegister(bit_new_pose) == 1) { //will only be executed if new pose was passed by PLC
var pose = getNextPose(); //nextPose read and split
x = pose.x;
y = pose.y;
z = pose.z;
rx = pose.rx;
ry = pose.ry;
rz = pose.rz;
setBoolRegister(bit_new_pose,0); //Feedback to PLC that pose has been read in
setBoolRegister(bit_is_moving,1); //Feedback to PLC that robot is moving to pose
move({
'movetype': 'JOINT',
'poserelation': 'ABSOLUTE',
'coord' : 'cartesian_basis',
'speed.ratio': 0.75,
'targetpose.x': x,
'targetpose.y': y,
'targetpose.z': z,
'targetpose.rx': rx,
'targetpose.ry': ry,
'targetpose.rz': rz,
'blendradius.xyz':0.12,
'blendradius.orient':180
}, "Pose");
setBoolRegister(bit_is_moving,0); ////Feedback to PLC that pose has been reached
}
}
3. Download
The PLC program and the horstFX program can be downloaded here: