12 minute read

Chapter 2 • OpenPLC Editor Installation

Next Article
Introduction

Introduction

Index

Symbols

24 V output %IW0, %IX0, %MD0, %ML0, %MW0, %QW0, %QX0.0, %QX2.0 156

139

A

ABS access code access data access structure variables ACOS action action block actuators 87 14 164, 171 105 87 51, 110, 111, 112 114 120

ADC A/D converter AddCatalog Adding a contact Addition Add new device

159 124, 156 33 61, 64 87 153

address 17, 126

address range

137 address space 139 AdvancedHMI 26, 123, 129, 130, 132, 166 AJAX 143, 169 Aktion 169 alarm contacts 168 alternative branching 119 analog input 153, 159, 167 analog-to-digital 153 analog value 152 AND 67, 80, 83, 87 Android 15 ANY_TO_ 88 ANY_TO_BOOL 88 ANY_TO_DINT 88 ANY_TO_INT () 88 ANY_TO_REAL () 88 ANY_TO_SINT () 88 ANY_TO_STRING () 88 ANY_TO_TIME () 88 ANY_TO_UDINT () 88 ANY_TO_UINT () 88 ANY_TO_USINT () 88 archive ArduinoESP8266 Arduino HTTP Arduino IDE Arduino UNO Arduino UNO IDE settings Arduino UNO IDE upload array AS ASIN assembly language ATAN ATmega328P audio 32 162 169 147, 148, 162 10, 147, 148 149 150 96, 103 110 87 53, 76 87 147, 155 11

B

barcode Barcode printing base type Basic data types BCD_TO_BIN () Beremiz BIN_TO_BCD () Bit AND Bit Exclusiv OR Bit OR bit pattern Bitwise operations BlinkLed BlinkTimer Boardmanager branches breadboard BTN_HMI BTN_Modbus button button press 93 94 88 82 88 7 88 87 87 87 96 74 93, 94 91, 92 162 55 39 138 122, 125 92, 124 110, 125, 137

C

CASE CDC ACM

86 153

CH340 164

chart

55, 109, 146, 174 C_HTTP 141 Circuit diagram for the ESP8266 board 185 Class 58, 69

client

15, 120 clipboard 23, 50 Codeblocks, C_HTTPPOST01 140, 141 COM6 149 Commander 20 comment 83, 110 Common operator 87 Commport 149, 164 communication error counter 128 community 47 compatibility 8 compiled, compiler 134 configuration 17, 21 connect 140, 141 Connected to Server 150 connections 65, 111 contact 110 convergence 119 conversion operator 88 conveyor belt 93, 109 copy 50, 141 COS 87 counter 88 country and time zone selection 14 coupling relay 160 C program 140 Create a new variable 110 Create Program 50 CTD, CTU, CTUD 88 current limiting 42 Cutting objects 50

D

D/A Dashboard

124, 167, 180 39 data management 81 data type 58, 59, 69, 96, 100, 103, 107 DC output 156 Debug menu 48 declare, declaring 91 Declaring variables 59, 111 default value 83 define 111 definition 94 Description 28 desktop 17, 18 desktop sharing system DHT11/22 DINT direct voltage DIV divergence Division DNP3 DO WHILE download area driver, drivers DS18B20 15 159 82 156 80 118 80, 87 26 54 26 162, 164, 171 159

E

EasyModbusClient EasyModbusClientAndServer Editor ST file Edouard Tisserant EL816 optocouplers electronic switch elements ELSE ELSEIF

123, 150 123 35 7 159 42 102 86 85 empty project 33 enable SSH on the Raspberry Pi 18 END_CASE 86 END_FOR 83 END_IF 85 END_REPEAT 90 END_WHILE 84, 90 Entering the ENUM variables 107 ENUMs 106 equal 87 ESP8266 158, 162, 165, 186 ESP8266_HTTP_POST 171 ESP8266 I/O board 158 ESP8266 I/O module 168, 171 ESP8266_Modbus_BOARD1_1 162 ESP8266 NodeMCU Board Pins 172 Ethernet 11, 120 exclusive OR 80 existing project 50 EXIT 90 EXP 87 expression 82, 83 EXPT 87

F

