This article describes an example (programmed in TIA Portal 16, programming language LD) in which HORST is initialized automatically by the PLC. Any program stored on the control cabinet is then started
1. Program structure
The detailed description of the horstControl Profinet interface (register assignment, etc.) is described in Profinet communication.
The program is divided into two function blocks (FB). Each FB is assigned a data block (DB3 or DB4) in which the local variables for control within the networks of the FB are defined.
FB2 "Initialize_Axes" controls the automated initialization of all axes from the PLC. The second FB "Program_load_and_start" is executed as soon as the initialization is completed. For this purpose, the output variable "#done" of FB "Initialize_Axes" is set as the start variable for FB "Program_load_and_start". In the FB "Program_load_and_start", the program stored on horstCONTROL with the corresponding name is loaded and executed. The modular structure of the overall program into two individual function blocks makes it possible to implement each FB in other program sequences by adapting the inputs and outputs.
1.1 Functionblock "Initialize_Axes"
In principle, two options are implemented for PLC-controlled initialisation.
In the first variant, a time is transferred for the initialisation within which all axes are automatically initialised. For more details, see Profinet input data. The disadvantage of this variant is that the robot performs an undefined movement, which can lead to collisions with interfering contours.
In the second variant, a defined angle is specified for initialisation for each axis. The advantage of this variant is that the robot can be initialised to a defined position if the start position (from which initialisation is performed) is known. To ensure this, the robot should be moved to a defined home position at the end of each programme. It should be noted that for safe initialisation, the initialisation angle should not fall below a minimum value and that the initialisation angles are subject to tolerances. More detailed information can be found here: Profinet input data (Initialisation).
In this example, all axes are initialised via a defined angle. The angle is transferred via the input "angle_to_Initialize". The FB is started by setting the local, Boolean input variable "start", which is controlled here by a flag bit.
Done" and "busy" are defined as output variables. If the parameter "busy" is set (=true), the initialisation is being executed. As soon as "done" is set, the initialisation is completed. This output can be used to control any other FB that is to be executed after initialisation.
The internal function sequence is divided into 6 networks:
Network 1:
In this network, the status bit #done is set and directly reset after the initialization (network 7).
Network 2:
When the FB is started (positive edge #start), all internal and external variables are reset to the default values and the status bits #busy and #start_detected are set.
Network 3 & 4:
In these networks, pop-ups are recognised and acknowledged. Each pop-up can be acknowledged with different options by setting the corresponding bit. The assigned screen pop IDs and which options are available for which screen pop can be viewed here: Documentation pop-up windows.
When the robot is switched on for the first time (without changing the operating mode), the following pop-up with the ID404 always becomes active:
The ID 404 is assigned to this pop-up. In network 3, the pop-up ID is recognized by querying the bit "HORST_IN".Pop_up and confirmed with "Yes" by setting "HORST_OUT".Pop_Up_Confirmation.Option_1.
Next, the following pop-up with the ID350 is displayed:
This pop-up is also acknowledged with Option_1 (OK) in network 4, as shown in the circuit diagram. Before this, the switch "PopUp-ID>7" is used to query whether all PopUpConfirmation commands from the previous network have been reseted (the PopUp-IDs 1-7 indicate which PopUpConfirmation bit is currently set, see Profinet input data).
Network 5:
Here it is queried whether all pop-ups have been acknowledged and the robot is ready for initialization.
Netzwerk 6:
After all pop-ups have been acknowledged (status bit #PopUp_done set), the initialisation can be started. For this purpose, the initialisation angle is transferred to the corresponding internal float registers via a MOVE block. A float register is reserved for each axis. Thus, an individual initialization angle can be transferred for each axis.
Network 7:
Once the initialisation angles have been transmitted, initialisation is started by setting the corresponding internal bits. Here all axes are initialised one after the other. Before this it is queried via Initialization_Call_Interface_Enabled whether horstFX is ready to start initialisation (brakes open, interface loaded, etc.).
If the last axis (here axis 6) is initialized, the status bits #start_detected and #busy are reset and #done is set.
Initialisation is now complete and the second FB "Program_load_and_start" is started.
1.2. Functionblock "Program_load_and_start"
The program name is passed to the FB as an input string (local input variable #program_name). The program with the corresponding name must be stored locally on the control cabinet under ""/home/fruitcore/fruitcore/save/". is_runnning" and "done" are defined as output variables. "is_running" indicates whether the loaded program is currently being executed; "done" indicates the termination of the loaded program.
The internal function sequence is divided into 5 networks:
Network 1:
In this network, the setting of the input variable #start is detected and the local variable for starting the program sequence #start_detected is set.
Network 2:
After #start_detected is set, a predefined function block converts the passed string (#program_name) into an array of chars and then writes it to the corresponding internal registers ("Switch_Activity.Current_Program). The following MOVE block writes the integer value 1 to the "Switch-Activity_Number" register to switch to the program view (cf. Documentation views horstFX). After setting the corresponding mask, the program is loaded with the transferred program name.
Network 3:
The loaded program is started in this network. To do this, the "Current_activity" register is first queried to see whether horstFX is in the program window. If network 2 was passed through successfully, a program is loaded and this is now started by the bit "Program_Calls.play". Now the local start variable #start_detectec can be reset.
Network 4:
Here the output variable #is_running is set. For this, the corresponding "Program_State" bits on the control cabinet are queried ("HORST_IN".Program_State.Is_Running and "HORST_IN".Program_Executing_mode). These indicate whether horstFX is in executing mode and a program is currently being executed (cf. Profinet input data).
Network 5:
Here, the local output variable #done is set when the called program has ended.
2. Download
The associated PLC program can be downloaded here: