PLC
The PLC module is a Special module used to interact with programmable logic controllers (PLC). These industry grade CPUs are used for controlling machines and plants. They typically allow to write/read certain registers or datablocks using a variety of protocols.
PLC is a Pro module.
Handling
After selecting the protocol, such as "Modbus TCP", you can enter the Port for communication and the protocol-related options. Then, you can begin to fill the table of registers. Either add rows on your own via the right-click menu or load a CSV file. When saving the table, all fields are saved again in the specified CSV file. Thus, the CSV file contains the general description of all readable/writable addresses in the PLC and can be used to quickly restore a machine-register description.
The right-click menu of the register table offers:
- Add empty row: adds an empty row below the selected row.
- Remove selected row(s): removes the selected rows.
- Write value: reads the current value of the selected register and opens a dialog to write a new value to the PLC.
- Read value: reads the selected register once and shows the value.
"Write value" and "Read value" can be used for testing purposes when no run is active. During a run, you can set fixed values or use the curly parameter syntax to change values dynamically (see column "Set Value").
Click the button "File" at the right of the file field above the register table to manage the CSV file:
- Load... loads a CSV file.
- Reload loads the current CSV file again.
- Save and Save as... save the register table to a CSV file.
- New creates an empty table.
- Open in editor opens the current CSV file in a text editor.
- Open in explorer opens the folder of the current CSV file.
If the table contains unsaved changes, the button shows "File*". A run can only be started after the register table has been saved. If the CSV file is changed by another program, SweepMe! asks whether the file should be reloaded.
Register columns
- Variable: mandatory, the name of the parameter as shown in SweepMe!
- Unit: optional, the unit related to the variable
- Machine Tag: optional, the tag name of the register, address or datablock as defined in the PLC setup software or your electrical machine plan. Only used as a reference.
- Address: mandatory, the number of the register or a string specifying an address or node. This will be used to read/write a parameter.
- Data Type: mandatory, the data type, e.g. BOOL, INT or REAL as which the retrieved data is interpreted.
- Endianness: optional, the word order of values that span two registers (REAL). "Standard" (default, big endian) sends the high word first, "Word Swap" swaps the two 16-bit words. Leave the field empty to use "Standard".
- Set Value: optional, a field to enter a fixed value or a parameter using the Parameter system in order to write a value to the PLC whenever the value changes during the run. This information is not saved to the CSV file but to the sequence file (setting file in SweepMe! 1.5), as the CSV file only contains machine and protocol related information.
- Comment: optional, just a comment that helps you to understand the meaning of the register/address.
You can add empty lines to structure your registers into meaningful blocks. They will be omitted later on.
Each register is returned as a measurement variable with the name given in the column "Variable" and is read at each measurement point.
CSV file
The register table is represented by a CSV file that helps you to reload all registers when you add a new PLC module. The CSV file format of the PLC module uses a comma as cell delimiter. The header line contains the column names Variable, Unit, Machine Tag, Address, Data Type, Endianness, and Comment.
You can use programs like Microsoft Excel, Google Sheets, or LibreOffice Calc to fill these files and load them with the PLC module for faster processing, or create these files programmatically. Please note that regional settings must match the comma as delimiter because otherwise the file will, for example, be saved with semicolons.
Attention: Register addresses starting with 0 like "0xxxx" should be treated as text, not as numbers. Otherwise, the leading zeros might be lost while saving the file and some protocols, such as Modbus, cannot handle the address correctly anymore.
Protocols
Modbus
Basically, all sensors, actuators, and controllers can be connected with the PLC module if they support the Modbus TCP protocol. So, not only PLCs are supported.
Options
- Port: Enter the IP address of the PLC or Modbus device, e.g. "192.168.0.1". A TCP port can be added in the format IP:port, e.g. "192.168.0.1:502". If no port is given, the Modbus default port 502 is used.
- Register start: Some PLCs start counting registers from 0 and others from 1. The default is 0. If you see that all readings are off by one address, changing the Register start might help.
The word order of REAL values can be set per register in the column "Endianness". The byte order within each 16-bit register is always big endian.
Data types
The user must specify as which data type the readout register should be interpreted. Supported are:
- INT (2 bytes, 1 register)
- UINT (2 bytes, 1 register)
- WORD (2 bytes, 1 register)
- BOOL (1 coil or discrete input)
- REAL (4 bytes, 2 registers)
Register address regions
The PLC module will automatically read/write different register address regions based on the first digit of the register address. It can handle 5-digit addresses as defined by Modbus but also 6-digit register addresses as used in some PLCs.
Coils "0xxxx"
- all registers, starting with 0
- Supported Data Type: BOOL
- returns a bool (True/False)
- writable/readable
Discrete Inputs "1xxxx"
- all registers, starting with 1
- Supported Data Type: BOOL
- returns a bool (True/False)
- only readable
Output registers "2xxxx"
- all registers, starting with 2
- Supported Data Type: INT, UINT, WORD, REAL
- returns different data types as defined by the user (INT, UINT, WORD, REAL)
- writable/readable
Input registers "3xxxx"
- all registers, starting with 3
- Supported Data Type: INT, UINT, WORD, REAL
- returns different data types as defined by the user (INT, UINT, WORD, REAL)
- only readable
Holding registers "4xxxx"
- all registers, starting with 4
- Supported Data Type: INT, UINT, WORD, REAL
- returns different data types as defined by the user (INT, UINT, WORD, REAL)
- writable/readable
OPC UA
Planned, but not yet available. Please contact us at contact@sweep-me.net if you would like to use it.