Trying to smooth incoming data


Recommended Posts

I am trying to read an analog signal coming in that I am streaming from a Labjack,  I was trying to figure out how to smooth the sign wave before it was picked up on my graph.  I ended up smoothing it in the graph.  The only problem with that is I am using high and low peaks to tell whether the part that its reading is bad.  If I set the numbers to the information that has been smoothed on the graph it fails every part.  Is there a way to smooth it as it comes in or do I have to do it in the graph?  If I need to upload my sequence I can, I am just trying to figure out how to use the smoothed info to set my high and low limit.

Link to comment
Share on other sites

global endtime = systime()
global testdata = Sensor[starttime,endtime]
global smoothedData = smooth(testData,12)
beginSeq(StopStream)
if ((min(testdata) < 4.81) || (max(testData) > 5.11))
   OutofRange = 1
endif

i was wanting to smooth the raw data as it came in but another Azeotech told me it's really hard so since in am testing the (testdata) i tried to smooth it before it was processed, but i am still having a hard time getting the good part to pass inside the numbers i set.  They are the ones from the graph that is set to with the same smooth command smooth(Sensor,12) as my Y expression.

 

Also the first half second of the signal is a high spike, how to i keep that out of the testdata?

Link to comment
Share on other sites

I don't recommend smoothing incoming data as you will be unable to get back to the raw data.  It is a much better idea to collect it raw in the channel, and then smooth it later.  It isn't really hard to smooth incoming data, it just isn't a beginner task for streaming data unless you use the Average function, which isn't the same thing.  The channel's average feature allows you to do oversampling, which will smooth your signal, but results in fewer data points.  The smooth() function does a rolling average and smooths the signal but maintains the same number of data points.

 

Link to comment
Share on other sites

I was told it was easier to create an event channel and have the streamed data stored there and then clean it up and do my max and min test off of that, and then if im right i can clear the channel at the start of the next test.  I am reading through the help file but can't find where i would save my stream data to the event channel.  right now it is just being used in the testdata command.

 

global endtime = systime()
global testdata = Sensor[starttime + .5,endtime]
beginSeq(StopStream)
if ((min(testdata) < 4) || (max(testData) > 6))
   OutofRange = 1
endif

Link to comment
Share on other sites

You don't need to have streamed data show up in a channel.  And it is not an "event channel" but rather the Event of a channel.  The Event of a channel is script that is associated with any channel that executes whenever new data comes in.  In the case of streamed data, the data comes into DAQFactory in blocks so the Event is only triggered with each block.  Block size is determined by the LabJack driver.  This makes it more challenging to use Channel Events.

The script you posted will capture your stream data and put it into a global variable called "testdata" from there you can work on the data as needed.

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.

Guest
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.