LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I execute capture once

Solved!
Go to solution

Hello, 

I´m quite new to Labview. I have a VI on RT that reads trough fpga reference data from ultrasonic sensor and controls motor. If there is a certain distance measured, it shoud stop the motor and take a snapshot with webcam. After that Im searching the image for a  QR code. Image and found data will be sent to host  with network stream. 

How can I take only one snapshot while measured distance is below the treshold? What I have now takes snapshot with every iteration of the while loop.   

Jenda02_0-1627249432932.png

At this moment it takes data from FPGA and calculates distance in cm with subvi,  then it compares it to a treshold (20). If true it should capture one image and find data from QR code. After object with QR code is removed motor shoud run again, while waiting for another object to reach the treshold. 

Is there any solution or am I completely wrong? Thank you. 

J.  

 

 

0 Kudos
Message 1 of 6
(1,486 Views)

You are triggering the capture when the threshold>20 is true.

 

You want to trigger the capture the first time the threshold>20 is true.

 

The quick and easy way is to use "NI_PtbyPt.lvlib:Boolean Crossing PtByPt.vi" (use quick drop).

 

Set the enum to false-true, and the output will only be true if the previous value was false, and the new one true.

 

 

Message 2 of 6
(1,418 Views)

You already keep the previous value of the condition (< 20) in a Feedback Node. You need to compare the current value with the previous one: only take the snapshot when the previous condition is false and the current is true.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
Message 3 of 6
(1,416 Views)

Also note that an Xor with a TRUE constant is simply a Not function:

Xor vs Not.PNG

Message 4 of 6
(1,407 Views)

Thank you for replying. It was exactly what I was looking for and I corrected XOR function. I was overthinking it a bit.

 

Now I have a bit different problem. Now I want to send data and an image trough stream so I created a writer endpoint  with cluster data type, that has image and data from it. But once I run my VI program hangs on network stream and I can´t control anything (FPGA VI is running but there is no distance info and stoping logic for the motor isn´t working, neither is QR reading). Knowing that I probably badly implemented network stream, how can I resolve this?

 

My idea was to put stream into seperate loop runing in paralel and write is activated when QR is found. Then  send cluster with image and text to this loop with  RT FIFO and send them. Could this work, or is there better solution? 

Jenda02_0-1627334233277.png

 

 Thank you,

J.

0 Kudos
Message 5 of 6
(1,381 Views)
Solution
Accepted by Jenda02

The network writer might simply hang because there's no network reader.

 

Write Single Element To Stream has a timeout, and it's -1 (infinite) by default. So it will wait...

 

I'd study the network stream a bit, maybe look at the examples.

 

Putting the network stream code in a 2nd loop can be useful. I don't think the Write should take significant time, but if you want your main loop as fast as possible, it's not a bad idea.

 

In fact, you could even put the screen capture in a 2nd loop (the network stream in there or in a 3rd loop).

 

Separating the trigger and the capture does make it easier to 'filter' triggers. If you get a bunch of triggers, you probably only want to capture once (after all, the shots of the first triggers are long gone anyway).

 

You can separate the loops with a (unnamed!) queue. Obtain the queue before all loops, enqueue in the top loop, dequeue in the 2nd.

 

Message 6 of 6
(1,361 Views)