LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to create a type of 'alarm event' based on acquired sensor data and system time?

Solved!
Go to solution

Hello all,

 

I'm fairly new to LabVIEW and have successfully created a VI that reads voltage data from sensors.  Each sensor outputs 2 voltage values and I treat these values as 2 different DBL values.  I'd like to be able to record each voltage value as a base and then compare the subsequent data readings with that base.  Once the base is determined, I'd like a sort of 'variable' set as "TIME" to be recorded at the moment the base voltage is recorded.

 

The alarm should occur (or anything Boolean set to TRUE I guess) once the continuously read voltage remains within certain limits for about 2 hours.  I know I can compare the system time w/ the "TIME" that the voltage base value was recorded.  If the voltage readings escape those limits, I'd like the voltage base value reset and the TIME set to the corresponding system time again.

 

I apologize in advance if this I haven't' described my problem well, but if anyone could help me figure out the best way to create this code, I would appreciate it much!

 

Thanks!

0 Kudos
Message 1 of 11
(4,745 Views)

ill try to illustrate a couple scenarios:

keep in mind that i dont necessarily want the voltages in these specific ranges, but just a range of +/- 20 mV ... in an above post i refer to a "base" voltage reading, in this case that would be 200 mV for V1 and 400 mV for V2, just because the voltage has shifted to those values for an extended amount of time each (> 2 seconds)

Scenario 1
1:00 pm
Sensor readings
Voltage 1: 200 mV
Voltage 2: 400 mV

between 1:00 and 3:00 pm:
Voltage 1 does not deviate from 180-220 mV range
Voltage 2 does not deviate from 380-420 mV range

at 3:00pm I want an alert/alarm/Boolean to change to 'true'


Scenario 2
1:00 pm
Sensor readings
Voltage 1: 200 mV
Voltage 2: 400 mV

at 1:45 pm:
Voltage 1: 2 mV
Voltage 2: 600 mV

Since the voltage has shifted out of the range, i want the new base voltage to equal whatever it changed to out of the range, and also the time spent within the new range (2 +/- 20 mV and 600 +/- 20 mV, respectively for V1 and V2) would be reset, so a new 2-hour counter would begin

0 Kudos
Message 2 of 11
(4,719 Views)

Hi dweedle,

As you mentioned you have program ready which reads data from sensors. You know what to do, you need to use compare function to check time,

You can use "In Range" function to check your Base voltage. If it is in range, keep counting time, else change time again.

I am attaching a example vi with this post.

Let me know if this is what you want.

Gaurav k
CLD Certified !!!!!
Do not forget to Mark solution and to give Kudo if problem is solved.
Message 3 of 11
(4,709 Views)

Wow, that example appears to work just the way I need it to work...what I need to do now is try to implement with my current VI.

I have had some issues with getting while loops to work together, but we will see what happens...I'll reply again with my results

 

Thanks!

0 Kudos
Message 4 of 11
(4,684 Views)

As I was concerned, the while loops will not work alongside one another (at least the way I am attempting).  I've attached an image of what it currently looks like, because I assume attaching the VI file will not open if you do not have the same DAQ board connected that I have.

 

Note, the image attached is obviously wrong, but maybe you can point out what I could change?

 

Thanks again!

0 Kudos
Message 5 of 11
(4,673 Views)

OK, I've got it working but I forgot to mention one detail that I also needed to check.  Based on the example.vi provided by Gak, I would also like to determine whether the voltage magnitude is greater than 1 V.  If it is greater than 1, then I'd like it to react the same way as if the voltage is outside of the limits.  I've tried to add this into the shift register, but I'm not sure what to do with the output Boolean.

 

Thanks again!

 

0 Kudos
Message 6 of 11
(4,662 Views)

Hi dweedle,

 

Assuming that the Boolean indicator you have in the bottom of that picture is your alarm, you need to "Or" the output of your "Greater Than" block with the output currently going to the alarm.  Then your alarm should of if you jump above 1 volt or your previous logic comes out true.

 

Have a great day,

 

Chris 

Applications Engineer
National Instruments
0 Kudos
Message 7 of 11
(4,647 Views)

Hi Chris,

 

Thanks, but there is actually no desired alarm if |voltage| > 1 ... I am monitoring whether |voltage| stays within a range and if it stays too long, then an alarm occurs.

 

The desired event that occurs if |voltage| > 1 is that the timer is reset to the current system clock and the alarm Boolean is false.

 

In the image I posted, the Boolean is the alarm, but that alarm occurs once the voltage has remained within the limits for 0.0009 [time units]

 

I use [time units] because it appears to be counting faster than 1 second when I run the VI, haha ... therefore if anyone knows how to get that to equal seconds, then I'd be grateful again Smiley Happy

0 Kudos
Message 8 of 11
(4,642 Views)

Hi dweedle,

 

Okay, I think I see now.  You are resetting the clock with your bottom select clock, correct.  So if the output of your greater than block is true, you want that select to see a false, correct?  To perform this, you will need to "not" the output of the greater than block and then "and"it with the output of your in range block prior to the bottom select statement (if I kept my boolean logic correct!).

 

"it appears to be counting faster than 1 second when I run the VI"

 

Do you meant that you want the loops to only run once a second?  To do this you need to change the input on your wait functions.  Right now they are effectively not doing anything since their inputs are both 0 (per your first screenshot).  If you set the input on wait function to 1000 (in ms, so that's 1 sec) the loop will run once approximately every 1 second.

 

Have a great day,

 

Chris

Applications Engineer
National Instruments
Message 9 of 11
(4,633 Views)

Quoted:

"it appears to be counting faster than 1 second when I run the VI"

 

Do you meant that you want the loops to only run once a second?

 


 

Hi again Chris,

 

What I meant was that the numeric indicator box on the front panel was literally increasing its value faster than by 1 unit-per-second

e.g. if I set a stopwatch, the number might count to 9 in about 5-6 seconds

 

Your advice on the previous matter matches some advice that I just received on another forum.  I will test this out tomorrow when I am back at the DAQ computer.

 

Thanks and have a great night!

0 Kudos
Message 10 of 11
(4,631 Views)