Part 1 - Introduction
Video
#PLC #TwinCAT3 #Beckhoff #IEC_61131-3
Previous Part | Next Part 🔜
Table of Contents:
- A) Welcome to the tutorial
- B) Contents of the tutorial
- B.1) Basic Group
- PART2 - Basics & installation
- PART3 - Tasks, programs & "Hello world"
- PART4 - Data types & arrays
- PART5 - Structures & functions
- PART6 - Function blocks & interfaces
- PART7 - Instructions (if/else, case-switches, for and while loops)
- PART8 - Tc2_Standard library (timers and triggers)
- PART9 - TwinCAT utilities
- PART10 - I/O
- PART11 - Libraries
- PART12 - TwinCAT functions
- B.2) Advanced Group
- B.1) Basic Group
- C) Other relevant topics for TwinCAT3
- D) IEC 61131-3 standard (programming languages of PLCs)
- Z) Glossary
A) Welcome to the tutorial
This tutorial will give you an introduction to the world of TwinCAT 3 software development.
https://alltwincat.com/twincat-3-tutorial/
The content of this tutorial is about the most important parts to know about PLC development in general and TwinCAT development in particular.
The Beckhoff infosys is great for reference, but it is not course or tutorial material.
https://infosys.beckhoff.com/
Most of the development practices in TwinCAT and for the field of automation in general does not have its roots in the field of software engineering (e.g C and C++) but rather in electrical engineering. PLC software development tools and practices have not had the same development as standard "IT software development".
Working with TwinCAT3 can give you opportunities to work with everything from:
-
Manufacturing machines
-
Machines converting wave energy into electricity
-
The largest optical telescope in the world
-
Autonomus Guided Vehicles
B) Contents of the tutorial
This tutorial is divided into two main groups:
-
The first group consists of part 2 - 12 which is the basic group and the scope of this is to give the most important blocks of information for the developer to create useful PLC software.
-
The parts 13 - 17 create the advanced group of this tutorial which the topics at some point you will most likely come across (these parts will not cover the core functionality of TwinCAT but rather things that are good to know to have a deeper and more advanced understanding of the TwinCAT ecosystem).
This is the content of the parts of the tutorial:
B.1) Basic Group:
PART2 - Basics & installation:
Here we'll see background information to TwinCAT 3 and describe on a high level how it works. We will also download the TwinCAT 3 development environment, the so called XAE so that we have everything up for our first program.
PART3 - Tasks, programs & "Hello world":
Here we will investigate the real-time properties of TwinCAT by learning how to define a task and create a program.
We will create a typical "Hello world" program although not in the "classical" sense. We will use the ADSLOGSTR()
function.
Note: To have a working program it's also necessary for us to investigate how licensing works in TwinCAT3.
PART4 - Data types & arrays:
Here we will see the various data types that are available in IEC 61131-3, the standard for the programming languages of PLCs, which TwinCAT 3 has implemented defines several datatypes that can be used.
PART5 - Structures & functions:
With structures you can group variables together into logical groups. Here we are also going to go through functions and some various ways in getting data in and out of functions.
Example - T_FILETIME structure:
PART6 - Function blocks & interfaces:
The closest thing we will get to the concept of classes in regular programming languages in the PLC programming world are function blocks. In this chapter we will dive into the equivalent building blocks of object oriented programming (OOP) languages.
It is divided in two parts:
-
Part 6a - Function blocks and interfaces (IEC 61131-3)
Example - GETSYSTEMTIME FB:
-
Part 6b - Function blocks and interfaces (IEC 61131-3)
Example - Interface vs Abstract Classes
PART7 - Instructions (if/else, case-switches, for and while loops):
Here we will cover if/else, case-switches, for and while loops and some other basic instructions.
PART8 - Tc2_Standard library (timers and triggers):
As TwinCAT 3 conforms to the IEC61131-3 standard there are certain things it has to be able to do. The Tc2_Standard library has many of the standard IEC functions such as timers and triggers which we will look into in this chapter.
PART9 - TwinCAT utilities:
In this chapter we will learn how to use one of the most used Beckhoff libraries for various purposes. We will add the library to our project and use some of the functions located inside of it.
PART10 - I/O:
When designing and building a control system you will eventually want the control system to actuate something, be it:
- a relay
- a mixer
- a boiler
- a pneumatic system
To get feedback of the actuation, sensors are needed.
In this part we will cover how we communicate with the environment using inputs and outputs (I/O)
PART11 - Libraries:
Once the complexity of your software gets to a certain level it might be a good idea to start thinking about splitting the software into different libraries.
This part will go through how this is accomplished and what you need to think of.
PART12 - TwinCAT functions:
When installing the TwinCAT development environment and runtime you get access to the core functionality but sometimes you want might want to extend this with additional functionality as for example adding an SQL-database connection.
In this chapter we will investigate some TwinCAT functions that can be added.
B.2) Advanced Group:
PART13 - Version control:
Version control in the world of automation has historically not been the highest priority but with TwinCAT 3 this is entirely possible using standard version control software.
In this part we will go through how we can do proper version control using the Git version control system.
PART14 - Handling different TwinCAT versions:
When developing TwinCAT over time, you will most likely end up in a position where you must be able to develop and maintain software for various versions of TwinCAT. This chapter will go through how this is done
PART15 - ADS:
ADS, the Automation Device Specification is Beckhoffs middleware to communicate with Beckhoff PLCs
It's used for all kinds of use cases, such as:
- software deployment
- reading and writing of variables
- internal communication of software modules.
In this part we will go through the theory, and also write some C# software to communicate with the PLC. We will also do a simple C++ program running under Linux that talks to the PLC.
PART16 - TwinCAT automation interface:
With the TwinCAT automation interface it's possible to automate certain parts of the configuration, development, and deployment process of your PLC software.
In this chapter we will look into the possibilities with the TwinCAT automation interface, and look at one example.
PART17 - Test driven development:
Test Driven Development (TDD) has been around in the field of software engineering for quite some time.
The world of automation has been lacking behind but nowadays it's entirely possible to do unit testing with TwinCAT using the TcUnit unit testing framework.
This chapter will show how to do TDD with TwinCAT
PART18 - Final Words:
A tutorial is not complete without a few final words to wrap up what we have learned and where to go from now.
C) Other relevant topics for TwinCAT3
There are many other topics that can be covered in a TwinCAT 3 tutorial.
A few of them are for instance:
- Motion control - for when you want to control motors
- HMI - For when you want to do a fancy front-end for your application
- Vision - For when you want to use a camera to do for example quality inspection
- Measurement - When you want do measure and analyze your process
These are however HUGE topics in their own manner and each and one of them could easily be a multi-part tutorial. Beckhoff has this complete ecosystem of industrial automation that you can probably spend a lifetime investigating in detail if you would like to.
D) IEC 61131-3 standard (programming languages of PLCs)
The IEC 61131-3 is a standard concerning the software architecture and programming languages of PLCs.
In this IEC standard there are five programming languages defined:
-
Sequential Function Charts (SFC)
-
Ladder Diagram (LD)
-
Function Block Diagram (FBD)
-
Instruction List (IL)
-
Structured Text (ST)
This tutorial will only cover the high-level language Structured Text, as this is the language that is the most similar to other programming languages that you might already have experience with.
Let's get started! :)
Previous Part | Next Part 🔜
Z) Glossary
File | Definition |
---|