IST / DEEC / API
Industrial Automation
(Automação de Processos Industriais)
PLC Programming languages
Structured Text - Networking
http://users.isr.ist.utl.pt/~jag/courses/api1718/api1718.html
Prof. José Gaspar, 2017/2018
Page 1
IST / DEEC / API Chap. 3 - PLC Programming languages
Structured Text
Networking (in Unity Pro)
Keywords: MODBUS, READ_VAR, WRITE_VAR
Modbus is a serial communications protocol originally published by Modicon
(now Schneider Electric) in 1979 for use with its programmable logic
controllers (PLCs). Simple and robust, it has since become a de facto standard
communication protocol, and it is now a commonly available means of
connecting industrial electronic devices.
Examples of Field Bus (IEC 61158) standards: MODBUS (Schneider),
PROFIBUS (Field Bus type, Siemens), CAN bus (Controller Area Network,
1983 Robert Bosch GmbH), ...
Page 2
IST / DEEC / API Chap. 3 - PLC Programming languages
Structured Text Networking (in Unity Pro)
Modbus RTU — Binary representation of the data for protocol
communication. Includes CRC. Modbus messages are framed (separated) by
idle (silent) periods.
Modbus ASCII — Makes use of ASCII characters for protocol
communication.
Modbus TCP/IP or Modbus TCP — Modbus variant for communications
over TCP/IP networks, connecting over port 502.
RTU = Remote Terminal Unit
MTU = Main Terminal Unit
CRC = Cyclic Redundancy Check
TCP = Transmission Control Protocol
ASCII = American Standard Code for Information Interchange
Page 3
IST / DEEC / API Chap. 3 - PLC Programming languages
Structured Text
Networking (in Unity Pro)
Modbus Function type Function name / Function code
Physical Discrete Inputs Read Discrete Inputs 2
Bit access Read Coils 1
Internal Bits or Physical Coils
Write Single Coil 5
Page 4
IST / DEEC / API Chap. 3 - PLC Programming languages
Structured Text Networking (in Unity Pro) – READ_VAR
Address:
ADDR(STRING)
ARRAY [0..5] OF INT
Type of object to read:
’%M’ for reading internal bits
’%MW’ for reading internal words
’%S’ for reading system bits
’%SW’ for reading system words
’%I’ for reading input bits
’%IW’ for reading input words
Address of first object to read:
The possible objects are of the DINT type Reception zone:
(variables, constants, immediate value) The reception zone is an integer array.
The size of this array depends on the
Number of consecutive objects to read: number of objects to read. This integer
The possible objects are of the INT type array can be located or not.
(variables, constants, immediate value)
Report: The report is an array of 4
integers
Page 5
IST / DEEC / API Chap. 3 - PLC Programming languages
Structured Text Networking (in Unity Pro) – READ_VAR
Challenge: how to make READ_VAR non-blocking in an
operating system without using processes nor threads?
Page 6
IST / DEEC / API Chap. 3 - PLC Programming languages
Structured Text Networking (in Unity Pro)
Page 7