Modbus TCP Datalogging Programs

modiconguy

Member
Join Date
Oct 2020
Location
Toronto
Posts
62
I have an application where we want to periodically (1 second) store the values from a list of memory words (about 100 %MW) from a PLC over Modbus TCP. We've used our Vijeo HMIs for this but unfortunately if another script is running the HMI will miss data.
At the moment I'm picturing a standalone DIN-rail mounted computer running a data logging application (a Modbus TCP client) that logs to a CSV file on the USB flash drive, preferably with the flexibility to use double words and identify each variable by name rather than address. I've written a basic prototype in Python but I'd like to see if there are commercial solutions that are known to be capable of running unsupervised for months or years. When I'm searching for devices or solutions like this, I'm typically finding dataloggers that use I/O and act as servers, whereas the PLC already provides these functions and I want to record this data to a flash drive. Is this something that's readily available? Is an Ignition Edge box appropriate or overkill?
 
Node-Red isn't a bad way to go. I've done Modbus/TCP (or RTU) registers to columns in a CSV file
https://nodered.org/

They have other nodes(palette additions) that can push into standard databases, SQL, noSQL, SQLite.

And you can add a live webpage with graphs using the Dashboard.
 
Just to make you aware, Ignition Edge is limited to 1 week's worth of data, or 10M rows, whichever may come first. Unless you add the MQTT option, which removes this limit.
 
Thanks for the responses.
Node-RED looks promising. Not as straightforward to setup as I pictured, but the "flows" look like a decent equivalent to FBD. Certainly could be superior to the Python prototype in terms of sharing the code and adding features.
The one week limit on the basic Ignition Edge would probably be a deal-breaker. It seems like I'll need to discuss with them what it would take in time and dollars to get what we need. Not obvious as an outsider to their system.
 
One other possibility is an OPC server like Kepware, this is capable of logging to a Database like SQL directly, You purchase a licence for the PLc you are using and has hundreds of protocols. Really easy to set up. These OPC servers are usually used as a communication server for a Scada system but the Data logging does not need any other software apart from SQL Server, however the free SQL Server express is limited to 10gb DB size but that is a lot of data.
 
I would consider a DataStation or FlexEdge controller to be a good solution that is relatively easy to set up and very flexible in functionality. You can grab the files out of these units over a web browser or have it populate a database or send files to a FTP server too.

https://www.redlion.net/data-acquisition


Have not used the FlexEdge, but highly recommend the DataStation.
 
I should also say, based on the number of responses regarding servers that log to a SQL database, a universal format like a SQLite file would probably be an acceptable alternative to a CSV file, but I still need a method to export it without connecting a computer. I can ask my customer to remove a flash drive and send it to me, but I can't assume that they can or will connect it to a computer. Maybe something like the SD card slot on the RedLion would serve that purpose.
 
I would consider using Raspberry Pi (or some Raspberry Pi based device like Modberry) with Codesys licence for this application or maybe writing a Python script to write date to a USB flash drive. Another option would be installing Advanced HMI on Raspberry. AdvancedHMI has built in data log function but if it's not enough you could easily write your own in Visual Studio.

https://sourceforge.net/projects/advancedhmi/

I haven't used Codesys DataLog manager but it could get the job done.
https://help.codesys.com/webapp/ac_dlm_overview;product=core_Application_Composer;version=3.5.16.0

http://www.tcpipweb.com/index.php/modbus-data-logger
 
I should also say, based on the number of responses regarding servers that log to a SQL database, a universal format like a SQLite file would probably be an acceptable alternative to a CSV file, but I still need a method to export it without connecting a computer. I can ask my customer to remove a flash drive and send it to me, but I can't assume that they can or will connect it to a computer. Maybe something like the SD card slot on the RedLion would serve that purpose.

The logging done by a Red Lion will be csv format stored on the SD card. The default settings for the log file will give you a new file each day, but those values can be adjusted to get fewer larger files or more smaller files. The header row will take the labels from the Crimson tag labels.

If you split the log sets up, you will get a folder named for each log and inside each folder will be a csv file with a numeric name based on the date (YYMMDDHH).

