06-04-2012 05:42 AM - edited 06-04-2012 05:45 AM
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:
06-04-2012 07:00 AM
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.
06-04-2012 07:24 AM
I send you an private message; please check it.
06-04-2012 08:00 AM - edited 06-04-2012 08:06 AM
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...
06-04-2012 09:42 AM
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.
06-04-2012 10:28 AM
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.
06-04-2012 10:49 AM
@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.