7 Tips for Programming Beckhoff TwinSAFE Safety Logic

7 Tips for Programming Beckhoff TwinSAFE Safety Logic

TwinSAFE is a module of Beckhoff’s TwinCAT programming software that allows a programmer to set up safety logic for Beckhoff Safety PLC’s. I've picked up a few tips and tricks in my time working with TwinSAFE, and I hope you will find them useful.

1. SafeAND – Use A Standard Bool

As you develop your safety program, you’ll notice that most of your inputs will be required to safety bool input. However, when using a SafeAND block, your first input (and only your first input), can be a standard bool input. This allows you to integrate logic from your PLC or HMI into your safety program.

Image of a Beckhoff TwinSAFE standard bool

2. Link Outputs to Inputs

While you’re zoomed out setting up your safety program, you will most likely find yourself trying to connect some outputs and inputs. If you find they can’t be connected, try zooming in. When zoomed out, TwinSAFE has a tough time picking up where you’re trying to click.

Image of Beckhoff TwinSAFEoutputs linking to inputs

Image of Beckhoff TwinSAFE outputs and inputs linking

3. Copy/Paste

This one is quick – you can’t copy and paste any safety blocks in the TwinSAFE program. If you need an additional block, navigate to the toolbox ( ) and bring in the proper block.

4. Create Variables

To create a variable in TwinSAFE, simply start typing at an input or output of a block. That variable will get placed into your variable mapping table, where you can associate the proper alias port to it.

5.Variable Mapping – Delete Variables

Anytime you delete a variable (or the block to which it’s connected), the variable mapping for that variable will be deleted. This feature makes sure that you don’t accidentally leave a variable linked to an output with which you no longer wish to link. If you forget to re-link a variable, your compile of the safety program will fail. To fix this, simply map the variable to an alias port.

6. Variable Mapping – Link Multiple Output Variables

If necessary, you can link a single output variable in your safety program to multiple alias ports in your safety mapping. When selecting your alias port mapping, simply CTRL + click to select multiple alias ports. This can be useful, for example, if you want a single error acknowledge button that will acknowledge errors on multiple drives.

Image of Beckhoff TwinSAFE variable mapping

7. Download the Safety Program

When downloading the safety program, you’ll be prompted for the username, serial number, and password. If the programmer has not changed them, the default username is “Administrator”, and the default password is “TwinSAFE”. To find the serial number, go to the target system tab, and find the serial number section.

Image of a Beckhoff TwinSAFE safety program

Learn more about DMC's Beckhoff PLC solutions.


Nikhil Holay
# Nikhil Holay
Fred - That is correct. If you open up the safeAND block for TwinCat2, you'll notice that you're able to connect a standard input to the first input, but not any of the others.

Noam - Regarding simulation, we typically don't simulate safety programs, just because so much of it is tied to IO that cannot easily be simulated (i.e. dual channel estops). If you're finding yourself in that situation, I would recommend developing similar logic in a standard PLC program, or disconnected outputs in the field. As to your second question, we keep backups of our programs stored with a version control software (external to TwinCat).

Hope this helps!
# Fred
Hello, for the first tip (SafeAND – Use A Standard Bool) : that rule is also valid for twincat 2 safety or only for twincat 3 safety ? Thanks a lot for your answer. Fred
# Noam
How do you simulate the TwinSAFE design?
As a graphical language, how versions are controlled?


Post a comment

Name (required)

Email (required)

Enter the code shown above: