A couple of years ago, prior to the release of Studio 5000 v21, Rockwell demonstrated a future feature for it’s new “multi-core” programmable automation controllers. This new feature was a very robust, controller based data logging system.
Unfortunately, since that demo a couple of years back nothing more has been hear about this feature. Well, at least I haven’t been able to find anything out despite my efforts. However, I can confirm it’s not in the soon to be released version 22, which was the originally targeted release.
But even without that new feature there is a way to log CSV files to you CompactLogix or ControlLogix’s Compact Flash or SD card. And it’s accomplished with a piece of free sample code from Rockwell’s own sample code website. Below is a link to the free code in question:
Log to CSV file on CompactFlash or SecureDigital
Having tested the sample myself, I have to say it works as advertised. Simply changed the code to match your processor model and version (the sample code is version 17,) change one rung to indicate the slot of your processor, and download.
There are two Tags in the program
which controls it’s behavior. The first Tag is the “logging_enabled” bit, which does just what it says. The second Tag is “max_file_size,” and this is the setpoint that when reached will unlatch the “logging_enabled” bit.
The output of this program is a CSV file which is easily opened in Microsoft Excel. Once open, you set the first column to the Date format, and the second column to Time format, and you end up with a document which looks just like the example below:
Unlike the “CF_Read_Write_Example” I mentioned earlier this year, this code is not so much an application example as it is a proof of concept.
In my opinion, to make this code fully functional the following features would need to be added:
- Easy way to tell which tags are being logged, and add new tags to be logged.
- Addition of a series of tags to be used as “row 1 headers”
- Automatically create new files at a predetermined time (midnight)
- Easy way to specify CSV file naming parameters
- Automatic deletion of older files after a certain number of files are present, or a percentage of the card had been filled.
That said, if you need to log to your CompactLogix or ControlLogix external CF or SD card, this sample code is a simple and easy to use free solution.
I hope you’ve found this article about logging to a CompactLogix or ControlLogix external CF or SD card helpful. If you have any questions, comments, or corrections, please don’t hesitate to share them with us by using the “post a comment or question” link below.
Until next time, Peace ✌️
If you enjoy this episode please give it a Like, and consider Sharing as this is the best way for us to find new guests to come on the show.
Shawn M Tierney
Technology Enthusiast & Content Creator
Eliminate commercials and gain access to my weekly full length hands-on, news, and Q&A sessions by becoming a member at The Automation Blog or on YouTube. You'll also find all of my affordable PLC, HMI, and SCADA courses at TheAutomationSchool.com.
- 2024 Podcast Audience Polls: Vote before January 8th! - December 18, 2024
- All 2024 Audience Choice Polls: Vote before December 31st! - December 18, 2024
- Position Guided Vision (P232) - December 18, 2024
Discover more from The Automation Blog
Subscribe to get the latest posts sent to your email.
Hello Shawn,
First, thank you. this code is very good and i like this article.
I tried to set up this type of system without ever succeeding. I tried unsuccessfully CR_read and CF_write functions. Your code will really help me.
I just have a few questions:
– I do not understand the use of CF_del.PRE in CF_FunctionsProgram function. Can you enlighten me this detail?
– If I understood correctly. you flash stores data. When the quantity of bytes is greater than a threshold. you exported and write at that time. You activate the delete function “oldeslogfiles” only when there are more than 10 CSV file?
-After Export, I can change in the CSV file, the cells of the date, but not this time. I have not proposed cell formats ‘h: mm: ss.000’. Is there an intermediate solution?
Thank you in advance for your answers.
I can run the software on a 1769_L33ER PLC.
Good morning Lefty,
I’m unable to offer free support for the above Rockwell sample code.
That said, if you’d like to hire me for an hour or two to help use this form here to contact me:
http://insightsinautomation.com/consulting/
Sincerely,
Shawn Tierney
Join my free community to follow along! You can also become a member and support our work at: Automation.Locals.com
Hello Shawn,
Very interesting article. Like Mikeuk, I also have only the mini version of controllogix. Is it possible to get a copy of the file you sent to Mikeuk?
Regards,
Dan
Good morning Dan,
Sure – just use the contact link at the top of the site to send me your request,
Sincerely,
Shawn Tierney
Join my free community to follow along! You can also become a member and support our work at: Automation.Locals.com
Good day Shawn,
In my application I only need to save data to the sd card right before the Plc malfunction or is shut down. Is there a bit that turns on right before the Plc is shut down? Something like the S:FS but for the “last scan”? Do you have any other suggestion to accomplish this?
Thanks in advance.
Good morning Jose,
Since many of the Compact and ControlLogix processors Rockwell made have no power storage, I don’t believe it’s possible for them to do anything when power turns off as they’ll have no power to keep running.
However, since all the new models do have a supercap built-in, it’s feasible that they could add this feature in the future.
That said, here’s a few options you could use today:
1) Fault Routine
All Rockwell’s PLC’s allow the user to write a fault routine which will run once when a fault occurs.
This can be very helpful when you want to record certain tag values when a math overflow or other trappable fault occurs.
2) UPS
If you have to record data when power is turned off, a small UPS with output contact wired into the PLC is one way to achieve this.
Setup the UPS so when power is lost it opens its contact, wire the contact into an input module on the PLC, and write a program so when the PLC sees the contact open it records the data you need.
3) Continuous logging / Log on change
The obvious and least efficient option is just to record the needed data every PLC scan.
This would definitely catch the data before a fault or powerdown.
It may also make sense to only log the data when it changes as all non-volatile memory (SD, CF, etc) has a maximum number of times it can be written to.
Hope this helps!
Shawn Tierney
Join my free community to follow along! You can also become a member and support our work at: Automation.Locals.com
A rudimentary approach can be taken by continuously storing and overwriting the data in a buffer tag(s) for each scan. Upon shutdown or fault, the S:FS bit can be used to write the buffer when it powers up. This essentially captures the data before the processor stopped.
The only downside to this is that the information can only be retrieved after the processor powers back up.
Thanks for the information, very useful.
You’re very welcome Jose,
Sincerely,
Shawn Tierney
Join my free community to follow along! You can also become a member and support our work at: Automation.Locals.com
I couldn’t buy you a coffee and not get you a Danish as well, enjoy.
Looking forward to trying the data logging, let me know when you have it.
Thanks Shawn.
Thank you very much mikeuk!!!
Will try to get it for by Monday – do you have a version preference? The file in this article comes in v17, but the Read Write you mention comes in many versions…
Thanks again,
Shawn Tierney
I know this is a big ask but does anyone have the CF_Read_Write_Example saved for a compactlogix (1769-L32 or 1769-L35) I only have the mini version of RSLogix5000 and nearly all of the examples are for controllogix which cant be opened by mini.
I tried my rep but no joy. Any help would be appreciated.
Good morning Milkeuk,
I think I have it somewhere and will look… would you be willing to trade me a cup of coffee for it? (I love coffee!)
Sincerely,
Shawn Tierney
Join my free community to follow along! You can also become a member and support our work at: Automation.Locals.com
Thanks Shawn,
That’s what i was wanting to do, i am new at this world of PLC programming and i try to understand the code reading all its lines but there are some things that i dont know but apart from that i didnt see where it shows what kind of data is logging or as @Alex says how can i pick some tags to be logged, or i am confusing the code’s purpose.
I will apreciate if you can help me.
Jorge
Good morning Jorge,
It’s true this sample code is not the easiest to use, and I’m still several weeks away from being able to look at it again 🙁
In the mean time, you may wish to contact your local Rockwell rep or Rockwell support to see if they can help?
Sincerely,
Shawn Tierney
PS – When I do get back to this topic I’ll update this article with a link to any new content
Could you please send me your contact info. I want to know more information
Sure – just use the contact link at the top of the page 🙂
Shawn Tierney
Join my free community to follow along! You can also become a member and support our work at: Automation.Locals.com
I want to know what changes should I make to record only to take a pulse and not complete with previous data
Francisco,
Thank you very much for your comment.
Unfortunately, I’m traveling and won’t have a chance to take a look at your code question about this Rockwell sample in the immediate future.
Sincerely,
Shawn Tierney
Join my free community to follow along! You can also become a member and support our work at: Automation.Locals.com
Una consulta, que cambios deberia hacer en el programa para que registre solo al generar un pulso ? porfavor, necesito saberlo
Sorry, I only speak English,
Shawn Tierney
Join my free community to follow along! You can also become a member and support our work at: Automation.Locals.com
Hey Shawn,
This article is awesome! Thanks so much! I am very very new to programming in controllogix and have built my own program. I only need two integers recorded and I’ve managed to get this program to work on my compactlogix but i’ve looked through the entire program and can’t seem to find where to put my tags to be recorded. I also need to keep my values as integers instead of strings and the instructions say to use the DTOS function but I think its not as simple as changing RTOS to DTOS wherever its found. I think some of the code could be done away with for my purposes. Could you give me some guidance? I feel like I’m missing something really simple.
Thanks!
Alex
Alex,
Thank you very much for your comment.
Unfortunately, I’m traveling and won’t have a chance to take a look at your code question about this Rockwell sample in the immediate future 🙁
But, if you figure it out I think everyone here would love to hear what you find!
Sincerely,
Shawn Tierney
Join my free community to follow along! You can also become a member and support our work at: Automation.Locals.com
Thanks Shawn! I am currently building a machine utilizing this feature right now. I, too, have been successful writing to the CF in CSV format and agree with your comments about the additions that would make this code awesome. If you figure out a way to do the “row 1 headers”, please let me know. Thanks again!
Morning Adam,
I had a great email exchange with the author of this code and he seemed very interested in adding some of the new features discussed above.
If I hear anything additional I’ll post it here,
Have a great day,
Shawn Tierney
Join my free community to follow along! You can also become a member and support our work at: Automation.Locals.com