andybdjuk Posted August 15, 2008 Share Posted August 15, 2008 Hi, can you give me an example or pointers to code that will add 3600 values together then give a result that can be plotted on a bar graph, then move on to the next hours total Etc, I want to graph the hourly output of my solar panals. Thanks Link to comment Share on other sites More sharing options...
AzeoTech Posted August 16, 2008 Share Posted August 16, 2008 There are two different interpretations of your questions. Since this is forum is designed to show many things, I'll give you both: 1) if you just want to do things with your data in groups of 3600 from the most recent point, you can use one of the various boxcar() functions. However, it won't line up with the hour, it will be a rolling 3600 points. Also, if one hour your device goes off line for 1000 seconds, it'll get screwed up and pick up more than an hour. My guess is you want #2: 2) This applies to any example where you want to create hourly, daily, weekly totals, or all at the same time: a) Create another channel to hold the total. One for each if you are doing say hourly and daily. Let's say you call the channel DailyTotal. It should be device type Test, A to D, Timing = 0. The rest doesn't matter, though you should probably use persist to keep the totals through restart. In your raw reading channel (the one with the values you want to add), go to the Event. Put script like this (assuming its called RawChan): if (formatdatetime("%H",RawChan.Time[0]) != formatdatetime("%H",RawChan.Time[1])) private timeend = floor(rawchan.time[0] /3600) * 3600 DailyTotal.AddValue(sum(RawChan[timeend - 3600,timeend])) endif Change the "%H" to "%d", and the 3600's to 86400 for daily. The first line could also be done using the %, provided data was coming in reliably every second (or minute): if (RawChan.time[0] % 3600 < RawChan.Time[1] % 3600) ... You can do both totals by adding two channels, and putting both if statements in. Link to comment Share on other sites More sharing options...
andybdjuk Posted August 16, 2008 Author Share Posted August 16, 2008 Hi, thanks for all your help, this is a whole new world to me but i am trying. Iv'e even printed out the whole DAQ Manual to take on holiday as my wife has banned the laptop. Link to comment Share on other sites More sharing options...
AzeoTech Posted August 18, 2008 Share Posted August 18, 2008 Hmm, I think maybe you missed the point of banning the laptop... Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.