LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to account for a broken sensor

I have 3 sensors coming from 3 com ports to my lab view program. I have all the sensors going into the same loop for the data to be time stamped and saved. Currently if one of the sensors stop working the program slows dramatically and does some weird things since no data is coming in.

 

So, I was wondering if someone could suggest a way to put NAN values for when a sensor stops working or gets unplugged from the computer so that the program will continue to work properly for the rest of the sensors. Also, it would be nice if I could find a way for the program to check occasionally to see if the sensor has started working again.

 

Thanks for your help.

0 Kudos
Message 1 of 7
(3,425 Views)

could you post your code?

0 Kudos
Message 2 of 7
(3,418 Views)

sure. I attached the main code.

0 Kudos
Message 3 of 7
(3,410 Views)

Sorry, that was the wrong code. This is the correct code.

0 Kudos
Message 4 of 7
(3,409 Views)

if communication is disrupted with one sensor, I'd expect the next call to serial read to time out.  If your timeout value is longer than your sampling interval, it'll disrupt the sample pacing.

 

Two basic possibilities

 

1) put each device in its own loop.  If one times out, it won't hold the others up.  You'll probably want to synchronize the loops, so this looks like more work, but perhaps .

2) reduce the timeout value to less than the sample interval.  handle timeout errors and report NaN to the log for that device.

 

Is it reasonable to reduce the timeout to less than the interval, or will that result in spurious timeouts?

-Barrett
CLD
0 Kudos
Message 5 of 7
(3,394 Views)

I thought about the first one, but I was not sure if the time stamps would be the same and I was not sure if there would be a problem still since no value would be passed to the consumer loop.

 

For the second idea... I am not sure. I am a novice still with LabView I think. But, logically it does sound like there could be a problem. Perhaps I could try it or try making the timeout = to the interval. I am not sure how to change the timeout value though could you please explain how to do that?

 

Thanks for your help.

0 Kudos
Message 6 of 7
(3,367 Views)

The question about whether you can shorten the timeout depends on the device itself.  How long does it usually take to respond? How consistent is that timing?

 

 

the first step you should take is to handle/log errors so that you know what is happening.  When it fails, is it a communications error (e.g. serial read returns an error), or is it a functional problem (instrument returning NaN codes)?

 

 

If this CSAT3 is the campbell sonic anemometer (http://www.campbellsci.com/documents/manuals/csat3.pdf), make sure you read and understand the serial protocol it implements very well. Note especially table B-8 where they give the codes for "not available" and "lost trigger".  Since the 5th word is used one way for these fault conditions and another way for normal conditions, if you aren't looking for 0xF000 or 0xF03F in word 4 (and 0x8000 in 0-3), you'll wind up trying to decode its NaN signal as -65.536 m/s. 

 

 

 

I can't see your subVIs, so I don't know how you've configured it, but the timeout is a setting you apply to the serial connection when you initialize it. Default is usually 10 seconds.

-Barrett
CLD
0 Kudos
Message 7 of 7
(3,345 Views)