Contact and Coil | Nearly In Control

TwinCAT 3 Tutorial

This is an in-depth tutorial on Beckhoff’s TwinCAT 3 PC-based automation software.

Twin cats?

Twin cats?

The tutorial is organized into a chapter format and is meant to be read like a book. Start here with the Table of Contents:

  1. Introduction
  2. Quick Start
  3. Structuring PLC Data
  4. Persistent Variables
  5. Structuring PLC Logic
  6. Multiple Virtual PLCs
  7. Ladder Logic Editor
  8. Writing your own Functions and Function Blocks
  9. Structured Text
  10. Building an HMI in .NET
  11. Introduction to Motion Control
  12. Introduction to TwinSAFE
  13. The Scope View
  14. Part Tracking

Be sure to check out my RSLogix 5000 Tutorial as well.




19 comments

  • codezs09 · January 29, 2016 at 12:59 pm

    This tutorial is great. Very specific in every details with understandable explanations.
    There are not a lot intro related to TWINCAT 3. This one is really the best I have ever seen.
    Much thanks to your effort! And strongly recommend it to others.

  • Gerard · February 23, 2016 at 11:28 am

    I find it a pity that the tutorials don’t come with a time stamp. One can see how old the blog entries are, but no idea about each of the tutorial chapters.

  • Ledian · February 28, 2016 at 8:58 am

    I come from an Omron plc experience background on Cx-Programmer and now I am trying to learn NJ-controllers (Sysmac Studio) and Backhoff (TwinCat 3) as both environments are based on Codesys. I like the ideology of these products more than Siemens and AB. I found these TwinCAT 3 tutorial useful as it’s detailed and clear to understand with examples. Thank you for your contribution, I will continue to follow every chapter of this tutorial hoping to get all the basic knowledge of PC based Automation Technology from Beckhoff. Good work, thanks again.

  • John nielsen · March 18, 2016 at 4:24 pm

    Great tutorial. Very easy to understand and thoug with very detailed and good explanations.
    The Best intro to TWINCAT 3.I have seen so far.
    Are you planning a chapter on scoope view ?
    I very much recommend this tutorial to others.
    Very god work, thank you very much

  • Author comment by Scott Whitlock · March 19, 2016 at 10:11 am

    @JohnNielsen – Thank you! Yes, after the next chapter (on TwinSAFE) then I’m going to do a chapter on the Scope Viewer, which is a really useful tool, even though it’s a bit intimidating at first.

  • John C. · April 15, 2016 at 1:44 pm

    Scott, I very much appreciate your tutorials. I’m in the process of learning TwinCAT 3 and, as others have pointed out, there are virtually no “getting started” materials available from Beckhoff. I found your “Structuring PLC Logic” lesson to be particularly interesting, as I come from an AB background. Keep them coming!

    (If you’re taking suggestions for future lessons, I’d like to learn more about EtherCAT… tips on laying out networks with couplers and terminals, addressing, troubleshooting, etc.)

  • glauber cabral de souza · April 17, 2016 at 12:42 pm

    Thank you a lot!!!! this helped me so much.

  • alex · April 20, 2016 at 10:20 am

    great tutorial for starters just like me
    many thanks from china!

  • biruk · May 17, 2016 at 5:39 am

    This is a great tutorial, very well organized, simple and tractable explanations. Thank you

  • Jeyfel Brandauer · May 19, 2016 at 5:50 am

    Thank you for this great tutorial!
    I’m a student currently in an internship and i’m kind of new in the automation control world. I do software development. So this tutorial is definitely helpful as I have to use TwinCAT.

    In the 6th part of the tutorial we create a EtherCAT device and its I/O. Each I/O (eg. EL1008 channels) of an EtherCAT device has its own Index group and offset. Does it mean that we can access them remotely with a TwinCAT ADS Client?
    This would be of great help to me.

    Regards
    Jeyfel B

  • Author comment by Scott Whitlock · May 19, 2016 at 7:24 am

    @JeyfelBrandauer – In theory yes, but I can’t remember ever doing it. If you happen to be doing a non-real-time system (just using Beckhoff I/O controlled from, e.g. C++ or C# in a PC program) then I recall the right way to do that is to create a Task in TwinCAT without creating a PLC (this way you only need the I/O license, not the PLC license). You create variables directly in the Task and you map them to the I/O. I/O needs to be linked to a task for it to “scan”. The task has an ADS port number. You then read and write to the variables you’ve created directly in that task, and TwinCAT handles moving the data to/from the I/O card (e.g. EL1008). That was a long time ago, though, so it’s a bit fuzzy.

  • Jeyfel Brandauer · May 20, 2016 at 3:56 am

    @Scott – Thank you for the reply! I’m working on a virtual commissioning project. We need to test and validate our PLC programs (Ladder, ST etc.) by running them inside of TwinCAT. My goal is to build an external program (i.e an ADS client program, in C++) which will “drive” the validation of our PLC programs by interacting with TwinCAT. Actually I did couple of things such as reading and writing PLC variables. The problem that I’m facing is to subscribe to their “state change” event. TwinCAT provides an ADS notification service to do so, but it’s not available for IO-tasks. @soberschmidt at GitHub suggested me a workaround: a mapping to PLC variables. I thought that I had to create a device (EtherCAT simulation for instance) and map its I/O to my PLC variables.But the device I/O are unreachable through ADS protocol.

    I will try what you suggested to me and combine it with an existing PLC project. Thanks again.

    Jeyfel B
    (sorry for my English, I’m from France)

  • Sina B · May 26, 2016 at 7:39 am

    This is amazing! Keep the nice work up.

  • Ivan · June 15, 2016 at 10:26 pm

    Hi Scott. Thank you very much for creating this excellent guide. It has been extremely useful in helping me learn TwinCAT 3. Thank you for putting this together and sharing your knowledge.

  • Chris · June 21, 2016 at 2:01 pm

    This is a nice write-up… many thanks!

  • Sachin Kapatkar · July 18, 2016 at 5:41 am

    Nice presentation in tutorial.
    Thanks allot.
    Keep sharing such helpful information.

    Best regards,
    Sachin Kapatkar
    (From India)

  • Krystian · November 28, 2016 at 2:13 pm

    Hi.
    I have just little experience with automation and this is very helpful. I just have a question if there is possible to run some kind of simulation mode, to check if my code/diagrams are logically correct. Like Simulation Mode from Siemens Logo!.

    Regards

  • Armando Narvaez · November 28, 2016 at 7:40 pm

    Hi Scott,

    I have to say that your tutorial is great! I come from an AB/Ladder background but, ever since I started my Master’s, I had to switch to a CODESYS/ST environtment. It was kind of tough at the beggining but, on the programming aspect, I think I can handle it myself. It is a bit helpfull that I also have a strong background on OOP and CS concepts.

    I wanted to ask you, if you have a “rule of Thumb” or way to choose which PLC should you use or which specs (# of cores, RAM, SDD storage and whatsoever) ?

    I’m asking you this because, outside of my Master’s, I’m working on a project with around 300 IO’s, 30 PTP axes, an OPC UA Server, a MySQL database and an HMI. But I don’t know if a PLC with only 2/4 cores could handle everything.

    Thanks in advance,
    Best Regards,

    Armando Narvaez.

  • Author comment by Scott Whitlock · January 8, 2017 at 4:38 pm

    @ArmandoNarvaez – sorry for the delay. The higher end Beckhoff IPC at the moment is a Core i7 with 4 cores, and even though they force Hyperthreading off in the BIOS, it still screams when it comes to PLC and motion control logic. We always use a Core i5 now, and it just doesn’t seem to make a difference how much logic you throw at it.

    We always use an SSD and 8GB of RAM at the moment.

Leave a Reply

Theme Design by devolux.nh2.me