LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

stop the program

Solved!
Go to solution

hello

i have a labview programworking as follows

the labview program will be waiting until certain threshold is detected like if the voltage is greater that 5 volts

then it will send the an sms message using a gsm modem through VISA

the threshold voltage may last for hours and i want only one message to be sent while the program is always looking for that thresold

i need the prgram to be running continously as i need to monitor the home via labview

so what programming i can do

i think its simple but i cant reach it 

looking for ur help

🙂

 

0 Kudos
Message 1 of 12
(2,666 Views)

@duaa wrote:

i need the prgram to be running continously as i need to monitor the home via labview 


(I assume that you have a big while loop, and are not using the "run continuously" debug mode.)

 

All you need is a shift register or feedback node to keep the reading for the next iteration. Wait until you see if the old value is below and the new value above the threshold and only sent a message under these conditions.

0 Kudos
Message 2 of 12
(2,663 Views)

here is my program

i want to send a message only when the ouput of the comparator is true and only one time until the value changes and come back to true.

but i don't know how to program it 

i tried to use shift register but i dont know how to use it and what values should be connected to it ! 
could u help me pelease

the program inside the case structure is to send an SMS using GSM modem  

0 Kudos
Message 3 of 12
(2,625 Views)
Solution
Accepted by topic author duaa

To detect the transistion you want to look for the situation where the current value of the comparison to the threshold is in one state and the previous comparison is in the other state.

 

You should have a Wait function in the False case (or just one outside the case structure with values inside each case). Without it the loop will run as fast as possible consuming all available CPU resources at least in one core.

 

Is there a reason you have three Writes rather than concatenating all the strings and just doing one write?  Normally opening and closing the serial port inside a loop is not a good idea.  You indicated that the system may be idle for hours between messages so it may be OK here.  What if the serial port configuration fails because some other program is using it or the GSM device fails to respond?  You are not doing any error handling.  A remote system which runs for long times should have robust error handling.

 

Lynn

 

transition.png

Message 4 of 12
(2,613 Views)

Lynn beat me to the punch.

The "and" solution posted is the easiest way to accomplish this without changing your code too much. You're basically using your current and last measurements to make the decision to execute the VISA code. In order for this to happen, the previous measurement should be <= threshold and the current measurement should be > threshold.

Lynn is right about controlling speed of execution in the false case. Since you'll spend most of your time in the false case, your processor will be pegged if you don't.

I noticed the "<" function in the code you posted as well, which would have executed your VISA code immediately if your measurement started off below your set threshold.

Good luck.

TR

><><><><><><
Tommy R.
><><><><><><
0 Kudos
Message 5 of 12
(2,606 Views)

actually in my program i need tosend an SMS if the received voltage is less than 2.5v andtus wy i am using less not grater "<" in my code
for the false case i will put a wait for 1000ms is tis ok ?
about writing all in one visa write, i didnt do that becasue the GSM modem takes time to respond to each command.
i have attached the modified program after i understood the logic of the shift register and i am afraid to run it !
i want to make sure everything is fine

 

0 Kudos
Message 6 of 12
(2,597 Views)

What is the feedback node outside the loop intended to do?  It only runs once for each time the VI runs.  Wire the shift register as I showed above and you do not need it.

 

The way you have your shift register wired its content never changes. If it never changes, it is not going to accomplish anything. 

 

A 1000 ms wait in the false case is fine.  The only issue is that you could wait up to almost two seconds after pushing the stop button before the VI stops.

 

Most likely you get only a fraction of a millisecond between commands the way you have your writes wired now.

 

Lynn

0 Kudos
Message 7 of 12
(2,593 Views)

Duplicate post due to browser/network error.

 

Lyn

0 Kudos
Message 8 of 12
(2,593 Views)

the feedback node outside to store the old data so the program can compare between the old and new data.

i am using feedback node and shift register to let the program send only 1 sms when the voltage come from the analog input (AI0) is less that the threshold( in oter words the output of the comparator is true).if the output of the comparator remains true for a long time i dont want the program to keep sending sms. 

thus what i am trying to do and it looks that i am doing something wrong

could u guide me please 

i appreciate ur help 🙂 🙂 

0 Kudos
Message 9 of 12
(2,582 Views)

Did you try what I posted?  You can change the > back of course since that is what you want.

 

The feedback node and the shift register essentially do the same thing.  One or the other should be sufficient.  You definitely do not need both.

 

Is this VI a subVI of a larger program?

 

Lynn

0 Kudos
Message 10 of 12
(2,574 Views)