Beckhoff#TwinCAT3 x TE1400 x Simulink Setup Guideline

This post I will explain how to link the TwinCAT3 System to the Simulink models and make simulations.This Road is a little long and I would like to remember all the things that I did before.

Please download the TE1400 Manual by the below link.It shoube be better to read this 🙁 and I will try to refer to all the installations within the Manual.

Project Link:

And, It should be better to install this software in the VMWare.

What is TE1400 TwinCAT Target for MATLAB®/Simulink®?

The MATLAB and Simulink Coder® had an Auto-Code generator, we can use this generator to auto convert our model to C/C++ Code.And Beckhoff’s TE1400 is operating based on the code that generated this TE1400.

While we use TE1400 Target to generate our code from the model, a TcCOM(TwinCAT Object Model) is generated from it. This TcCOM3 object can be imported into your XAE.

Also, If necessary, while you start the runtime, the TcCOm models will be automatically run in Real-time and be a part of your machine.

What is MATLAB®/Simulink®?

Sure that you can search from Google.

When you use MATLAB® and Simulink® together, you combine textual and graphical programming to design your system in a simulation environment.

Directly use the thousands of algorithms that are already in MATLAB. Simply add your MATLAB code into a Simulink block or Stateflow® chart.

Use MATLAB to create input data sets to drive simulation. Run thousands of simulations in parallel. Then analyze and visualize the data in MATLAB.

Please refer to the above link to get more information.

Application Example

Rapid Control Prototyping

You can use Simulink to play the Real-time close loop control simulations with TwinCAT.

The Input/Output that is configured in the Simulink can be directly integrated into your TwinCAT Project.

We will call this as “Model in the loop Simulation”.

For Example:

Surely This Model in Simulink will be automatically generated as TcCOM modules and imported into your TwinCAT Project.

Real-time simulation of a machine / virtual commissioning

We can Generate the TcCOM modules from Simulink modules – And we can test that Model in Real-time.Thanks for this Technology, the program debug time,Commissioning time are decreased.

And we have 2 types of Configurations:SIL and HIL.


This type of configuration is All the Remote IOs,PLC,Drives are in the virtual environment.

It is your first step of Virtual commissioning.


Here is the next step – You will integrate some parts of Hardware inside your control loops.

For example: Drives,Remote IO.


Now I will explain how to install the TE1400 into your system.


Engineering PC

Visual Studio

Reference to the installation manual, Visual Studio 2010(SP1),2012,2013,2015 or 2017 is supported.Please instal the above version.

Trips:Please Always Run as administrator for the installer.

And if you are using Visual Studio 2017,please check the box of “Desktop development withC++”.

Microsoft “Windows Driver Kit” version 7.1.0

If your TwinCAT3 Version is lower than 4024.0, please search in google and install it

Here is the link:

Unzip and run the installer as administrator.

Check the “Build Environments” and OK.

Set up the install path and please just let it in default.

Also,please copy the path to the notepad.

Agree the License and OK.


This installation takes about 5 mins in my VM.


Modify the environment variables of windows.

Control Panel>System and Security>System>Advanced system settings

Advanced>Environment Variables。

System variables>New。

Variable Name:WindDDK7

Variable value:The path that you copied before in notepad.

Restart your PC.


Install TwinCAT3 XAE into your Machine 😉

Sure, you need it!

Runtime PC

IPC or Embedded CX PC with Microsoft operating system based on “Windows NT kernel” (Win XP,Win 7 and corresponding embedded versions, Win 10)


Depends on the Version..

  • TwinCAT 3.0:32BitOS only
  • TwinCAT 3.1:32Bit/64BitOS Both OK。
    But you need to instal Driver sign if 64BitOS is used.

Driver sign

You can have a detailed explanation in the below link:

Because I am using Visual Studio 2017, open the Developer Command Prompt inside the Visual studio 2017 folder.

Create the certification.

makecert -r -pe -ss PrivateCertStore -n CN=MyTestSigningCert MyTestSigningCert.cer

Now we can check if the certification is available or not.

Command prompt>mmc.

File>Add/Remove snap-in.


Select My user account,Finish.

Press OK.

Save it.

Add the certification into your PC Environment Variables.

PC Environment Variables>User Variables>add the certification name that red-lined below.




Check the Tc Sign setting into Configuration Properties>Tc Sign.

