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: 

labview concurrency

Hello all!

 

I have posted a fewforums earlier - but think itis best to start a new post which is more specific as opposed to updating progress. 

I have attatched my code for my football detection VI. I will summarise what I have done in my code:

 

a) The top half is just configuring the colour and the TAB settings.

b) Case one is image processing the information. It computes the speed and distence etc of the football.

c) The second case used this information and determines if the ball crossed the goal line. If it crossed the line, it is a goal.

d) Hence the VISA port is used to send a character to the USB and is wirelessly transmitted via an XBEE.

 

The program is incredibly large! The following are problems I need help in resolving:

 

1) in the case statement I want to use the x,y and radius information of the football in both cases. I thought the way I have done my code it should work. BUt it desnt and I dont know why.

 

2) My XBEE continuously transmitts charecters. I only want to ever d this once and after that wait for 10 seconds to alow people to remove the football from the goal. I know I must use a delay - but us there a more elegant way to do this?

 

3) Why is it the my stop buttons dont terminate the program completely when I have linked them all via the local variablwe???

 

Other smaller problems like speed of ball not correct and image processing algorithms will be asked when the above problems are first solved.

 

So can you guys assist?

Thanks
Saqib 

 

PS in my ZIP- ensure you browse for the VRML file I made and ensure you link the JPEG image too. The code is not working because of a local varible issue I got too. PLease help! 

0 Kudos
Message 1 of 9
(2,935 Views)

Hi Saqib,
I will try to address you questions one by one:


1. You have more than one case structure in your program, which do you mean? What do you mean when you say it does work? What are you expecting and what actually happens? Please try to be more descriptive of the problem. Maybe this information will help:


Case Structures have Input & Output Tunnels which are ways of passing data in and out of your case structure or any other structure like a loop. The data that is wired to that tunnel is the data that will be seen inside your structure no matter which case is entered.


If you have a tunnel on a loop, the data that is present in the tunnel on the first iteration will be the same for the duration that the loop structure executes. In other words, you can’t pass any data into a loop using a tunnel. This follows the LabVIEW dataflow model:


A node executes only when data are available at all of its input terminals and A node supplies data to the output terminals only when the node finishes execution. Where a node can be a function, subVI, or structure.

 

2. The Wait function is used to wait an arbitrary amount of time in your code. This sounds like what you would like to do so why do you think it is not elegant?

 

3. When using Local variables with the Boolean data type, the mechanical action must be set to SWITCH and not LATCH. You can set the mechanical action by right clicking a Boolean control on the front panel. This is why the program you have uploaded is not run able.


Your program may not stop immediately when you press the stop button because some code may be executing. You are using while loops in your code which will execute any code and THEN check the condition. If you have some code that takes a long time to finish, the loop will not be able to check the condition until it is finished and therefore it will not stop.


Kind Regards

 

Lewis Gear CLA
LabVIEW UAV

Message 2 of 9
(2,890 Views)

Thank you Lewis for your response.

 

1) Further detail in greater detail:

 

I expect in the VI I built that when I hit run, the cameras that I have set up would capture the live data (but not store them) and use the recent image to image process them. 
Once I image process them, I would be able to access data like Radius, x,y coordinates of the image detected circle.

This works well as expected - and is occuring automatically in the "default tab 1" position.

 

However: I originally thought that I could use this data, which was generated from the events in "tab 1" to feed into the program in "tab 2". I first thought that as my cameras continously image process, my data would continuously update into the program in "tab 2.Which by the way, is a football on a scaled pitch, which should move relative to the live data captured.

 

Looking at your esponse however, I have learnt that I can not use the live data I would like to, to pass into the 'loop tunnel' into page two of the "tab".

So, is there another way for me to do this? I remember a while a go where I didn't have the case structures and the "tabs" and the football model updated live, with respect to the live data from the image processing block.

 

But in doing just that - on my front panel, I had 2 outputs for my camera outputs and the football model all on the same screen, To make it visually acceptable - I made use of using "tabs" and thus wanted to make it more appealing to the use. But this is a mistake as I realise the data will just not flow and b) the code in the case is only executed when your in that case. SO again - what can I do bearing in mind that I would like:

 

a) the live information from my image processing block to feed into my football model

 

b) on the front panel, make it visually appealing by placing the 1) image processing block seperated from the 2) football model ( although in code they must still be virtually linked andthe information must be continously pssed through).

 

Is this possible, and if so, what programming function would you suggest?

 

2) Is the 10 seconds delay using a wait function elegant?

OK - I think your right. I guess when a football goal occured - I just want to kind of stop everything for 10 seconds, to give everybody time to celebrate (what 10 seconds. haha should be enough!) afte this period let the program continue again from the begining. In fact, could I just not program to reset once it reaches here? or shall I leave it as after 10 seconds, let the program continue? I gues they both do the same thing in my case...?

 

