07-07-2023 03:11 PM
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.
Thanks.
Solved! Go to Solution.
07-07-2023 03:25 PM
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.
07-07-2023 03:41 PM - edited 07-07-2023 03:42 PM
@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.
07-07-2023 03:52 PM - edited 07-07-2023 03:52 PM
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.
07-09-2023 02:21 PM - edited 07-09-2023 02:58 PM
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~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
07-10-2023 12:50 PM
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.
07-10-2023 01:44 PM
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 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~