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.

Share this post


Link to post
Share on other sites

I'm confused.  Do you want to find these peaks in the smoothed data or in the raw data?

Share this post


Link to post
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?

Share this post


Link to post
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.

 

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

how do I call the data up and modify it?

I wanted to smooth it and put it in a graph once it has been smoothed, After i have stopped the stream.

Share this post


Link to post
Share on other sites

Just reference it by name like you would a channel.  For example to graph it smoothed, just do something like:

smooth(testData,12)

in the Y Expression.

Share this post


Link to post
Share on other sites

I was wanting to do the smooth before it went into the graph so I can use the data shown in the graph for reference points for a high/low, pass/fail setup.

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now