Change to TestMode

Run the Command prompt as Administrator and then execute the below command:

bcdedit /set testsigning yes

Restart your PC.

If the below text is shown in your Desktop, now your PC is in Test Mode.



  • MATLAB®/Simulink®
    • From R2010a to R2019a
    • R2010b later is recommended.
  • Simulink Coder®

TE1400 Target

Download from the below link:

After installation is finished, TE1400-TargetForMatlabSimulink is created.

Open the Matlab as Administrator.

Open the Folder.

Choose TE1400-TagertForMatlabSimulink Folder.

You can see the SetupTwinCatTarget.p inside the Folder.

Right click and Run.

If the Setup is OK, you can see the following messages in the Command Window.


TE1400 does not have the 7-days full functional trial license.

but you can use the demo license.

First Model


You can see the Model Edit Screen.

Click the Setting Button.

Click the Solver Tab.


Fixed-step size:0.01

Code Generation>Browse

Choose TwinCAT.tlc.

Check the Publish module inside TC Build and  TwinCAT RT(x86) and (x64),


Create a sample model.

Compile it.

If there is No Error, you are finished!

The tmc file is auto created also.


Next, Import the tmc into your PLC.

Open the TwinCAT XAE.

Create a new project.

C++>Add Existing Item.

Choose the C++ Project that you compiled in the Simulink.

Right Click the Project and Rebuild.

Build OK!

Then import the model that you compiled.

TcCOM Object>Reload System TMC Files。

TcCOM Objects>Add New Item.

TE1400 Module Vendor>Generated Modules>Choose the Model that you compiled>OK。

Choose the TcCOM Objects, Assign the task by Context>Task.

Use Build>Build Solution to compile your project and download to the runtime.

Click the Online button to monitor the current status.

you can see if you click In1, “0(False)” is displayed in the graph.

Press the write button. the graph will display 1(true).

You can also view the model in the Block Diagram.


We monitored the signal in the previous parts.

Now we would like to link these signals to our PLC.

Click POUs>MAIN.

Define these Variables.

What is the the meaning of this –  binput1 AT %Q*:BOOL; ?

下のInformation Systemには説明があります:we can find more information in the below link:

The Reason that we need to define the local process IO:

If the code generator is configured appropriately with TwinCAT Target, a TwinCAT Object Model (TcCOM) is created with the input and output behavior of the Simulink model.

Build>Build Solution Again.

We would like to connect the In1,In2,Out1 of TcCOM to Untitled1 Instance’s In1,In2,Out1. 

Let’s assign the Input and output.

Click the In1 inside the TcCOM Objects.

Choose binput1>OK.

And do the same operation for the other parameters.

Build the Solution again after you assign all the pins.


We can test the AND Gate very soon

Just turn on binput1.

Then turn on binput2.

We can see bOutput1 is True now.


TwinCAT3 AdsWarning 4115: system clock setup fail

If you can not Start the TwinCAT3 Runtime..


  • Restart your Machine
  • Disable Hyper-V
  • Run as Administrator :win8settick.bat

Compiler is not match 

Please install the current version of Visual Studio.

x64 Publish procedure failed

While compiling the model in the Simulink, it just showed error and please send this report to Beckhoff Automation.

it said, ”You can try to build manually using the project file..”.

Let’s try it.

Insert that C++ Project and Compile it.

This time it shows “Either a certificate name or a certificate ID is expected”.

It seems like we do not have the Signtool!


Please download the SignTool and install it.

Reference Link:

Open Control Panel>Visual Studio>Change.

Check all the tools and install it.

Restart your PC.



Beckhoff Information System


TWINCAT3 – Installation Manual

TC3 Target for Matlab®/Simulink® Manual

TwinCAT C/C++ Manual

Publish Procedure Failed – Simulink code generation with TwinCAT.tlc Target file

How to install SignTool.exe for Windows 10

How to install SignTool.exe for VS 2017?

TwinCAT3 AdsWarning 4115: system clock setup fail

TwinCAT 3 Error When Switched to Run Mode.

The implementation and debugging of TwinCAT 3 C++ modules requires

Windows Driver Kit Version 7.1.0

Driver signing

How to sign X64 Driver Beckhoff TwinCat3

TE1400 Download

Global Variables


Find ME

Email:soup01threes* (* to @)


  • このエントリーをはてなブックマークに追加