02-15-2017 01:19 PM
Hello,
I would like to start and stop current/power monitoring upon receipt of a UDP message (start/stop). I used an event structure which should trigger the power monitoring code when it receives start message. But unfortunately, it does not get triggerred. What is possibly going wrong here?
02-15-2017 01:22 PM - edited 02-15-2017 01:24 PM
The event structure will fire whenever something happens to the control called "Start Montioring". That would be a user entering data on the front panel (even if it is the same data), or the program writing a value to the "Value (Signalling)" property node.
I don't see where either of those things are happening in your VI.
You shouldn't be using an event structure here. You should be using a case structure.
02-16-2017 07:26 AM
I tried with the case structure. But it seem to fire only once. I need the monitoring to continue until I receive a stop message.
02-16-2017 07:53 AM
Put a timeout on th UDP read message. That will keep the loop iterating. When it reads a start message, it sets a flag that is maintained in a shift register to tell it that it is in read mode. When it reads a start message, it puts a false into the shift register to put it into "not read" mode. When the UDP read times out, it just uses whatever value is in the shift register.
02-16-2017 07:58 AM - edited 02-16-2017 07:58 AM
Hi JohnDoe,
I need the monitoring to continue until I receive a stop message.
Then you need to program this algorithm!
All you need is a shift register keeping the last state of your routine…
WHILE data := UDPRead() IF data == "START" THEN state := TRUE IF data == "STOP" THEN state := FALSE IF state THEN do DAQ ENDIF WEND
02-16-2017 09:02 AM
I now understand that I need to keep the state persistant by using a shift register. Unfortunately, I could not find the shift register block in the express menu. Like the while loop I cannot even right click on the border and create a shift register. Do you suggest me to add another while loop around the case structure? or any other alternative way? I am using Labview 2009.
02-16-2017 09:56 AM
02-16-2017 10:57 AM - edited 02-16-2017 11:00 AM
I am sorry, I misunderstood. I thought the shiftregister is suppossed to be inside the first while loop. Anyways, I added a shift register and get back.
02-16-2017 11:40 AM
I have now added the shift register but still I do not see anything in the waveform chart. I did the highlight execution, retain wire values and single step. It looks like it seems to perform like it should, but still no waveform visible. Could you please check again and let me know the issues.
02-16-2017 11:46 AM
First, get rid of the Rube Goldberg that you have where there is a Select statement and the True and False constants. Just use the boolean wire, it does the same thing!
The second thing is that you forgot an important part of what I told you in my message. You need to put a timeout value on the UDP Read. The -1 timeout value means wait forever. Pick a value that is comparable to how fast you want the loop to run. You may need to experiment and make it either a little higher or lower. It should probably be just a slightly smaller value than the time associated with the amount of data you are collecting in the DAQ functions.