Instrument Control System Seminar, 20 th -24 th October 2014 C++ with TwinCAT Mario Kiekebusch (On behalf everyone who took part on this work)
Instrument Control System Seminar, 20 th -24 th October 2014 Outlook Motivation Development Applications Preliminary Conclusions Live Demo
Instrument Control System Seminar, 20 th -24 th October 2014 Introduction Reuse of existing C/C++ libraries. Reuse of in house expertise. Why is C/C++ Relevant? Extending normal capabilities of PLC. More efficient object code.
Instrument Control System Seminar, 20 th -24 th October 2014 Engineering PC Windows XP or Windows 7 Microsoft Visual Studio 2010 and 2012, Level Professional, Premium or Ultimate. Microsoft "Windows Driver Kit" (WDK) TwinCAT 3 installation (XAE Engineering) Introduction
Instrument Control System Seminar, 20 th -24 th October 2014 Run-time Machine Embedded PC Windows: XP,7 or Embedded Standard TC 3.1 (XAR Run-Time) Licenses: TC xx: TwinCAT 3 C++ TC xx: TwinCAT 3 C++/Matlab TC xx: TwinCAT 3 PLC/C++ TC xx: TwinCAT 3 PLC/C++/Matlab Introduction
Instrument Control System Seminar, 20 th -24 th October 2014 Modular Design Flexible Scalable Based on “Component Object Model (COM) High Reusability preemptive multi-tasking parallel processing of tasks Introduction Run-time Environment
Instrument Control System Seminar, 20 th -24 th October 2014 Introduction Mandatory Attributes Module Optional Attributes
Instrument Control System Seminar, 20 th -24 th October 2014 Introduction State Machine Transitions: INIT2PREOP (IP) PREOP2SAFEOP (PS) SAFEOP2OP(SO) OP2SAFEOP(OS) SAFEOP2PREOP(SP)
Instrument Control System Seminar, 20 th -24 th October 2014 Development Creating a Project … 1. Select New Item
Instrument Control System Seminar, 20 th -24 th October 2014 Creating a Project … 2. Select Project Type Development
Instrument Control System Seminar, 20 th -24 th October 2014 Creating a Project … 3. Selecting Module Class Development
Instrument Control System Seminar, 20 th -24 th October 2014 Creating a Project … 4. Entering Module Name Development
Instrument Control System Seminar, 20 th -24 th October 2014 Development Project Skeleton
Instrument Control System Seminar, 20 th -24 th October 2014 Development
Instrument Control System Seminar, 20 th -24 th October 2014 Development Executing the C++ Code… 1. Creating a module instance
Instrument Control System Seminar, 20 th -24 th October 2014 Executing the C++ Code… 2. Triggering module execution Development
Instrument Control System Seminar, 20 th -24 th October 2014 Development Code Generation via TMC Editor
Instrument Control System Seminar, 20 th -24 th October 2014 Development Debugging … 1.Enable debugging 2. Start Debugging 3. Start TwinCAT Live Watch 4. Monitor Variables
Instrument Control System Seminar, 20 th -24 th October 2014 Development Deployment … 1.Publishin a module 2. Importing a module Binaries (32 & 64bit) TMC file (XML)
Instrument Control System Seminar, 20 th -24 th October 2014 Parameter name FunctionUnitsDV EXLOCWhere the signal is injectedEnum 0 = Disabled 1 = PosTgtE 2 = PosRefE 3 = VelTgtE 4 = VelRefE 5 = TrqTgtE 6 = TrqRefE 6 EXTYPSignal typeEnum 0 = CONSTANT 1 = SQUARE WAVE 2 = TRIANGLE WAVE 3 = SAWTOOTH 4 = SINEWAVE 5 = WHITE NOISE 6 = PINK NOISE 6 EXOFFSignal offsetrad (EXLOC = 1,2) rad/s (EXLOC = 3,4) kNm (EXLOC = 5,6) 0.0 EXAMPNot used (EXTYP = 0) Signal amplitude (EXTYP = 1,2,3,4) Signal RMS (EXTYP = 5,6) rad (EXLOC = 1,2) rad/s (EXLOC = 3,4) kNm (EXLOC = 5,6) 0.05 EXFREQSignal frequency (only used when EXTYP = 1,2,3,4) Hertz0.01 EXDUTYSignal duty cycle (only used when EXTYP = 1) Adimensional0.5 Applications Signal Generator Provide excitation signals – reused from ESTAC project.
Instrument Control System Seminar, 20 th -24 th October 2014 Applications Signal Generator
Instrument Control System Seminar, 20 th -24 th October 2014 Applications Signal Generator Examples of signal generation
Instrument Control System Seminar, 20 th -24 th October 2014 Applications Derotator and ADC DROT: Compensate for field rotation – adapted from LCU implementation. ADC: Provides Automatic Atmospheric Dispersion Compensation.
Instrument Control System Seminar, 20 th -24 th October 2014 Applications Derotator Time Conversion Functions
Instrument Control System Seminar, 20 th -24 th October 2014 Prelimnary Conclusions + Simple adaptation of existing code. + CPU consumption when running C++ modules is very low. + Opens the door for implementing more advanced applications. + Communication module to module via input/output is very simple. - Development environment (XAE) is not yet a mature product. - Some problems with Object Ids when exporting C++ code with methods called from PLC code. - Beckhoff documentation is still rather poor in many areas.
Instrument Control System Seminar, 20 th -24 th October 2014 Live Demo