The first column will be the date, the 2nd column will be the time, the rest of the columns will be your tag data in the order you stick them in the log file contents. You can drag them around to control the order of the columns.

Screenshot of an old log file from a water plant:

Crimson Log Example.png
 
The logging done by a Red Lion will be csv format stored on the SD card. The default settings for the log file will give you a new file each day, but those values can be adjusted to get fewer larger files or more smaller files. The header row will take the labels from the Crimson tag labels.

If you split the log sets up, you will get a folder named for each log and inside each folder will be a csv file with a numeric name based on the date (YYMMDDHH).

The first column will be the date, the 2nd column will be the time, the rest of the columns will be your tag data in the order you stick them in the log file contents. You can drag them around to control the order of the columns.

Screenshot of an old log file from a water plant:
Thank you. Great explanation, that's the kind of information I was hoping for. I'm trying out Crimson 3.1; the manual says Data Logging is setup in the "usual way", which is a bit unclear. If I have a blank project (DA10D for example), what kind of components do I need to add before the Data Logger button appears under the Navigation Pane?
 
Thank you. Great explanation, that's the kind of information I was hoping for. I'm trying out Crimson 3.1; the manual says Data Logging is setup in the "usual way", which is a bit unclear. If I have a blank project (DA10D for example), what kind of components do I need to add before the Data Logger button appears under the Navigation Pane?


Looks like the DA10D doesn't support data logging. Pick a DA30D.

The basic Crimson workflow is to follow the order of the items in the lower left pane. On Communications, set up a protocol by picking the Modbus TCP/IP Master driver. A single device will be created for you called PLC1. Click on it and set up any required details for communication. You can rename it at any time if you want a different name.

Next create some crimson tags assigned to that device pointing at the addresses you want. If your tags are all of the same data type and in a contiguous block, you could make that tag an array and set the array size as needed.

Next, you can jump down to the Data Logger section, add a new Log file and populate the contents tab. If you use array tags, you can pick individual elements of the array by right clicking on the tag (in the resource pane on the right) and select "Toggle Array". If you want all of them (ie. 100 tags named Tag[0] through Tag[99], you have to toggle the array to expose them all, select them all (shift key is your friend) then drag them onto the Log Contents

Set up the log details:
Update rate 1.0 seconds
Each File Holds 86400 samples
Retain at most 200 files

That would give you a new file every day for 200 days (Crimson wont let you pick more than 200, and I always set it to the max...never have filled up a memory card even with lots of log files).

I would recommend just setting up one tag at first, then create virtual HMI page to display that tag, dump it into the unit and test it to ensure you have good communication and all the right data formatting and addressing before you finish the application. It is also a good idea to make a flag tag something like "CommsOkay" and set its data source to IsDeviceOnline(PLC1). This tag will give you a "1" when comms are good and a "0" when comms are not good. With modbus, this function is dependent on the Ping Holding Register set up for the device on the Communications settings.

Stick that tag on the virtual HMI page too. You can monitor the virtual HMI with any web browser, but Chrome works better than IE. IE sometimes messes with the pointer location...you push one button and a different one operates!
 
Last edited:

Similar Topics

If a device has Modbus RTU over serial and Modbus RTO over TCP and Modbus TCP then there is a difference between Modbus RTU over TCP vs Modbus TCP...
Replies
7
Views
351
Hi There. I have PC to get few tags from PLC into C# windows forms application. What is the best and fastest way? I could not find Omron in...
Replies
3
Views
165
I contacted Hach and bought a kit they recommended for a customer to add Modbus TCP capability to his Chlorine Analyzer with a SC4500 controller...
Replies
8
Views
195
I’m trying to read values from a device that can either send registers as 32 bit or a pair of 16 bit but if I understand right, the micro can only...
Replies
26
Views
689
Does anyone have any recommendations for Electronic Circuit Breakers with 0V Terminals built-in and Fieldbus (IO-LINK, MODBUS TCP, EtherNet/IP?)...
Replies
2
Views
168
Back
Top Bottom