realvirtual.io
  • Building Digital Twins with Unity and realvirtual.io
  • Basics
    • Installation
    • Demo Model
      • Old Demo Model
    • Editor User Interface
      • Hierarchy Window
      • 3D Views
      • Quick Edit
      • Move Pivot Points (Pro)
      • Selection Window (Pro)
      • Material Window (Pro)
      • Measurement (Pro)
      • Kinematic Tool (Pro)
      • Model Checker
    • Runtime UI
      • Group Manager
      • Debug Console
      • Responsiveness
      • Runtime Persistence
    • Importing and exporting
    • Folder structure
    • Tutorial
    • Physics
    • CAD import (Pro)
      • CADLink (Pro)
      • CAD Checker (Pro)
      • CAD Updater (Pro)
    • Reusable Components (Prefabs)
    • Cadenas parts4cad
    • Publishing the Digital Twin
    • Revision management
  • News
  • Login & Download Updates (Pro)
  • Components & Scripts
    • Realvirtual
      • Environment Controller
    • MU, Source and Sink
      • Source
      • Sink
    • Motion and Kinematic
      • Drive
      • Kinematic
      • Group
      • Joint
      • CAM
      • TransportSurface
      • Guided Transport
      • Drive behavior
      • Chain
      • Chain element
      • Motion for developers
    • Sensors
      • Sensor
      • Measure
      • MeasureRaycast
    • Picking and Placing MUs
      • Grip
      • Gripper
      • Fixer
      • Pattern
    • Changing MUs
      • MaterialChanger
      • PartChanger
      • Cutter
    • Scene Interaction
      • 3D Buttons
      • Screen Overlay Buttons
      • Scene Selectables
      • Lamp
      • Interact3D
      • UI components
      • HMI components (Pro)
        • Start your own HMI
        • HMI Tab
        • HMI DropDown
        • HMI Puschbutton
        • HMI Switch
        • HMI Value
        • HMI Text
        • HMI Slider
        • HMI Message
        • HMI Marker
      • ModelZoo (Pro)
    • Interfaces
      • Interface Tools
        • Signal Manager
        • Signal Importer Exporter
        • Signal Catcher
        • OnValueChangedReconnect
      • Signal Importer / Exporter
      • ABB RobotStudio (Pro)
      • Denso Robotics (Pro)
      • EthernetIP (Pro)
      • Fanuc (Pro)
      • FMI
      • Igus Rebel
      • MQTT (Pro)
      • Modbus (Pro)
      • OPCUA (Pro)
      • PLCSIM Advanced (Pro)
      • RoboDK (Pro)
      • RFSuite (Pro)
      • SEW SimInterface (Pro)
      • Siemens Simit Interface (Pro)
      • Simit Shared Memory (Pro)
      • Simulink (Pro)
      • S7 TCP
      • TwinCAT (Pro)
      • TwinCAT HMI (Pro)
      • UDP (Pro)
      • Universal Robots (Pro)
      • Wandelbots Nova (Pro)
      • Websocket (Pro)
      • Windmod Y200 (Pro)
      • Custom Interfaces
    • Performance Tools
      • Combine Meshes (Pro)
      • Create Prefab (Pro)
      • Hierarchy Cleanup (Pro)
      • Mesh Optimizer (Pro)
      • Performance Optimizer (Pro)
    • Defining Logic
      • Unity Scripting
      • Behavior Graph
      • Logicsteps
      • Unity Visual Scripting
      • Recorder
    • Robot Inverse Kinematics (Pro)
    • Volume Tracking (Pro)
  • Multiplayer (Pro)
  • Extensions
    • ModelZoo
      • Beckhoff TwinCAT
      • Siemens S7
      • Denso Cobotta 1300
      • Wandelbots Nova Fanuc CRX
      • Universal Robots UR10
      • Fanuc Roboguide
    • realvirtual.io AIBuilder
      • realvirtual.io AI Builder Overview
      • Generate AI Training Data
      • AI Training
      • Testing AI in a Digital Twin
      • Deploying the AI
    • realvirtual.io Simulation
      • Conveyor Library
      • Path System
        • Path finding
        • Line
        • Curve
        • Workstation
        • Catcher
        • Pathmover
    • realvirtual.io Industrial Metaverse
      • Setup Guide
      • VR Modules
      • AR Modules
      • Multiuser
    • AGX Physics
    • VR Builder
    • CMC ViewR
  • Advanced Topics
    • Render Pipelines
    • Mixed Reality with Meta Quest3
    • Upgrade Guide
      • Upgrade to 2022
    • Open Digital Twin Interface
    • Usefull Addons
    • Improving Performance
    • Supported Platforms
    • Compiler Defines
    • For Developers
      • Important Classes and Interfaces
      • Assembly Definitions
      • Starting your development
      • Class documentation
      • realvirtual Init Sequence
      • realvirtualBehavior Lifetime Methods
      • Testing
    • Newtonsoft JSON
    • Troubleshooting
  • Release Notes
  • AI Digital Twin Assistant (GPT4)
  • License Conditions
Powered by GitBook
On this page
  • Introduction
  • Prerequisites for TwinCAT ADS Communication
  • Interface configuration
  • Importing signals
  • Interface communication modes
Edit on GitHub
  1. Components & Scripts
  2. Interfaces

TwinCAT (Pro)

Connecting Beckhoff PLC with realvirtual.io

PreviousS7 TCPNextTwinCAT HMI (Pro)

Last updated 18 days ago

Please note, that this Interface is only available in realvirtual.io Professional

Introduction

