Getting started with the IP-S7-Link .Net Advanced MATLAB


The IP-S7-Link .Net Advanced MATLAB is a toolbox which uses the software driver framework IP-S7-Link .Net Advanced which does implement the whole internet protocol (IP) stack for Simatic S7 controllers. While the toolbox does provide simple read / write methods it does also target different advanced scenarios. Using this toolbox does not only bring the possibility to bind programmable logic controller (PLC) addresses to your MATLAB application. It does also provide mechanisms to link variables or whole structs to one or more PLC addresses of your PLC device and read / write them at once.

This section of the IP-S7-Link .Net Advanced MATLAB documentation provides information about basic application development tasks.

Operand

Name Abbreviation (Siemens, DE) Abbreviation(IEC)
Input E I
Output A Q
Flag M M
Peripherals P P
Counter Z C
Data Block DB DB
Timer T 16

Data types

Name Abbreviation Bit size Range Description Array
BOOL X 1 0 to 1 single bit representing true (1) or false (0) x
BYTE B 8 0 to 255 unsigned 8-bit x
WORD W 16 0 to 65.535 unsigned 16-bit (Word) x
DWORD D 32 0 to 232 -1 unsigned 32-bit (Double Word) x
CHAR B 8 A+00 to A+ff ASCII-Code unsigned 8-bit character x
INT W 16 -32.768 to 32.767 signed 16-bit integer x
DINT D 32 -231 to 231-1 signed 32-bit integer (Double Word) x
REAL D 32 +-1.5e-45 to +-3.4e38 IEEE754 32-bit single precision floating point number x
S5TIME W 16 00.00:00:00.100 to 00.02:46:30.000 binary coded decimal (BCD) number representing a time span
TIME D 32 00.00:00:00.000 to 24.20:31:23.647 signed 16-bit integer representing a time span in milliseconds
TIME_OF_DAY D 32 00.00:00:00.000 to 00.23:59:59.999 unsigned 16-bit integer representing a time span in milliseconds
DATE W 16 01.01.1990 to 31.12.2168 unsigned 16-bit integer representing a date in days
DATE_AND_TIME D 64 00:00:00.000 01.01.1990 to 23:59:59.999 31.12.2089 binary coded decimal (BCD) number representing a date and time
S7String B any A+00 to A+ff ASCII-Code, max. 254 Bytes

The variables are composed of operand and data type. Examples:

Examples Data type Example Siemens Example IEC
Input Byte 1, Bit 0 BOOL E 1.0 I 1.0
Output Byte 1, Bit 7 BOOL A 1.7 Q 1.7
Flag Byte 10, Bit 1 BOOL M 10.1 M 10.1
Data Block 1, Byte 1, Bit 0 BOOL DB1.DBX 1.0 DB1.DBX 1.0
Input Byte 1 BYTE EB 1 IB 1
Output Byte 10 BYTE AB 10 QB 10
Flag Byte 100 BYTE MB 100 MB 100
Peripherals Input Byte 0 BYTE PEB 0 PIB 0
Peripherals Output Byte 1 BYTE PAB 1 PQB 1
Data Block 1, Byte 1 BYTE DB1.DBB 1 DB1.DBB 1

Data Block 1, Data Block 1 Typ bool, Address 1.0 → DB1.DBX 1.0
Data Block 1, Data Block Typ Byte, Address 1 → DB1.DBB 1
Peripherals Input, Typ DWORD, Address 0 → PED 0

Help:
DB#.DBB # = Data Block#.Data Block Byte #
DB#.DBW # = Data Block#.Data Block Word #
DB#.DBD # = Data Block#.Data Block Doubleword #
# = Address