Help: Visualizing logged data


Recommended Posts

Hi.

I have an application where I need to log data for up to 2 weeks, and later go through the data to look for specific patterns. To explain further, there is a production line that sometimes behaves strange, and I wish to monitor some signals to see which of the PLC:s that is not working correctly.

I have an Advantech ADAM-6510 ethernet digital IO module, and I have managed to get it to work with DAQFactory. I can log data at certain intervals, and store data to a file or database.

The question is:

Is it possible to use the logged data (from a file/database) as data source for a graph? I need the visualize the data and zoom in at certain time periods to look for these patterns. I have tried in different ways, but did not get the result I wanted.

Best regards

Linus Nilsson

Link to comment
Share on other sites

If you just need to go back a fixed amount of time that is reasonable in length, the easiest way to do this is by using the Persist feature of the channels. The Persist allows you to extend the history to the disk in an easily accessible method. So, a channel might have a history of 3600, which is 3600 data points kept in memory for graphing, and then you could set the Persist to 500000 to allow you to go back much farther.

Accessing the data is almost transparent. You still reference the channel by name, but you have to provide subsetting. So you can't just put the channel name in Y Expression for the graph. Instead you have to add [] notation and a range of data to plot. This is so you don't bring the entire 500000 (or however many you specified) data points into memory you probably don't have.

The easiest way to subset is by time instead of data point. Most likely you have been subsetting by index, meaning [0] gives you the most recent point, [1] the next most recent, etc. You can also subset by time. For example:

MyChannel[systime(), systime() - 60]

will return all the data points in myChannel for the last 60 seconds. You can put any time value in there, including the ones that come out of the Date/Time edit control.

Usually what I do is use two variables to determine the X axis scaling, usually one for the time of the right side of the graph, and another for the time width of the graph. I set the Scale From and Scale To to these values (actually, scale from is the right side variable minus the width). The channel also gets subsetted with these same ranges. I then use sliders or other components to allow the user to scroll.

Anyhow, I've attached a sample that shows this in operation. This sample also shows how to use component events and properties to create your own controls. The graph actually creates its own variables for the scaling and will actually automatically switch to live mode if you slide the bottom slider all the way to the right. This perhaps isn't the easiest sample to follow, but its the easiest to simply cut and paste into your own app. All the work is done in the graph itself. To see it, go to View-Event, select the graph, and look at the various events, the OnPaint in particular.

That all said, if you actually want to load data back into DAQFactory from a log file and plot it, then we are talking about something different. For this, you'd have to use the File. functions to open the file, read it into a variable, and then close the file. You'd then plot the variable. The File.ReadDelim() function makes this easy. Post if you need help with this method.

historysample2.ctl

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.