is the programming framework for Beckhoff PLCs. The realvirtual.io TwinCAT interfaces uses ADS as communication framework to Beckhoff PLCs. The Bechoff PLCs can be virtual ones like the one delivered with the TwinCAT programming environment (which can be downloaded for free here ) or it could be a real PLC connected over the network with your PC.

The TwinCAT programming environment is enabling, just for development purposes, for free 7 day trial licenses for the TwinCAT PLC runtime. The virtual PLC can also act as a OPCUA server and it can be also used with the OPCUA interface. But we recommend to use directly the TwinCAT Interface if you just want to communicate with Bechoff PLCs because this interface is faster and creates less overhead than the OPCUA interface.

Prerequisites for TwinCAT ADS Communication

To establish TwinCAT ADS communication, you must have either a complete TwinCAT3 environment, which includes a virtual PLC, programming environment, and ADS router, installed on your PC, or you can opt to install just the TwinCAT ADS component (TC1000 TwinCAT 3 ADS). The necessary software is available for download from the official website.

Interface configuration

The TwinCAT interface is added to the Scene by selecting Tools > realvirtual > Add Component > Interface > TwinCAT or by adding the script TwinCATADSinterface to an empty GameObject.

You will get an inspector window like this:

Importing signals

With Import signals all signals of the current TwinCAT project are imported.

Please make sure that NetID and PortID are configured and that the TwinCAT configuration is activated. Otherwise an error will appear if you try to import the signals. The icon of TwinCAT in the Windows Taskbar should now be green.

After importing the signals you get all signals as Gameobjects in your scene:

RegEx for Signal import

RegEx Import Signals For limiting the number of imported signals another RegEx can be used. In RegEx Import Signals one ore multiple RegEx as part of the signal names can be defined. If the list is empty everything is imported. If the list has one or multiple RegEx are defined only signals which are matching one of the RegEx are imported. For example be defining this RegEx

only signals which are named IO…. are imported like IO.TestInputBool,IO.TestOutputBool and so on.

RegEx Skip Signals If you give here one or multiple strings all signals which are matching one of the strings will not be imported.

RegEx Symbol is PLC Input If the imported signals are defined in the TwinCAT project as an Input or Output, the corresponding realvirtual.io signal type will be attached to the Signal. For global TwinCAT variables, which are not assigned an input or output area, this is not possible, because it is not defined if the signal should be a PLC output or input. If it is not defined, the standard setting will import everything as input. You can change it manually by for example replacing the PLCOutputBool script against a PLCInputBool script. If you give here one or multiple strings all signals which are matching one of the strings will be imported as input. This is only necessary for global variables where it can’t be detected, if they are input our output.

Sub-folders when importing signals

TwinCAT is organizing variable in an object oriented approach. The signal symbol names are usually [object].[name]. You If the option Create sub folders is selected for each [object] one additional hierarchy in the Signal hierarchy is created.

Interface communication modes

The TwinCAT interface provides 3 different operation modes. Dependent on that mode, all signals are exchanged in a cyclic manner or signals are exchanged based on change events. You should select the mode which fits best your application and performance needs.

CyclicSumCommand This is the standard option and is the best performing mode with a lot of fast changing signals. The TwinCAT interface is operating in this case in Multithreaded mode and the thread status is displayed in the inspector. In this mode all signals are exchanged with one ADS command for reading and one ADS command for writing in each Thread cycle. For example about 700 input and output signals can be exchanged in a cycle of about 30ms. With MinCommCycleMS define a minimal cycle time and if you communication is faster the parallel thread is waiting for the next cycle. The communication thread is running independently from the main Unity thread and the signal data exchange will not slow down your simulation.

Cyclic The AdsNotification event is fired cyclically. The Notification will be registered on the ADS Server side for a cyclical trigger (dependent on time parameter) and is bound to the ‘default’ task of the addressed target. In case of the PLC target (e.g. Port 851) the default task is the first configured task. Each time the ‘default’ task has finished its cycle the real-time system will check for the expired cycle time and sends the AdsNotification message on expiry. Please be aware, that server side ‘Change’ notifications stress the real-time system and should be handled with care.

OnChange The Notification will be registered on the ADS Server side for an on-change and optional cyclical trigger (dependent on parameters) and is bound to the ‘default’ task of the addressed target. In case of the PLC target (e.g. Port 851) the default task is the first configured task. Each time this task has finished its cycle the realtime system will check for the changed value and an optional expired cycle time and sends the

Please note that Cyclic and OnChange can stress with a lot of fast changing signals the communication a lot and due to the many events the Unity and PLC performance can decrease dramatically. Please use this option only if the speed of signal changes and the number of changed signals is limited.

For accessing the virtual or the hardware Beckhoff PLC you need to configure the NetID-Adress under Net Id and the Port number. The standard settings of the interface are for a local installed TwinCAT3 development environment with a local virtual PLC. For TwinCAT2 the Port number must be changed. For more information about the configuration of NetIDs and Ports please refer to the .

For limiting the number of signals you can define with RegEx (see ) special filters. In the simplest case a Regex is a part of a string which can be found in the Symbol name.

© 2022 in2Sight GmbH - All rights reserved. No part of this publication may be reproduced, distributed, or transmitted in any form or by any means, including printing, saving, photocopying, recording, or other electronic or mechanical methods, without the prior written permission of the publisher.

Bechoff documentation
https://en.wikipedia.org/wiki/Regular_expression
https://realvirtual.io
TwinCAT
https://www.beckhoff.de/twincat3/
Tutorial Beckhoff Interface
LogoTwinCAT 3 ADSBeckhoff Automation
TwinCAT3 Downloads