Guide for elektor models including: DSO3D12 Modular and Scalable Control Systems, DSO3D12, Modular and Scalable Control Systems, Scalable Control Systems, Control Systems, Systems

Excited for the Zeeweii DSO3D12 Oscilloscope – Elektor

Your Store for Raspberry Pi, Arduino & ESP32 | Elektor


File Info : application/pdf, 6 Pages, 631.09KB

PDF preview unavailable. Download the PDF instead.

Contents Object-Oriented PLC Programming in CODESYS
Object-Oriented PLC Programming
in CODESYS
Modular and Scalable Control Systems Using Structured Text
Academy Pro Title by
Majid Pakdel

Object-Oriented PLC Programming with CODESYS

Majid Pakdel

Object-Oriented PLC Programming with CODESYS

 This is an Elektor Publication. Elektor is the media brand of
Elektor International Media B.V. PO Box 11, NL-6114-ZG Susteren, The Netherlands Phone: +31 46 4389444
 All rights reserved. No part of this book may be reproduced in any material form, including
photocopying, or storing in any medium by electronic means and whether or not transiently or incidentally to some other use of this publication, without the written permission of the copyright holder except in accordance with the provisions of the Copyright Designs and Patents Act 1988 or under the terms of a licence issued by the Copyright Licencing Agency Ltd., 90 Tottenham Court Road, London, England W1P 9HE. Applications for the copyright holder's permission to reproduce any part of the publication should be addressed to the publishers.
 Declaration

The authors and publisher have used their best efforts in ensuring the correctness of the

information contained in this book. They do not assume, or hereby disclaim, any liability to

any party for any loss or damage caused by errors or omissions in this book, whether such

errors or omissions result from negligence, accident or any other cause.

 British Library Cataloguing in Publication Data

A catalogue record for this book is available from the British Library

 ISBN 978-3-89576-696-1

Print

ISBN 978-3-89576-697-8 eBook

 © Copyright 2024 Elektor International Media

www.elektor.com

Editor: Glaucileine Vieira

Prepress Production: Elektor

Printers: Ipskamp, Enschede, The Netherlands

Elektor is the world's leading source of essential technical information and electronics products for pro engineers, electronics designers, and the companies seeking to engage them. Each day, our international team develops and delivers high-quality content - via a variety of media channels (including magazines, video, digital media, and social media) in several languages - relating to electronics design and DIY electronics. www.elektormagazine.com
 4

Contents
Contents
Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Chapter 1 · Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
1.1 The Object-Oriented Programming for PLC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9 1.2 The CODESYS Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 Chapter 2 · The Structured Text (ST) Programming Language . . . . . . . . . . . . . . . . 12 2.1 Conditional Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 2.2 Calling the Standard Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 2.3 The Finite State Machine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 2.4 The Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 2.5 The Loops. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 2.6 The Non-Instantiated Function Principle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 2.7 The Non-Instantiated Function Demo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 2.8 Writing an Expandable PLC Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 Chapter 3 · The Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 3.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 3.2 The Class Demo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58 3.3 The Structured Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 3.4 The Structured Variables Demo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 3.5 Passing Structures to the Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 3.6 The Structure Pass Demo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 3.7 The Array of Structures and Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 3.8 The Array of Objects Demo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 3.9 Calling Multiple Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 3.10 The Sequence Activation Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 Chapter 4 · The Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 4.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 4.2 The Methods Demo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92 4.3 The Methods Parameters Pass . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
 5

Object-Oriented PLC Programming with CODESYS
4.4 The THIS Keyword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108 4.5 The THIS Keyword Demo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109 4.6 The Wrappers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 4.7 The Wrappers and Method to Method Passing Demo . . . . . . . . . . . . . . . . . . . . . 117 4.8 Two Production Lines for the Sequence Activation Project . . . . . . . . . . . . . . . . . . 127 Chapter 5 · The Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152 5.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152 5.2 The Property Software Demo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154 5.3 The Properties as IO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159 5.4 The Properties as IO Demo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160 Chapter 6 · The Inheritance and Polymorphism . . . . . . . . . . . . . . . . . . . . . . . . . . 165 6.1 The Inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165 6.2 Inheritance Demo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167 6.3 The Deep Inheritance. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180 6.4 The Method Override . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183 6.5 The Override and Super Keyword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185 6.6 The Polymorphism . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189 6.7 The Polymorphism Software Demo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191 Chapter 7 · The Access Specifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195 7.1 The Public. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195 7.2 The Private . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196 7.3 The Protected . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198 7.4 The Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199 7.5 The Application Demo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201 Chapter 8 · Interfaces and Abstractions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218 8.1 The Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218 8.2 The Interface Software Demo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220 8.3 The Interfaces Vs Inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223 8.4 The Multiple Interfaces Demo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228 8.5 The Interfaces and Polymorphism . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235 8.6 The Interfaces and Polymorphism Demo. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237 8.7 The Object Composition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243
 6

Contents Chapter 9 · The Delegation and Advanced FSM . . . . . . . . . . . . . . . . . . . . . . . . . . . 248
9.1 The Delegation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248 9.2 The Object Pointers and References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251 9.3 The Object Pointers and References Demo . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254 9.4 Advanced FSM Pointers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258 9.5 The FB_INIT Constructor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260 9.6 Advanced FSM Demo Part 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262 9.7 The Transitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269 9.8 Advanced FSM Demo Part 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271 9.9 The State Initializer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282
 7



References

Adobe InDesign 20.5 (Macintosh) iLovePDF

Related Documents

Preview C# Programming for Windows and Android
A comprehensive guide to C# programming for developing applications on Windows and Android platforms using Visual Studio. This book covers core language features, object-oriented programming, UI development, debugging, and advanced topics like databases and multimedia.
Preview Advanced Programming with STM32 Microcontrollers
A comprehensive guide detailing advanced programming techniques for STM32 microcontrollers, covering essential peripherals, development environments, and practical project implementations.
Preview Programming the Finite State Machine with 8-Bit PICs in Assembly and C
A comprehensive guide to programming finite state machines using 8-bit PIC microcontrollers in both Assembly and C languages. Covers fundamental concepts, practical implementation, hardware construction, troubleshooting, and comparisons between assembly and C programming.
Preview PLC Programming with Raspberry Pi and OpenPLC: Modbus Examples
A comprehensive guide to PLC programming using the Raspberry Pi and OpenPLC project, featuring ModbusRTU and ModbusTCP examples with Arduino Uno and ESP8266.
Preview C Programming on Raspberry Pi
A comprehensive guide to C programming on the Raspberry Pi, covering operating system setup, development tools, C language concepts, hardware interfacing with GPIO, I2C, SPI, and various practical projects involving LEDs, LCDs, and sensors.
Preview Coding Modbus TCP/IP for Arduino: Example Projects with Node-RED, MQTT, WinCC SCADA, Blynk, and ThingSpeak
This guide provides practical examples for implementing Modbus TCP/IP communication with Arduino. It covers setting up hardware, programming Arduino, and integrating with platforms like Node-RED, MQTT, WinCC SCADA, Blynk, and ThingSpeak for industrial automation and IoT applications.
Preview Grafisch programmieren, messen und steuern mit PROCESSING
A comprehensive guide to graphical programming, measurement, and control using the Processing language, authored by Kurt Diedrich. This document covers fundamental concepts, user interactions, data handling, and provides practical programming examples, including Arduino integration.
Preview Visual Basic Express 2010 Programming Guide - Table of Contents
A comprehensive table of contents for a guide on Visual Basic Express 2010 programming, covering fundamentals, toolbox objects, variables, graphics, data handling, and more.