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

  1. Show your controller controlling the digital twin and your CIF plant model to one of the supervisors.

  2. Start TwinCAT project

  3. Generate PLC code and control a Festo workstation.

Start TwinCAT project

  1. Log in to the desktop computer of your workstation in the Festo lab.

  2. 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.

  3. 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

  1. Start Eclipse on your laptop.

  2. 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 from running to FINISHED).

  3. Plug the USB drive into your laptop.

  4. Copy and paste the plc.xml to the USB drive.

  5. Switch back to the desktop computer in the Festo lab.

  6. Plug the USB drive into the desktop computer.

  7. Navigate to PLC -> Untitled1 -> Untitled 1 Project -> IMPORT XML HERE in the Solution Explorer.

  8. Right-click on the IMPORT XML HERE folder and click on ImportPLCopenXML….

  9. Find the generated XML file (plc.xml) on the USB drive. Click Open to import.

  10. 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.

    ../_images/import-xml.gif
  11. Save the entire solution in TwinCAT by clicking File ‣ Save All, or img-save-all.

  12. Activate the configuration, click on img-activate-cfg button.

  13. An Activate Configuration-window pops up. Click OK.

  14. A dialog pops up with the message Restart TwinCAT System in Run Mode. Click OK.

  15. Login to the PLC by clicking on img-login.

  16. A dialog pops up, click yes to create and download an application on port 851.

  17. Start the PLC by clicking on img-start. 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.

  1. Stop the PLC program:

  • Click PLC ‣ Stop. Alternatively, click the appropriate toolbar item (img-stop).

  • Click PLC ‣ Logout. Alternatively, click the appropriate toolbar item (img-logout).

  1. Start the current PLC program from the beginning:

  • Click PLC ‣ Login. Alternatively, click the appropriate toolbar item (img-login).

  • Click PLC ‣ Reset cold. Alternatively, click the appropriate toolbar item (img-reset-cold).

  • Click YES in the next pop-up window.

  • Click PLC ‣ Start. Alternatively, click the appropriate toolbar item (img-start).

  1. Start the PLC after reloading the generated code:

  • Click PLC ‣ Login. Alternatively, click the appropriate toolbar item (img-login).

  • Click PLC ‣ Reset origin. Alternatively, click the appropriate toolbar item (img-reset-origin).

  • Click YES in the next pop-up window.

  • Click PLC ‣ Login. Alternatively, click the appropriate toolbar item (img-login).

  • Click YES in the next pop-up window. (Port 851 download message)

  • Click PLC ‣ Start. Alternatively, click the appropriate toolbar item (img-start).

The PLC is now running, and you can use the system.

Reset and restart PLC after changes in your CIF model

  1. Stop the PLC:

  • Click PLC ‣ Stop. Alternatively, click the appropriate toolbar item (img-stop).

  • Click PLC ‣ Logout. Alternatively, click the appropriate toolbar item (img-logout).

  1. 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 PLC ‣ Stop. Alternatively, click the appropriate toolbar item (img-stop).

  • Click PLC ‣ Logout. Alternatively, click the appropriate toolbar item (img-logout).

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.