PLC Programming with the Raspberry Pi and the OpenPLC Project.pdf
(
30060 KB
)
Pobierz
books
with the
Raspberry Pi
and the
OpenPLC project
ModbusRTU and ModbusTCP examples
with the Arduino Uno and ESP8266
PLC
Programming
Josef Bernhardt
PLC Programming
with the Raspberry Pi
and the OpenPLC Project
ModbusRTU and ModbusTCP examples using the Arduino Uno and the ESP8266
●
Josef Bernhardt
●
This is an Elektor Publication. Elektor is the media brand of
Elektor International Media B.V.
Phone: +31 46 4389444
PO Box 11, NL-6114-ZG Susteren, The Netherlands
●
All rights reserved. No part of this book may be reproduced in any material form, including photocopying, or
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.
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
●
Declaration
cause.
The Author and the Publisher have used their best efforts in ensuring the correctness of the information contained
in this book. They do not assume, and 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
●
British Library Cataloguing in Publication Data
●
ISBN 978-3-89576-469-1
ISBN 978-3-89576-470-7
Editor: Denis Meyer
Print
eBook
A catalogue record for this book is available from the British Library
●
© Copyright 2021: Elektor International Media B.V.
Prepress Production: D-Vision, Julian van den Berg
Elektor is part of EIM, 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
Content
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Chapter 1 • Installing the Raspberry Pi 4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
1.1 Hardware description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
1.2 Installing the operating system . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
1.3 Installing the VNC Viewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
1.4 Installing the File Transfer Software WinSCP . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
1.5 Installing the openplcproject runtime . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Chapter 2 • OpenPLC Editor Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
2.1 Download and Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
2.2 Raspberry Pi pin descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
2.3 Additional Hardware I/O Test Board . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
2.4 Additional 24 V PLC Board hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
Chapter 3 • The OpenPLC Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
3.1 Description of the OpenPLC Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
3.2 Ladder Logic Example (LD) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
3.3 Function Block example (FBD). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
3.4 Instruction List example (IL). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
3.5 Structured Text examples (ST, SCL). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
3.5.1 Variable. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
3.5.2 Control structures. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
3.5.3 Conversion operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
3.5.4 Standard function blocks according to IEC 61131-3 . . . . . . . . . . . . . . . . . . 88
3.5.5 First ST program example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
3.5.6 ST example for controlling a conveyor belt . . . . . . . . . . . . . . . . . . . . . . . . 93
3.5.7 Defining arrays with the OpenPLC Editor . . . . . . . . . . . . . . . . . . . . . . . . . . 96
3.5.8 Defining structures with the OpenPLC Editor . . . . . . . . . . . . . . . . . . . . . . 100
3.5.9 Combining structures with arrays using the OpenPLC Editor. . . . . . . . . . . . 103
3.5.10 Definition of ENUMs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
3.6 Sequential Function Chart example (SFC) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
Chapter 4 • OpenPLC and the Modbus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
4.1 Testing PLC programs with Modbus TCP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
●
5
PLC Programming with the Raspberry Pi and the OpenPLC Project
4.2 Visualization of PLC programs with AdvancedHMI . . . . . . . . . . . . . . . . . . . . . . . 130
4.3 Visualization of PLC programs via the Internet . . . . . . . . . . . . . . . . . . . . . . . . . 140
Chapter 5 • Modbus I/O modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
5.1 Modbus RTU module with the Arduino UNO. . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
5.2 Modbus TCP module with the ESP8266 and WLAN . . . . . . . . . . . . . . . . . . . . . . . 158
5.3 Web server application with the ESP8266 I/O module . . . . . . . . . . . . . . . . . . . . 168
Chapter 6 .1 • Bibliography, circuit diagrams and layouts . . . . . . . . . . . . . . . . . . . 175
6.2 Web links . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176
6.3 Modbus commands for the ESP8266 I/O module . . . . . . . . . . . . . . . . . . . . . . . . 178
6.4 Circuit diagrams and layouts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
6.4.1 Circuit diagram for the test board with buttons and LEDs: . . . . . . . . . . . . . 181
6.4.2 Circuit diagram for the test board with 24V input outputs: . . . . . . . . . . . . 183
6.4.3 Circuit diagram for the ESP8266 board with 24V input outputs: . . . . . . . . . 185
Index
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
●
6
Plik z chomika:
destroyer30
Inne pliki z tego folderu:
RaspberryPiofficialmagazine-April2025.pdf
(74064 KB)
RaspberryPiOSSystemAdministrationwithsystemd.pdf
(14598 KB)
Explore the Raspberry Pi in 45 Electronics Projects, 3rd Edition.pdf
(8926 KB)
Getting Started With Raspberry Pi, 4th Edition (Make).pdf
(26948 KB)
Gates J. Raspberry Pi Basics. A Beginners Guides 2023.pdf
(1907 KB)
Inne foldery tego chomika:
AndroidBOX_MXQ4_RK322X
DiagBox_Peugeot_Citroen
Dokumenty
Driver
Firefox-dla-xpeka-ostatnia-działająca wersja
Zgłoś jeśli
naruszono regulamin