LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Set sensor value to zero

Solved!
Go to solution

Hi everyone,

I am working on a piece of code for some time now, which still isn't exactly doing what I want. I am working on a control system that is to be uploaded to a CompactRIO in scan mode. For this control system I am using a capacitive displacement sensor that gives values between 0 and 10V, corresponding to an absolute displacement (between 0 and 800 um) from the sensor head.

 

Before I close the control loop, I want to press a button on the front panel and subtract an average of a number of samples from the signal, so it will be 0 m. Because there is some noise on the sensor signal, I want to take an average of say 100 samples. This average has to be computed after the button is pushed.

 

I have been working on a dummy program (attached). The sensor signal is simulated by using a random number between ±0.5 for noise above a displacement of 400 um. I am using a for loop inside a case structure to start counting until 100 samples to compute the average. The average is saved to a local variable, which is subtracted from the signal+noise. The code is doing what I want the first time I press the button, although I am not sure if the average is taken over 100 samples. When the button is pushed again, also values from the previous time the button is pushed are used in the average, while this is not what I want.

 

Can someone give me a good idea to change the code to get this presumably easy problem solved? Or are there simpler ways to solve this? Thanks in advance

 

0 Kudos
Message 1 of 3
(3,803 Views)
Solution
Accepted by topic author JansenR

Hi Jansen,

 

surely there is a simpler way:

check.png

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 3
(3,789 Views)

Works exactly the way I want it to, thanks!

0 Kudos
Message 3 of 3
(3,770 Views)