falling edge Falling Edge Trigger FC1 FC2 FC3 FC4 FC5 FC6 FC15 88 89 124, 126, 140, 148, 152 124, 140, 148, 153, 179 148 148, 153, 179, 180 124, 148, 151, 152, 178 126, 148, 152, 180 179

FC16 field buses 152 26

file dialog

68 File Menu 45 File menu of the OpenPLC Editor 45 File Transfer Software WinSCP 18 FOR 82, 83 F_TRIG 88, 89 full screen 47 function block 9, 51, 52, 69, 72, 80, 81, 83, 88

Function Block example FUP 67 10

G

galvanic isolation gate gate controls gaugetest.html Generic ESP8266 Module 41, 155 67 109 174 163

Git Go to Dashboard

22 29 GPIO 8, 11, 42, 137, 159 Greater than, Greater than equal to 87

H

HDMI Hello_World HelloWorld.ST Help menu HITFET BSP76 home automation house HTML HTML server http post 11 33, 34, 36 36 47 41, 159 8, 120, 130 168 143 158 168, 171 humidity sensor 159

I

I2C 159

I2S Idle 159 167

IEC 61131-3 IEC address IEC programming languages IEC symbols IEEE 802.11

9, 88 59, 122 81 59 159

IF IL command overview 85, 87 80

IL program example Imager Imager program index.html

53, 77 13 12 143, 172

inductive and capacitive loads

42 industrial controllers 41 industrial control systems 8, 120, 130, 140 industrial environments 8 Infineon 42, 159 infinite-loop condition 85 initialization value 102 initial start 14 initial test 26 Inline 112 Input 113 Input circuit 157 inputs/outputs 111 installation 12, 120, 132, 139, 141, 167 instruction list 9, 51, 53 Instruction List example 76 Internet 140 I/O board 158, 159, 162, 166 I/O pins 147 IP address 14, 165 IX0.0 41

J

JavaScript function JavaScript-library Javascript objects JavaScript section jump with target 144, 171 173 145 170 115

K

KOP 10, 36, 37, 60

L

ladder diagram 51, 52, 55, 58, 60, 72 Ladder Logic 9 Ladder Logic Example 55 lamp 37, 41 LANGUAGE_DEFAULT 33 LANGUAGE_ENGLISH 33 LED 114 LedOK 94 Less equal 87 less than or equal 81 letters 82 library 47, 53 license 19 link inputs 90 LN 87 localhost:8080 24 LOG 87 login 25 loop 84, 90 low pass 156

M

machine MainForm.vb main menu MainTask Making connections Mario de Sousa Master-Slave principle mathematical calculations Matiec menu microcontroller micro SD card Microsoft Visual Studio minus MOD Modbus Modbus ADC Modbus addresses Modbus address mapping Modbus client 8 133 44 49 116 7 120 81 7, 10, 36, 67 44, 50 53, 76, 147 10, 12, 13, 14 130 58, 69 87 120 153 127 138 140 Modbus commands Modbus commands for the ESP8266 I/O module Modbus documentation Modbus ESP8266 module Modbus "FC" command Modbus interface 123

178 127 166 144 167

Modbus I/O modules

147 Modbus libraries 167 Modbus program for the Arduino 148 Modbus register 139, 152 Modbus RTU 120 Modbus RTU module 147 Modbus-RTU pin assignment 148 Modbus RTU RS485 multidrop network 158 Modbus server 26 Modbus settings 136 Modbus Slave 154 Modbus TCP 8, 120 ModbusTCP-DotNET-Master.zip 129 Modbus-TCP Master program 129 Modbus TCP module 159 Modbus TCP protocol 120 Modbus TCP Tester 129 Modicon 120 modifier 61, 62 modules 71, 72 Modulo 87 MomentaryButton 137, 138 monitoring 25, 29, 41, 79, 129, 155 monitors 120 Mono Framework 43, 130, 134, 139 motor 38, 41, 93 MotorDir 94 MotorLeft 107 MotorOff 107 MotorOn 94 MotorRight 107 MotorState 107 MUL 80 multiplexer 74HC151 166 Multiplication 80, 83, 87 my_button 37

N

name 58, 69

