From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

While loop and 2 device

Hi all; I have 2 devices: -usb camera (taking snap shot) -usb to rs232 converter-> on it is connected some measurement device (taking measurements) I need to control both devices independent of each other. I add both case structures for each device into "while loop". For every device I started with button (Latch when released). When program is running I need to started both device "several" times(depend of users demands) When I run it, I can take picture, also with 2 device taking measurements. But when I try to start second device to take measurements, I cannot any more taking pictures with 1 device.

 

Where is the problem and how can I solve it? Please see a part of code:

 

Untitled.png

_________________________
Rookie; LV 2011 on WIN 7
0 Kudos
Message 1 of 7
(2,557 Views)

Hello Hlod,

 

This is not the right way to do LabVIEW coding. I think you should learn some basics first.

 

Configure and close your visa and camera session outside the wheel loop. Whenever you want to acquire the image press start button and Grab the camera images no need to open and close session each and every time, Same for visa.

 

Share your VI so it will give the complete idea about the system.

Thanks and Regards
Himanshu Goyal | LabVIEW Engineer- Power System Automation
Values that steer us ahead: Passion | Innovation | Ambition | Diligence | Teamwork
It Only gets BETTER!!!
Message 2 of 7
(2,540 Views)

I send you an private message; please check it.

_________________________
Rookie; LV 2011 on WIN 7
0 Kudos
Message 3 of 7
(2,535 Views)

Yes, I agree with you Himanshu Goyal. I did already what you said, but it's the same; I cannot share VI public, but I can send to you on email.

 

The problem is that when I started 2 "instruments", camera not taking snapshot anymore; I pressed button, but first case is not started...

_________________________
Rookie; LV 2011 on WIN 7
0 Kudos
Message 4 of 7
(2,526 Views)

As you have implemented in the picture above you do not have two independent tasks. Since both case statements are within a single loop BOTH must complete before you can run another iteration. You will need to place the code for each device in it's own loop. This also means that you will need some basic messaging to control when to stop both the loops so you can exit your code.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 5 of 7
(2,511 Views)

Yes, this is one solution, but it's not good for CPU. I also have third device(event structure and inside while loop..). I can add for 1 and 2 device "wait for next loop" for 100ms, but I cannot effort this on third device where I need acquire precisions data.  For these reason I think 3 while loops are too much for computer, so for these reason I was using only one while loop for 1 and 2 device, but I'm having problem which I already described.

_________________________
Rookie; LV 2011 on WIN 7
0 Kudos
Message 6 of 7
(2,503 Views)

@hlod wrote:

Yes, this is one solution, but it's not good for CPU. I also have third device(event structure and inside while loop..). I can add for 1 and 2 device "wait for next loop" for 100ms, but I cannot effort this on third device where I need acquire precisions data.  For these reason I think 3 while loops are too much for computer, so for these reason I was using only one while loop for 1 and 2 device, but I'm having problem which I already described.


That is utter nonsense. LabVIEW is more than capable of supporting 4 parallel loops. Well written code is the key. The applications I develop have dozens, yes dozens of parallel tasks and there barely a blib on the CPU.

 

It gets a bit frustrated when a self described novice makes definitive statements like "but it's not good for CPU" despite hearing from numerous experts it is possible and indeed recommended.

 

I can guarantee you that your attempt to write a better, more efficient solution in a single loop will not meet your needs. Just think about what you are saying. You have mutliple independent tasks yet you want to do them all at the same time in the same loop. Therefore, ALL of your processing will only run as fast as your slowest task can go.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 7 of 7
(2,500 Views)