LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

floating signal with a time depend thresholding

Solved!
Go to solution

hello all,

i have a floating signal that need a time depend thresholding. For example if the signal shift more than 0.2 V in less than 1 second then an alarm is set otherwise the baseline and if the signal shift 0.2V in more than a second then alarm stays off and baseline shift. I've tried different techniques such as averaging the signal and deducting its original but nothing seems to work i also tried to put a time delay but all the instrument channel are then delayed even if created in a subvi. could someone help me please?

thank you in advance

Frederic.

0 Kudos
Message 1 of 11
(3,553 Views)

Hi Frederic,

      Can you "buffer" the most recent 2 seconds of data in an array?  After appending data to the array, do a MaxMin on the array.  If Max-value - Min-value > 0.2, then Alarm.

 

?  

"Inside every large program is a small program struggling to get out." (attributed to Tony Hoare)
0 Kudos
Message 2 of 11
(3,542 Views)

Hi Fred,

 

Could you elaborate a bit more. Am a bit confused exactly what you are after. Could you post any code you have currently done to give a better idea of what you are trying to achieve. I will try my best to help once i have a better understanding.

 

Regards.

------------------------------------------------------------------------------------------------------
"Everything should be made as simple as possible but no simpler"
0 Kudos
Message 3 of 11
(3,521 Views)

Hi Lucither,

I want to setup an alarm when a door opens sounds simple however the pressure sensor is also temperature sensitive so i cannot just set a standard  base threshold as the base signal might overshoot above the threshold value due to temperature change  hence the importance to trigger the alarm if the threshold is reached within say a second of the door opening. I've tried lot of techniques. I just tried sequencing it with a time delay. Please find attached my VI i left a few of the tries i did today. None are working 😞 . I didn't include the time delay ones since it delays all the instruments.

Any help or suggestions are welcome as i'm running out of idea. I'd like to try the technique suggested by tbd as it's a good idea but i have no idea how to buffer data i've tried but i ended doing the useless queuing technique i did in my VI. 

Regards,

Fred. 

0 Kudos
Message 4 of 11
(3,487 Views)

Hello tbd,

This is a good idea. I had a look but i have no idea how  to "buffer" the most recent 2 seconds of data in an array. I've tried something in my VI but ended up queuing the data to try to delay them but with no success. 

If it's not too much asking could you please tell me how to "buffer" the most recent 2 seconds of data in an array? 

Thank you in advance 

 

0 Kudos
Message 5 of 11
(3,485 Views)

Hi Fred,

 

I will be able to show you how to queue the last 2 seconds of data tonight. I have just got up for work and dont have time now.

 

I created something similar to what you are trying to achieve a while back, it was a flow sensor for a chemical cabinet company. That too was temperature sensitive. The ideal solution is to incorporate either a NTC Thermistor or temperature dependant resistor and then offset your pressure readings according to ambient temperature. An NTC is highly non-linear so requires linearisation to temperature but you can get many temperature dependant resistors that are linear over a specified range (just slightly more expensive).

 

As i said, i can look at this for you tonight and send you over some sample code.

 

Rgs,

 

Lucither

------------------------------------------------------------------------------------------------------
"Everything should be made as simple as possible but no simpler"
0 Kudos
Message 6 of 11
(3,471 Views)

Hi Fred,

 

As promised i have attached a circular buffer vi. All this does is store your data in a circular buffer. You can specify the size of the buffer. Upon initialisation (will automatically do the first time you write to it) a buffer of your specified size is created with the buffer initialised, filled, with the first value you enter. I did it this way so if you are inputting a voltage, the whole buffer will be filled with that voltage which will immediately allow you to add your peak sensing algorithm after it. (Rather then the buffer be full of 0's and then adding your first input voltage). 

 

Upon entering a new value to the buffer the buffer deletes the oldest value, shifts the buffer and then inserts the new value on top. If for example you configure the buffer to have 100 values, the output of this vi will always be the last 100 values entered. If you store 50 values per second then a 100 values will represent the last 2 seconds worth of data continuously. It does not take 2 seconds of data, stop and then take another 2 seconds worth. The data is a constant rolling representation of the last 2 seconds of data.

 

Circular Buffer.png

 

You can then do any filtering of high and low values on this set of data output from the vi. I will attach both the circular buffer vi and a demo vi to visually show you how it works. On the demo version i have coded the buffer to a size of 5 just to show you. On the front panel extend the buffer to show 5 values. You will see as it runs how it shows the last 5 values entered into the buffer vi.

 

Circular Buffer Demo Snippet.png

 

Hope this helps you out. If you are still having problems filtering this data to achieve what you want let me know.

 

I will send you this in LV 2009 and LV 8.6 as not sure what you are using.

 

Rgs,

 

Lucither

Message Edited by Lucither on 03-23-2010 07:29 AM
------------------------------------------------------------------------------------------------------
"Everything should be made as simple as possible but no simpler"
0 Kudos
Message 7 of 11
(3,454 Views)

Hi fredric,

      Lucither's example is on the right track, though, I wouldn't recommend rotating the entire buffer every DAQ-cycle - it could require LabVIEW to shift thousands of values, (depends on the DAQ rate.)  Better to increment the array index instead.  Use the arithmetic Mod function to force index to "wrap" when it reaches the 2-second sample-count.

 

Are you reading one sample each DAQ loop?  If you have more questions, it might help us to see the code you have so far - when Replying, use the "Add Attachments" link, below left.

 

Hey Lucither, where's the MaxMin/Alarm logic? Smiley Wink

 

Cheers!

Message Edited by tbd on 03-23-2010 06:00 PM
"Inside every large program is a small program struggling to get out." (attributed to Tony Hoare)
0 Kudos
Message 8 of 11
(3,436 Views)

With regards to the min/max code, i didnt want to rob Fredrick of the deep satisfaction of completing that part himself 🙂

 

You have a good point about the rotate function. When i normally implement a circular buffer i do not do it like this. I normally keep track of the next index and insert, clocking over the index when i reach the buffer size. For Fredrick i wasnt 100% sure that his min/max will work (as i havent actually seen an example of the signal he is recieving from his device) and that he may need to try other things with the array, in the order they came in, from 0 to buffer size. I just thought that this way would be easier for him to work with the output array.

 

Hopefully he can get back to us to let us know whats going on.

 

Fred, could you post an example of the data you are getting, specifically when the door opens?

------------------------------------------------------------------------------------------------------
"Everything should be made as simple as possible but no simpler"
0 Kudos
Message 9 of 11
(3,429 Views)
Solution
Accepted by topic author fredericb

Hi Fred,

 

I have re-written the circular buffer for you and also written a small demo code showing how to find the max and min and trigger an alarm is this is above or equal to a trip point:

 

Circular buffer 2 snippet.png

 Circular buffer 2, this time i do not rotate the buffer but just increment an index and clock this over when buffer full.

 

Circular buffer 2 demo snippet.png

 

Here is a small demo vi showing how to trigger an alarm if the difference in highest and lowest value is equal or greater then a trip point.

 

With regards to the circular buffer 2 i output the current index value. This is in case you at some point need to go through the current buffer in the first to last order. You can use this index value as your starting point.

 

Hope this helps.

 

Rgs,

 

Lucither

Message Edited by Lucither on 03-24-2010 05:45 AM
Message Edited by Lucither on 03-24-2010 05:46 AM
------------------------------------------------------------------------------------------------------
"Everything should be made as simple as possible but no simpler"
Message 10 of 11
(3,417 Views)