network New action block New branching New coil New connection New function block New jump New power line New project New variable Niklaus Wirth NodeMCU module NOT Notepad++ not equal NOT inverted 14, 24, 52, 55, 157 110 110 60 72, 110 60, 110 110 110 50, 57, 76, 90 72 54 158 80, 87, 92 33, 37, 74 81 87

O

opener 62 OpenPLC 32, 34, 36, 44, 46, 48, 57 OpenPLC Editor 32, 44 OpenPLC runtime 25 OpenPLC Runtime 23, 24, 25, 26 OpenPLC Runtime page 24 OpenPLC_Uno 148 OP LM7301 156, 159 optocoupler 41, 42, 156, 159, 179 OR 67, 80, 83, 87 output 111, 113, 124 output pins 122 overtemperature 42 overvoltage 42

P

Parallel branching Pascal password Pasting objects PHP program PHP server program PilotLight pin assignment PIP PLCAdressClick PLC Editor 118 54, 81 14, 17, 25, 38 50 143, 144, 169, 170 168, 169 137 38, 148 167 138 136

PLC-Example-ConveyorBelt 94 PLC-Example-FBD PLC-Example-FUP PLC-Example-KOP

68 68 121

PLC program 9, 25, 120

PLC programming

8, 76 PLC ST-Program 28 plus symbol 97, 100, 102, 103, 104 position 93 Power Rail left and right 60 power supply rails 55 power supply socket 147 Prepare Coils 126 Prepare Registers 126 processing units (POUs) 81 process via monitors 140 process visualization 140 production lines 109 product version 46 program block 90 program comments 116 program cycle 49, 109 program flow 109 program generated by the compiler 116 program interval 49 program monitoring 129 Program Organization Unit 81 program runtime 49 program sequences 110 program step 114 program upload 164 project 33 project directory 73 project name 69 project properties, settings 46 protection mechanisms 42 proximity switch 94 Pulse Timer 89 PWM 124, 148 PWM LED 126 PWM output 38, 41, 126 PWM register 127 PyModbus 167 pymodbus_openplc_post.py 140 PythonModbus 167 python_modbus_client_tkinter_esp8266.py 167

Python program Python test program

Q

qualifier QX0.0 140 167

112, 113 41

R

Raspberry Pi Raspberry Pi Documentation

120 14 Raspberry Pi Imager 12 Raspberry Pi Modbus Slave settings 154 Raspberry PI ModbusTCP server 123 Raspberry PI Monitor 128 Raspberry Pi OS (32-bit) 13 Raspberry Pi PLC 130 Raspberry Pi's IP address 21 Raspberry Pi (VNC Server) 15 Raspberry Pi Zero W 11 RaspiTestBoard 124 Read Coils 179 reading outputs 125 Real 82, 102 Reference 98, 101 register 124, 139, 180 relay 34 relay coil 56 relay contact 64 relay outputs 8 REPEAT 90 REPEAT Cycle 84 REPEAT UNTIL 54 RESET 69, 88 Reset value 80 RETURN Instruction 90 reverse-polarity protection 157 RISC CPU 159 rising edges 88 Rising Edge Trigger 89 ROL 87 ROR 87 RS 88 RS-232 120 RS-485 interface 158 RS-485 network 120 R_TRIG 88, 89 Run in terminal RUN Mode running light runtime library runtime program 142 26 26 7 38

S

Save As Save Changes Save device scan cycles Schneider semicolon sensor SensorLeft

50 26 154 128 120 83, 92 120 94

SensorRight

94 sequence control 8, 109 sequential function chart 9, 51, 110 Sequential Function Chart example 109 Sequential Function Chart (SFC) 55 Serial Monitor 165 server 38, 120 SET 69 settings 25, 26, 46 SFC 9, 51, 55, 109 SFC program blocks 115 SFTP client 18 SHL 87 SHR 87 simple state machine 110 SIN 87 Slave Devices 153 Small 87 software architecture 9 SPI 159 sqlquery.php 143, 172 SQRT 87 SR 88 SR flipflop 69 SSH configuration 18 ST 80 ST array type listing 100 start condition 110, 111 start screen 32, 44 start value 84 Statements 82

ST code step ST example ST example data type ENUM ST example structure ST file ST file listing STL files 37 110, 113 89, 93 107 103 27, 50 67 93

ST Listing

