Graphing problems


Recommended Posts

Dear Sir / Madam,

I have an aplication where I want to present on a graph a measurement on hourly, daily and monthly basis. The channel table looks like this.


I assume that for the daily log and for 10 sec timing I need 60*60*24=86400 /10 = 8640 history points. But the graph looks like this. I don



Link to comment
Share on other sites

Unfortunately, you generally can't create multiple channels with the exact same Type, D#, I/O type and Chn#, even though they have different names. When the driver sends the data back to DAQFactory it uses those 4 values to identify the channel, not the name. So, in your case, every second MEAS14 is read, and the result put in all 4 of your channels with tag #539. Then, every 5 seconds, MEAS14_Hourly is also read and causes a value to be put in all 4 channels, etc. This is all done after averaging, so you can't use the average settings either.

One solution is to make your hourly, daily, monthly channels into Test A/D channels with timing = 0. Then in the event for the MEAS14, you can calc the averages and stuff them into these channels. The nice part about this is that you can then align your boxcars to the hour/day, etc. For example, to do hourly averages that actually line up with the hour, you'd do:

private average
// for clarity, put time of last data point into a variable:
private lasttime = meas14.time[0]
// check if hour changed:
if (formatDateTime("%H", lasttime) != formatDateTime("%H", MEAS14.time[1]))
   // hour changed, calc average of last hour:
   average = mean(MEAS14[lasttime- 0.99, lastTime - 3600.99])
   average.time = lasttime

Repeat the if block for daily and monthly, though monthly has its own issues because months are different lengths. You need to decide if you want it to align with the month, or just 30 days.

Link to comment
Share on other sites


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