Showing results for 
Search instead for 
Did you mean: 

Single Boolean Signal During Continuous Monitoring

Go to solution

Hi all,

I am attempting to build a feature for a VI that sends out a single email when an analog input value falls below a threshold. The DAQ is continuously acquiring data, and the whole program is running in a while loop, so the configuration as of now sends out a wildly undesirable amount of emails when the signal dips below the threshold. 

How would I create a system that sends a single email while the signal is below XYZ? Then potentially wait some period before resetting, without altering the acquisition and visualization rates? The segment handling the email configuration and sending is solid so I just need ideas for a boolean toggle/flag (?) that would go before the case structure.


0 Kudos
Message 1 of 7

One way to do this would be to have a "Time of Last E-mail" saved in a Shift Register in your main Loop.  Initialize it to 0 after you pass this value through the "To Time Stamp" function (which sets it to roughly January 1, 1904, "a long time ago".


When you find a condition where you might want to send a message, use "Get Date/Time in Seconds" to get the current time, subtract the "previous" time in the Shift Register, and if the number of seconds (which is what you'll get by the subtraction) is greater than the time since the last message, send a new message and reset the "Last Message Time", otherwise ignore the error.


If you have no errors, you will send no messages.  The first error will generate a message, but other errors that immediately follow should be "blocked" by your "Time-since-previous-message" check until that time has passed.


Bob Schor  


P.S. -- I do exactly this for a temperature-monitoring utility I have running.

Message 2 of 7

@LBerger37 wrote:

the whole program is running in a while loop


Well without seeing your code I would say that this is the root of your problem. One Big Loop (OBL) is rarely a good program architecture.


But if you can a relatively easy band-aid would be to set a flag (boolean) everytime the signal drops below the threshold AND you have sent one email. 

Check the flag every time before you send an email and if it is set then don't send the email. 

Reset the flag when the signal raises above the threshold so you can send another email next time.



=== Engineer Ambiguously ===
0 Kudos
Message 3 of 7

What you want to monitor is a transition from different states, ie, T-> F or F->T, not necessarily an absolute state.


Look at the comparison palette and the "Is Value Changed" vim. That should do the trick.

0 Kudos
Message 4 of 7
Accepted by topic author LBerger37

Can you please attach your VI? I would like to help you with this. If you don't have a code, that's fine too. You can look at what I have. Maybe it can give you an idea.


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Acts 2:38~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Message 5 of 7

Thank you for sharing your solution to this problem, it worked perfectly after rearranging it to fit in my original program. I greatly appreciate your help and also the contents of the email.  

Message 6 of 7

You're welcome LBerger37. Anytime.  It's always a pleasure for me to help others. 

Thanks for the compliment on the contents of the email. 😊


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Proverbs 16:3 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

0 Kudos
Message 7 of 7