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:
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.
Click HERE to scroll down to view or leave comments
- I found this thread to be very useful. I downloaded the Rockwell logic and put it into my controller, but then what!? I was logging data of nothing essentially. I've played around with this for several days to try to make the logic useful to me and I came up with a couple helpful things I think others might be interested in trying in order to collect specific data (in my case I'm collecting 2 vibration signals and a speed reference of our machine).
One thing I noticed was that when the memory card was removed and then put back in, the logic seemed to get "stuck" and wouldn't log data anymore. I wrote a small branch of logic to "unlatch" the cfbw01.busy bit since when the memory card is removed and put back in, this bit gets stuck on and never allows the logic sequence to continue, so it doesn't log data. My logic addition will reset this 5 minutes after the memory card has been put back in (see image below).
And also, I wanted to create a .csv file on a daily basis rather than file size to make organizing our data more useful. I have my logic writing to a single file daily until midnight, then it'll create a new file for the next day and will log until midnight comes around again. In my case, midnight happens to be when the Idt.hour bit hits '6' (this is a work in progress, I'm trying my best to figure out this logic and edit it to be useful to me). Once it hits midnight, it'll finish writing to the one .csv file for the day and create a new one... see image:
Ultimately, what we want is to log data, our own data. This is done in the Raw2ascii structured text routine. Their first 2 "groups" of logic in this routine are written to log the date and time. That's good, but I also wanted to log my data for the specific date and time stamps that were being logged. I pretty much copied and pasted the first 2 "groups" of logic and edited it to use the bits I wanted to monitor in the PLC, see image:
With all this being said, I now log the data I want to see, along with meaningless extra stuff that is being written to this .csv file: . The first 5 columns are the Date, Time, Vibration Data, Vibration Data, and Speed. The last several columns are meaningless (where it writes the values 1-10 for each row). I ended up making a macro in Excel to delete these meaningless numbers.
Like I mentioned, this is still a work in progress, but ultimately what I'd like this logic to do is to ONLY collect the data I want and figure out how to not write the rest of that meaningless stuff to the .csv file. And I'd like to figure out how to write a top row in every .csv file that has all the headers for what each column represents.
I hope this helps some people, I was unable to find any real examples of how to manipulate Rockwell's logic to make it their own, so I had to give it a try on my own. Btw, I'm an electrical engineer with 3 1/2 years of programming experience, so I'm still fairly new to the world of programming, but hope this helps some people.Good morning Emocowmoo,