TwinCAT 3 Tutorial: Introduction
This chapter is part of the TwinCAT 3 Tutorial.
In the control system industry we’re used to slow progress. PLCs lag behind PC technology by ten years or more, and we pay an outrageous premium for PLC hardware compared to the technology sitting on our desktop in our offices.
Beckhoff has always pushed PC-based control systems based on commodity hardware like Intel x86 processors and Ethernet chips. With TwinCAT 3, their flagship automation software now supports multi-core processing, which leaves traditional PLC technology so far behind it’s not even funny.
On all new TwinCAT 3 PLC programs I start, I set the task to run every 0.5 ms by default, and I could run most of them much faster. Not only does the PLC logic execute every 0.5 ms, but the EtherCAT I/O bus for a reasonably large machine can also run at this speed. When you compare this with a traditional PLC with typical logic scan times (plus I/O refresh times) in the tens of milliseconds, you can see that TwinCAT 3 with EtherCAT is far better suited to any high speed process than your typical PLC.
If you think scan times don’t matter, consider a conveyor line running at around 1 m/s (completely reasonable) and you have to fire an output as a specific point on the conveyor passes a given location (measured by an encoder). The difference between a 1 ms reaction time and a 10 ms reaction time is the difference between 1 mm and 10 mm accuracy.
The TwinCAT 3 solution also offers many advantages over the traditional PLC/HMI/Laptop combination we’re familiar with:
- The development environment runs on the same machine as the PLC logic, so you don’t need a separate laptop. Going online is as simple as opening the development environment and clicking the Go Online button.
- The HMI runs on the same machine as the PLC, so HMI-to-PLC communication responds incredibly fast. Transferring data between the TwinCAT 3 runtime and the HMI is as fast as a memory copy instruction. I’ve been able to transfer hundreds of kilobytes of data from a PLC array to a .NET application in a fraction of a second.
- If you’re into writing your own HMI software (for example in .NET), the driver for the protocol (called ADS) is included for free.
- The TwinSAFE safety editor is integrated into the development environment, so mapping signals between your safety program and your PLC program is trivial, and safety inputs can also be double-mapped both to the safety program, and to your PLC program for monitoring and alarming.
- You can use source control applications like git, mercurial or subversion, and they can even integrate with the development environment.
Not only does TwinCAT 3 offer outstanding performance, but you can download it, install it, and try it out indefinitely for free! When you try to activate your first TwinCAT 3 PLC program, you’ll be prompted to generate a 7 day trial license. When that 7 day trial license expires, if you’re not done testing, you can just generate a new 7 day trial license without reinstalling. Obviously you wouldn’t be able to run this in a production environment if you had to do this every 7 days, but the trial is a fully functional version of TwinCAT 3. Want to try something on your test bench before you commit to implementing it in production? Just install the trial version on an old PC and test it out.
I’ve been a control system programmer for over 15 years, and I’m also a .NET programmer, but I’m a ladder logic programmer first and foremost. If you’re a control system programmer in North America, you’re likely familiar with Allen-Bradley’s (or Rockwell Software’s) RSLogix family of control software. There is no doubt that RSLogix has set the standard for ladder logic editors, and to be completely honest, no other editor comes close to the user-friendliness of their development environment, and I’m including TwinCAT 3.
Beckhoff is a German company and ladder logic just doesn’t seem to be popular on their side of the pond. TwinCAT 3’s ladder editor is a major improvement over the one in TwinCAT 2, but it still doesn’t have the polish you’d be used to if you’re coming from the RSLogix world. I guarantee you’ll be frustrated the first time you try it, but that’s why I’m writing this tutorial. In my experience, programming ladder logic in TwinCAT 3 can be just as productive as in RSLogix, and it doesn’t need to be painful. Also, keep in mind that TwinCAT 3 is very new and Beckhoff continues to support and improve it.
If you’re familiar with RSLogix 5000, you may find some of my examples familiar. I’ve tried to organize my TwinCAT 3 projects in a way that’s similar to how most RSLogix 5000 programmers would organize their projects. That made the transition easier for me, and I hope it will for you too.