This highly configurable CNCnetPDM device driver enables monitoring and output of machine-, process- and quality data from various Programmable Logic Controllers (PLC) and electronic devices with Ethernet connection and Modbus protocol support. It also allows to control these devices by its ability to set or change their program parameters.
For bidirectional communication between PLCs connected to CNCnetPDM and your applications you can use our free Open Source Client (C-Sharp)
You can dynamically define your own set of items (up to 30) that can be enabled and disabled on a per-device basis by an INI file that is automatically created with reasonable default values. This INI file also allows to define standardized, comparable tag names for devices from different vendors.
Download the PLC device driver and extract all content into the folder where you have CNCnetPDM installed.
Edit CNCnetPDM.ini and add an additional device as described in the quick start guide point 6. Change the line similar to the following (adjust device name, IP Address or DNS Hostname according to your needs):
FIG 1: Configure PLC device driver in CNCnetPDM.ini
For PLCs the following 2 parameters are important:
Right to the IP Address of the controller (here 192.168.1.212) enter the TCP port number used for communication (default: 502)
Change the driver name to mbus.dll and save CNCnetPDM.ini.
USAGE
Start CNCnetPDM, foreground program is sufficient (Start thread)
CNCnetPDM automatically copies the original mbus.dll and appends the device number as configured in the INI file, e.g. mbus_1000.dll for equipment number 1000.
In addition an INI file with the same name is automatically created by the device driver, e.g. mbus_1000.ini.
Double click CNCnetControl, the output should be similar to the one below:
Here the PLC (1) shows up as connected (2) which is good. On the right side (3) you see the acquired data:
The line starting with ‘A’ contains items defined in the device INI file that should be output to section 2, ‘O’ goes to section 1, Z is the part counter value and E the OEE device state.
If you didn’t change the INI file you get something like the following:
1001 12/05/2023 09:13:25 AM 10000000612 A REG|+400|INR|+0| 1001 12/05/2023 09:13:25 AM 10000000612 O BIT|1|INB|0| 1001 12/05/2023 09:13:26 AM 10000000613 E 5 1001 12/05/2023 09:13:26 AM 10000000613 Z 400
Every item has a tag name, here BIT and INB, followed by its tag value. Items in sections have names and values delimited by pipe ‘|’ symbols. This allows CNCnetPDM to create a database record, MTConnect and/or OPC UA output for each item. Tag names for part counts and OEE states can be defined in CNCnetPDM.ini.
With an unmodified INI file the initial configured items are:
Section
TAG Name
Description
Active
DEVICE STATE
STATUS
OEE Device state (numeric), output Tag name defined in CNCnetPDM.ini
Yes
PART COUNTER
COMP_QTY
Part counter value (numeric) , output Tag name defined in CNCnetPDM.ini
Yes
0
BIT
Status of bit (aka ‘coil’) at PLC address 1, either 0 or 1
Yes
1
INB
Status of physical digital input 1 of the connected device, either 0 or 1
Yes
2
REG
Numeric value of register at PLC address 1
Yes
3
INR
Numeric value of analog input 1 of the connected device
Yes
FIG 3: Ids, tag names, description and initial activation state of items
ADJUST ITEMS
This device driver enables to dynamically add, group, enable or disable items and change their names. The INI file automatically created by the device driver for every PLC contains sections that allow you to control its behavior.
Section [GENERAL]
Contains information about global parameters used by the driver on startup.
Commands defines the number of all commands you’d like to use for reading, maximum value = 30. Adjust when adding commands.
Operation timeout ms., time after which an active reading or writing operation is canceled if not completed, default 500 = 0.5 seconds.
Section [ALIVE]
Contains a command and PLC address that is used to determine if the device is reachable. If no data can be read from this address by using the command the driver assumes that the device is down and automatically disconnects and tries to reconnect after the time specified in CNCnetPDM.ini. Read status of bit at address 1 should work for almost any device.
Section [DEVICE STATE]
Contains a command and 4 PLC addresses that are used to detect the OEE device state. Initially status (0 = off /1 = on) of physical digital inputs 1 to 4 of the connected device is read with command ‘readinputbits’.
If Input 1 = on the driver reports OEE state 2 (Production)
If Input 2 = on the driver reports OEE state 3 (Manual)
If Input 3 = on the driver reports OEE state 4 (Interrupted)
If Input 4 = on the driver reports OEE state 5 (Error)
If all inputs are off the driver outputs OEE state 5 (Error)
Inputs are ordered by priority. In case two or more inputs are on at the same time the driver outputs the state of the last input with state on. Means in practice that, if Input 1 and 3 are on the driver outputs OEE state 4 (interrupted).
All available commands for reading can be used to detect the OEE device states. If you use a command that reads numeric values from registers all results > 0 are treated as 1 (on). To get correct results make sure that only one address reports 1 (on) at the same time.
Section [PART COUNTER]
Contains a command and PLC address that is used to read part counter values. Typically a register that stores the result of a counting operation is used.
Numeric sections [0] -> [29]
These sections can be used to freely define data acquisition items. To add an item you can simply copy and paste one of the existing sections, adjust its content, assign a new numeric section identifier and increase the number of commands in section [GENERAL].
Description of a numeric section:
Entry
Description
[1]
Section identifier, numbers from 0 to 29 can be used
Active
If you set this to 0 the command is not executed
Name
A short tag name (max 5 characters) to describe the item e.g. INB for input bit value. If you query more than one value with a single command it is recommended to only use 3 characters for tag name as the driver automatically appends a sequential number for each value read e.g. INB1 -> INB10
Comment
A comment that describes the command (optional)
Command
Command to be executed e.g. readregisters to read one or more register values
Start address
First PLC address to be queried by the selected command
End address
Last PLC address to be queried by the selected command
Divisor
Divides output values by the specified number if necessary
Output item
Reserved for future extensions
Output section
You can output data to 3 sections that may contain up to 256 characters. 1 goes to section ‘O’, 2 to ‘A’ and 3 to ‘F’. If data in one section exceeds the maximum length you can send items to a different section. Make sure you have entries CollectOrders, CollectFeeder and CollectQuality enabled (=1) in CNCnetPDM.ini.
FIG 4: Description of a numeric device INI file section
Note: To change commands, switch items on or off or alter its name while CNCnetPDM is running open the device INI file with a text editor, make the desired changes and save the file. To apply the changes immediately you can click on the device in CNCnetControl on the left side followed by clicking buttons ‘Close’ and ‘Open’ above the section ‘Devices’.
COMMANDS
Below you can find commands for reading data that can be used with this driver.
Command
Description
readbits
Reads the status (0/1) of one or more bits (aka coils) from start- to end-address. Reading of bits only makes sense if the value at the specific address is maintained by the PLC program, otherwise you just get 0.
readinputbits
Reads the status (0/1) of one or multiple physical digital inputs of the remote device from start- to end-address
readregisters
Reads the numerical values of one or more holding registers from the selected address range. Values of holding registers read by this command have to be maintained by the PLC program, otherwise the output is 0
readinputregisters
Reads the numerical values of one or more physical analog inputs from start- to end-address
FIG 5: Description of available commands for reading
TIPS
If you want to add additional items (up to 30 in total) first adjust the number of commands in section [GENERAL]. Then, copy and paste a complete numeric INI file section, adjust the section number and its content and save it.
TEST WRITING OPERATIONS
It is highly recommended to test any writing operation to PLCs before using them in a production environment with the device driver. For verification that you can access and write PLC bits and registers you should first use the tool ModbusGui To test with the device driver proceed as follows:
FIG 6: Write single register value to PLC (CNCnetControl)
In CNCnetControl select the device (1) at the left side
After clicking on button [Command] (2), an additional dialog opens.
Select the number (3) of one of the available write commands followed by 3 items (4) delimited by pipe symbols ‘|’ Clicking on [OK] (5) writes the value to the selected address. Examples:
Command
Nr.
Input
Comment
writebit
6
1|1|0
Sets bit (coil) status at address 1 to 0
writebits
7
1|5|1
Sets status of bits (coils) from address 1 to 5 to 1
writeregister
8
2|2|455
Sets value of single holding register at address 2 to 455
writeregisters
9
2|5|33
Sets values of holding registers from address 2 to 5 to 33
FIG 6: Format and examples of writing commands
The first item in input is the start- followed by the end-address and the desired value.
* device|1000|command|7|1|5|1 (sets status of bits from address 1 to 5 to 0)
To verify the result you can either define sections to read these values in your device INI file or check with ModbusGui.
LICENSING
This device driver requires the most recent version of CNCnetPDM and also works with a free license. However, in this mode you can only read bits from the remote device. With a valid license you are able to read physical digital and analog inputs, registers and output the result of up to 30 queries per reading cycle, see licensing for details.
TROUBLESHOOTING
The device driver writes a log file entry for any communication issue to the log file of the device. The file can be found in subdirectory \log of your CNCnetPDM program folder. The file format for the log file is log_ + device number + _ + date.txt. Please check this file first if you observe an issue. Deactivate commands with issues by setting them to ‘Active = 0’.
If, in CNCnetControl, the remote device shows a red icon, state disconnected and you get just output E = 0 the PLC is not reachable at all. This has nothing to do with CNCnetPDM, it’s a network issue, DNS Hostname or IP Address is wrong.
If, in CNCnetControl, the PLC also shows a red icon, state connected but you only get output E = 1 the device is reachable (ping-able) but it does not respond to commands, check your controller setup and the parameters used in CNCnetPDM.ini (esp. port number). Please use the tool ModbusGui to check if the PLC replies to commands.
If you try to communicate with a remote PLC that is already connected to a different PC the connection succeeds but you only get output ‘Error: No error’ in the device log file. In this case add and use a different TCP port or disconnect the other PC from the PLC.
If you get numeric device OEE states but not any of the preconfigured items please make sure that entries CollectOrders, CollectQuality and CollectFeeder are set to 1 in section [General] of CNCnetPDM.ini.
If specific items are not acquired check first with ModbusGui that you get output. Also make sure that the numeric section of the item in the device drivers INI file is activated and has an entry for ‘Name’, inactive or items with empty names are not acquired. Also check that you didn’t misspell entries for command and output item in your device driver INI file.
UPGRADE DRIVER
If you already have a previous version of the driver installed and would like to upgrade to the most recent version proceed as follows:
Stop any CNCnetPDM background service or foreground program that uses the device driver.
Extract mbus.dll and Modbus.dll from modbus_driver.zip into the folder where you have CNCnetPDM installed, overwrite the existing files.
Delete ALL mbus_NNNN.dll (NNNN = device number) files.
If you already have created adapted INI files for specific devices do NOT delete the mbus_NNNN.ini files.
After restarting CNCnetPDM upgraded device driver versions for all PLCs are automatically created.