TwinCAT PLC control of Festo workstations
Follow the steps described below to use your CIF model to create a solution and project in TwinCAT, generate PLC code in it, and use the PLC code to control the hardware. Please follow the steps very carefully, since even a small error will lead to a system that does not work.
Important
Before you can start controlling one of the workstations you must show your controller controlling the digital twin and your CIF plant model. When both models are approved by a supervisor you may control your Festo workstation.
Important
Please bring a USB drive to the Festo lab.
Procedure to follow
Show your controller controlling the digital twin and your CIF plant model to one of the supervisors.
Start TwinCAT project
Log in to the desktop computer of your workstation in the Festo lab.
Run the
start-twincat.bat
file (from the desktop) to initialize and open a new TwinCAT project. If you have used this batch file before, rerunning the batch file removes your previous TwinCAT project.Choose TwinCAT XAE Shell as the program to open the solution file if Windows ask you how to open the solution file.
Generate PLC code and control a Festo workstation
Start Eclipse on your laptop.
Generate PLC code from Eclipse, by executing the
3-plc-gen.tooldef
script. Wait for the execution of the script to finish (the status indicated as part of the title of the console should change fromrunning
toFINISHED
).Plug the USB drive into your laptop.
Copy and paste the
plc.xml
to the USB drive.Switch back to the desktop computer in the Festo lab.
Plug the USB drive into the desktop computer.
Navigate to PLC -> Untitled1 -> Untitled 1 Project -> IMPORT XML HERE in the Solution Explorer.
Right-click on the IMPORT XML HERE folder and click on ImportPLCopenXML….
Find the generated XML file (
plc.xml
) on the USB drive. Click Open to import.In the next window, click OK. A window opens that warns you that you are about to import files that already exist in the project. Select: Replace the existing object. Do the same for all subsequent conflicts. and click OK.
Save the entire solution in TwinCAT by clicking
, or .Activate the configuration, click on button.
An Activate Configuration-window pops up. Click OK.
A dialog pops up with the message Restart TwinCAT System in Run Mode. Click OK.
Login to the PLC by clicking on .
A dialog pops up, click yes to create and download an application on port 851.
Start the PLC by clicking on . Initializing should start.
Reset and restart the PLC with the same code
As long as the configuration and mapping of your solution do not change you can start and stop the PLC in the following ways. (Otherwise you may have to start at the beginning of the previous paragraph.) It is assumed that you are not yet logged in.
Stop the PLC program:
Click
. Alternatively, click the appropriate toolbar item ().Click
. Alternatively, click the appropriate toolbar item ().
Start the current PLC program from the beginning:
Click
. Alternatively, click the appropriate toolbar item ().Click
. Alternatively, click the appropriate toolbar item ().Click YES in the next pop-up window.
Click
. Alternatively, click the appropriate toolbar item ().
Start the PLC after reloading the generated code:
Click
. Alternatively, click the appropriate toolbar item ().Click
. Alternatively, click the appropriate toolbar item ().Click YES in the next pop-up window.
Click
. Alternatively, click the appropriate toolbar item ().Click YES in the next pop-up window. (Port 851 download message)
Click
. Alternatively, click the appropriate toolbar item ().
The PLC is now running, and you can use the system.
Reset and restart PLC after changes in your CIF model
Stop the PLC:
Click
. Alternatively, click the appropriate toolbar item ().Click
. Alternatively, click the appropriate toolbar item ().
Follow the 17 steps from Generate PLC code and control a Festo workstation.
Stop the PLC when you are finished, or when you switch Windows to another user
Click
. Alternatively, click the appropriate toolbar item ().Click
. Alternatively, click the appropriate toolbar item ().
Multi-user operation of each Festo workstation via TwinCAT
To allow simultaneous access to the Festo workstations via TwinCAT for as many groups as possible, TwinCAT and Windows facilitate user switching. Each group makes a reservation of just 20 minutes, but when the group needs to rewrite the model, it can temporarily relinquish control to another group by switching to another user in Windows. This saves the state of the TwinCAT system, thus allowing the group to continue where they left off, when the model has been rewritten. This is then done by another user switch.
Please note that each time you login or switch users, the same student should login. If another student of the group logs in, he or she will need to make a new TwinCAT project, following the steps described under Start TwinCAT project.
What to do when nothing seems to work
In rare cases, you may end up with a system that does not seem to work whatever you do. In such a case, the best thing to do may be to delete your TwinCAT project.
To do this, close TwinCAT XAE Shell and follow the steps from Start TwinCAT project and Generate PLC code and control a Festo workstation.