Recommended Posts

Hey! So I'm using DF Express to measure some Load Cell Data. Through a LabJack U6-Pro.

I'm using a 0-500kg load cell and trying to get a resolution of almost 1-5 grams. However, I noticed there is a little bit of noise which I believe could be filtered with an equation like this:

Filtered Analog = (filter_coefficient x Analog Input) + ((1 - filter_coefficient) x filtered analog)

How could I implement this in DAQFactory or would you suggest a different method? Also to keep in mind that I am plotting these values in a graph, logging them, and also grabbing the data every 0.1 seconds. Hence I cannot simply use the averaging function from DAQFactory.

Link to comment
Share on other sites

Well, my first thought would be, yes, you can simply use averaging by oversampling.  Sample the LabJack at 0.01 seconds then average 10 readings into 1.

But implementing your function is not hard.  Just use a conversion.  I'm assuming filter_coefficient is a constant, but what is "filtered analog"?  You have it on both sides of the equation.

Link to comment
Share on other sites

On 5/2/2020 at 3:12 AM, AzeoTech said:

Well, my first thought would be, yes, you can simply use averaging by oversampling.  Sample the LabJack at 0.01 seconds then average 10 readings into 1.

But implementing your function is not hard.  Just use a conversion.  I'm assuming filter_coefficient is a constant, but what is "filtered analog"?  You have it on both sides of the equation.

Oversampling is not able to provide the filtering I need as I can still see some noise. Also I will be changing the sample time anywhere from 0.1-10 seconds which can make things even more complicated to try this method.

I have included the function in my scripting and also tried in my conversion. But I believe the problem is that this equation requires the output (filtered analog) to be part of the input. Hence that is why I have the same variable on both sides of the equation. This is an IIR filtering equation that is very commonly used in other coding platforms. I don't see any other way to solve my problem via DAQFactory. I think it might be the hardware I am using that is causing the issue. To be specific, my Signal Conditioner.

Link to comment
Share on other sites

Yes, be careful about trying to remove noise in software without understanding what the noise is coming from.

In your formula, is the filtered_analog on the right side of the equal sign, the same reading as the left, or is it the previous reading?  If it is the same reading, then you just need to do some basic algebra to move it so it is only on the left.  If it is actually the previous reading, then subset with [0].  So, if you put the code in Analog_Input's event, with a separate channel to hold filtered_analog, it would be:

filtered_analog.addValue(filter_coefficient * analog_input[0]) + ((1 - filter_coefficient) * filtered_analog[0])

DAQFactory can certainly handle this filtering, I'm just not sure how you want it implemented within the rest of your app.

 

Link to comment
Share on other sites

Hi Guru,

So I tried that and it worked but that equation didn't really help much in terms of filtering.

I was trying a few other things and came up with some questions. I have a channel called "Force".

I was trying to add a deadband to that channel with some sequencing so that I can just display and log "0" when there is no load. I did something like this:

While(1)

   if (Force[0] < -0.5)

       Force [0] = Force[0] * -1

   elseif (Force[0] > 0.5)

        Force[0] = Force[0] *1

   else

        Force[0] = 0

   endif

endwhile

But I noticed that this part of the code was not being executed. Why might that be? Please note that I also tried to initialising "Force[0]" as a global variable.

The reason I want to do this in my sequencing is because I also want to log and graph the results. Any help will be appreciated.

Thanks You!

Link to comment
Share on other sites

Is Force a channel?  You can't really assign a value to a channel unless it is a D to A.  If you want to adjust a value in a channel on its way in, use a Conversion.  In this case, you can use a fancy math to do what you did in 9 lines in a single expression.  Note the change to "Value" from using the channel name directly.

abs(Value) * (abs(Value) > 0.5)

You are basically taking the absolute value if the value is in range (i.e. > 0.5), but setting to 0 if not.  abs(Value) > 0.5 returns 1 if the value is > 0.5 or < -0.5, and 0 if not, so will convert the result to 0 if inside that deadband.  

Link to comment
Share on other sites

I already had a expression in my conversions, hence I hesitated to add what you have shown me. The expression is "(Value*50)-LoadCellTare"

However, I will try to implement what you have provided now.

Thank you so much for your assistance Guru!

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.