Logging the maximum output over a time period?


Recommended Posts

Hi, I'm logging data from a load cell. The cell is loaded periodically (every second in this case). I am only interested in the maximum load the cell reads every time period; I'd like to avoid logging many data points and having to filter the data later. This way, the file size is much smaller as well. How can I go about doing this? I imagine I need to write a script in the load cell's channel..

By the way, the time period is a global variable defined in a script, Auto_Start. 


Link to comment
Share on other sites

This is probably an event-based logging problem. I'll expand a bit further..

I'm toggling two solenoids to control a pneumatic cylinder. I want to log the force the cylinder is exerting at max extension (max force at this position). The cylinder is controlled with a sequence, which I'll post here:

while (N_cycles_executed < N_cycles)
   Output_contract=5 //turn off contraction solenoid
   Output_extend=0 // turn on extension solenoid
   delay(period_half) // extend for time period
   Output_contract=0 //turn on contraction solenoid
   Output_extend=5 //turn off extension solenoid
   delay(period_half) //contract for time period
   N_cycles_executed++ //Index number of cycles by 1


Link to comment
Share on other sites

You really should just put everything in that sequence, that way everything is synced up.  Use the file. functions to create the log, or perhaps an export set, but I would use the file. functions which give total flexibility.  Record the time stamp when you activate and deactivate the cylinder and then you can subset your load cell reading between those two times.  Then just take the max and log it.  You can probably keep the acquisition of the reading in a Channel with its own timing.

That all said, be careful about throwing away data.  There is certainly a benefit to creating slim data files, but consider also having a separate raw log for backup.  I always tell this story about the ozone hole: when it was first discovered back in the 80's, it was the find of the century for atmospheric scientists.  A group went down to the south pole, measured ozone for a bit, wrote a paper, and became famous (within the atmospheric scientist community at least).  Well, it turned out that another group had been measuring ozone for years at the pole, but, since data storage was expensive back then, they had programmed their system to throw away any data below 50ppb because it was assumed that that meant the machine was glitching.  Of course, the ozone hole was when ozone was below 50ppb so they totally missed it.  Back then they had a reasonable reason for saving storage space.  Today, when you can buy an 8 terrabyte drive for like $100 there really is no excuse.

That said, your data might not be critical to warrant logging raw, but whenever I hear about trying to save disk space used in logging slow (i.e. under, say, 1khz) data I have to tell this story.  I mean even at 1khz, a years worth of data on a single channel is only 31 gig.

Link to comment
Share on other sites

Got it, thank you. I would like the raw data and peak values to live on the same data sheet. And I would like to create the file using a button. I'm having a hard time with this (I'm new to the software). I've created a button and want to write a quick sequence action to open a dialog, write the file name, and create the file. Then when I start the experiment, all the data starts logging to that file. My script at the moment is 

FileName = file.FileOpenDialog([],"C:\Users\austi\Dropbox\Product Testing\Cycle Testing Machine\Cycle Test Data\DAQFactor data\",".csv",[])

The dialog opens and I write the file name, however the file is not created. Can you help me with this?

Link to comment
Share on other sites

OK, you'll want to put Filename as a global string variable:

global string filename = file.opendialog(...)

also, [] notation in the function call doesn't mean anything.  Just drop it.  If you don't want to specify a parameter, just leave it out.  Most functions have required parameters.

Create the file when you start the experiment using the filename global variable.


Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.