3) Why is the stop button that all vitually linked via the local variables not stopping when told to do so?
So thats how you change it! I knew it wasnt runnable too because the error mentioned about latching it. I just didn't know how to change it to a switfch. Thanks for this - I will definately change this now 🙂 And thanks for pribing me about VI not stopping instantly. I will see what I can do but it may reoslve that I remove some of the while loops and place the codes in one single loop.

 

Again, thanks Lewis. I am going to make changes this afternoon hopefully. I have a problem with my XBee and am trying to resolve this. Everything works on the breadboard!!! But not on my PCB!!! :(. I will have to trace the connections and hopefullly - when this works I will implement the changes you suggestedi nyou earlier post and the suggestions you suggest in the next.

 

Thanks a bunch !

 

Saqib

 

 

0 Kudos
Message 3 of 9
(2,868 Views)

Hi Saqib,
You can only execute one of the cases each time your loop iterates. If you would like to pass information from one iteration too the next, you can use shift registers. See this example, I think it is what you are looking to do?

To add a shift register to your loop, right-click the border and select Add Shift Register from the shortcut menu. The Right shift register stores data on completion of an iteration and the Left shift register provides stored data at beginning of the next iteration.


It would seem that your program would benefit from using a state machine. Please read this article for more information.  If you implement a state machine (which I highly recommend), it answers questions 2. You could have a state in your state machine to reset and a state to wait.


All of these concepts are taught in our LabVIEW core 1 course. It would be great if you could either come along to one of our courses or even do it online. See here for more info.


Lewis Gear CLA
LabVIEW UAV

0 Kudos
Message 4 of 9
(2,861 Views)

Thanks for that.

 

I think yoiu are right. I have had experiance with shift registers and it should work. Only problem i anticipate is that the football model will be lagging the data coming from the image processing block i think. I will try now and update you later on today.

 

Thanks 

 

saqib

0 Kudos
Message 5 of 9
(2,856 Views)

Hi Lewis

 

Quick question.

 

I have done all my work in Labview 2010 in desltop. It is an old PC 32bit HP pavilion. Really old.

 

However, I am to test my work on field - I want to do it via my LAPTOP. It is an Acer 64 bit.

 

Will I have compatibility issues. Would I be able to modify/edit code?

 

I have labviews on both PC/Laptop student edition 2010!

 

Advise is appreciated

 

Saqib

0 Kudos
Message 6 of 9
(2,852 Views)

Thanks for your help Lewis!

 

I have successfully completed whaty I wanted to acheive. I made use of your shift registers but as expected tey were delayed by one iteration.

 

Nevertheless - I completely cleaned my code, removed the multiple while loops and now with my single while loop - it is all concurrently working! 🙂

 

Now I will test this on my laptop and pray for the best! 

 

I want to ask two questions:

 

a) Will the work I have be compatible and editable on a 64bit machine?

 

b) When computing speed of an object I use speed=delta distance/delat time.

- with regards to time - Is it simply:

 

1/framerate 

 

because I can guarantee my image processing is faster than the rate of my camera, i.e. processing is at 40 fps, whilst camera is at 30fps. Hence, I dont need to consider time for processing and the time using above formula should be correct right?

 

I solved the time delay - it was just using a wait function as you suggested. I have give 20s if celbration time, and the program re-runs!

All I need to do now is just test this on field with my posts, calibrate all the data and everything should in theory work!

 

I will update you all soon.

 

Saqib 

0 Kudos
Message 7 of 9
(2,829 Views)

Update:

 

Yes, labview is working very well on my laptop which is a 64bit mahine!

 

With regards to my testing on the pitch, it was OK but I had to tweek my code in terms of image processing and the calibration. I am to later test the changes today though. It was very very difficult to get 3D information from a single camera and used crude estimates!

 

Please can one of you guys tell me though, why on my front panel my camera screens are black??? I would like to see the original live captured video and the processed images - but they are both black. The capturing and live camera are however running when i do presss run. Any good reason as to why they are black?

 

Thanks

0 Kudos
Message 8 of 9
(2,805 Views)

Hi Saqib,


Try looking at these:
Black output image of vision assistant
Thresholded Images Look Black in Vision Assistant and Other Programs

This new issue you are seeing is unrelated to the original post so it would be best for you to post a new discussion. It will help other people find the discussion if they are having the same issue and you will be more likely to get a response.


Try to keep your discussions to individual questions/problems with descriptive titles and problem details.

 

Hope this helps

Lewis Gear CLA
LabVIEW UAV

0 Kudos
Message 9 of 9
(2,785 Views)