75 ST listing structure 103 ST listing with structure and arrays 106 STN 80 ST program 29 ST project save function 36 ST project (structured text) 50 Structured control language 54 structured data types 100, 103 Structured Text 9, 51 Structured Text examples 81 structure tree 44 structure variable 105 SUB 80 Substraction 87 sudo apt-get install git 22 switch 124 symbols 55, 67, 98, 109, 110 system 168 system language 33

T

tabs 83

TAN 87

task settings

73 temperature 159 temperature and humidity sensor 159 Tensilica 159 terminal window 23, 30, 141, 153 test board 29, 39, 138, 181, 182, 183, 184 Test Board 40 Testing PLC programs with Modbus TCP 120 T-flip flop 110 Thiago Alves 7 time interval 113 timer 110, 137 Timer On 89 TimerReady 92 timestamp time zone selection TOF TON Tools TP transistor transition transition condition translate translation translation completed transmit TRUNC type 128 14 89 89, 91, 92 163, 165 89 42, 155 55, 110, 114 113 10, 35, 66, 72, 74 96 96 178, 179, 180 87 58, 69, 82

U

UART underscore Unipi 1.1 Unix epoch Unix timestamp UNTIL upload USB USB ID on the Raspberry Pi USB-RS485 interface USB-Serial converter user-defined data types user interface username 159 58, 69, 82 8 128 128 84 10, 166 11 153 157 164 98 10, 20, 47 14, 17

V

value variable variable list Variable names 80 113, 120 136 82

version 2.52 version number "View" menu 30 28 47

visualize processes

10 Visual Studio 43, 134 Visual Studio Community software 130 Visual Studio Installer 132 Visual Studio Toolbox 135 Visual Studio user interface 133

VNC Server VNC viewer VNC Viewer credentials VNC Viewer installation VNC Viewer start menu voltage divider 15 15, 22, 141 17 15 16 42, 157, 159

W

web browser 24, 140, 143, 144, 169, 170 web host 168 web interface 24, 26, 38, 41, 79, 153, 168 web page 170, 171 web server 24, 38, 140, 143, 171 Web server application 168 website 167, 172 WEP 159 WHILE 84, 90 WIFI 159 WinSCP 18, 20, 21, 22, 139, 141 WiringPI library 30 WLAN 14, 120, 158, 159, 168 working directory 162 worksheet 60, 69, 77, 111 world 140 Write 13 Write Multiple Coils 179 Write Single Coil 178 Write Single Register 180

X

XOR 80, 87, 92

Z

ZIP 131

PLC Programming

with the Raspberry Pi and the OpenPLC project

ModbusRTU and ModbusTCP examples with the Arduino Uno and ESP8266

Introduction to PLC programming with OpenPLC, the fi rst fully open source Programmable Logic Controller on the Raspberry Pi, and Modbus examples with Arduino Uno and ESP8286

PLC programming is very common in industry and home automation. This book describes how the Raspberry Pi 4 can be used as a Programmable Logic Controller. Before taking you into the programming, the author starts with the software installation on the Raspberry Pi and the PLC editor on the PC, followed by a description of the hardware.

You'll then find interesting examples in the different programming languages complying with the IEC 61131-3 standard. This manual also explains in detail how to use the PLC editor and how to load and execute the programs on the Raspberry Pi. All IEC languages are explained with examples, starting with LD (Ladder Diagram) over ST (Structured Control Language) to SFC (Special Function Chart). All examples can be downloaded from the author's website.

Networking gets thorough attention too. The Arduino Uno and the ESP8266 are programmed as ModbusRTU or ModbusTCP modules to get access to external peripherals, reading sensors and switching electrical loads. I/O circuits complying with the 24V industry standard may also be of interest for the reader.

The book ends with an overview of commands for ST and LD. After reading the book, the reader will be able to create his own controllers with the Raspberry Pi.

Josef Bernhardt became interested in electronics at a very young age, when he built his fi rst detector receiver, followed over the years by many other circuits.

He gained his fi rst programming experience in the 1980s with the Commodore VC20. He became familiar with assembler programming on the 8088 processor.

Josef can look back on more than 30 years of electronics and software development at University of Regensburg.

With his own SMD production, he also implements electronic customer projects, always driven by the pleasure of electronics and programming.

Elektor International Media www.elektor.com

This article is from: