LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Barrels of LabVIEW

Matt,

Congratulations on reaching the point where you feel able to contribute by answering!

I haven't thought it through completely but I was thinking of a semaphore for each vat. Put the references in an array then just search through the array for the first available semaphore.

Lynn
0 Kudos
Message 11 of 23
(1,385 Views)
I just wanted to correct myself. The vat numbers are stored in an array which is stored inside a cluster. I'll see if I can get it to run by taking the array out of the cluster. Having an array inside a cluster is still a bit too confusing for me to work with.
 
-- Matt
0 Kudos
Message 12 of 23
(1,378 Views)

Hmmm still can't seem to figure out how to get semaphores to limit each vat to 1 barrel at a time. While the NI examples do show how to use semaphores, I can't find anything quite like what I am trying to accomplish. All the examples restrict usage to 1 subVI at a time or one section of code contained in a loop. There isn't one that shows how to properly "protect" particular values (vats in my case) in an array.

-- Matt

Message Edited by LabViewNubie on 02-09-2007 01:52 PM

0 Kudos
Message 13 of 23
(1,363 Views)
Matt,

Can you post your most recent effort with some comments about where it fails to work as you want? It may be easier for us to suggest modifications to your code than just to drop a hint.

Lynn
0 Kudos
Message 14 of 23
(1,347 Views)
Sure! I understand how extremely difficult it is to not have the program in front of you.
 
The Tank Assigment & Wait.vi contains a cluster that contains an array of values. The first column is the destination tank (vat) number and the second column is the wait times associated with each vat.
 
There are 4 different barrel types, each barrel type with 3 different sizes, and barrel type 2 can either be delployed quickly or not. Not all barrel types are always used, but sometimes up 4 barrel types can have a barrel deployed.
 
Now where I start banging my head against the desk
 
The 4 re-entrant VIs take these numbers and sends them into a queue where a lift one by one processes them (I left out the code to move the lift to help simply the VI). The problem right now is that there can only be one barrel per vat and I can't find a way that gets the program for instance, to keep from dropping off a Barrel Type 1 into a vat that already contains a Barrel Type 2. I somehow need to keep the re-entrant VIs from sending a command to drop a barrel into a tank that already has a barrel in it. Each barrel type has to move from tank to tank in the correct order.
 
I appreciate you helping me and I hope I described it well enough. I'm just not quite "there" as far as realizing what all you can do in LabVIEW.
 
 
-- Matt
 
 

Message Edited by LabViewNubie on 02-09-2007 03:08 PM

Message Edited by LabViewNubie on 02-09-2007 03:10 PM

0 Kudos
Message 15 of 23
(1,342 Views)
I realize globals are dangerous, but what if I just had 4 global variables, one for the current position of each of the 4 barrels. When the vat # is getting passed into the re-entrant barrel VI, I could compare the destination vat # with the 4 global variables that contain where all 4 barrels are currently located. If the vat number coming in matches one of the global variables, I just set a delay.
 
When the lift moves a barrel, it updates the global variable.
 
Since the lift only operates on one barrel at a time, if I just have it write the global variable after making the move, a race condition can't surface, right?
 
-- Matt

Message Edited by LabViewNubie on 02-09-2007 03:29 PM

0 Kudos
Message 16 of 23
(1,329 Views)
That is basically what I was thinking of using the semaphores for.

Lynn
0 Kudos
Message 17 of 23
(1,316 Views)

Hi Matt,

      Be careful!  In the scheme you proposed, two barrels may want to move to the same [empty] vat at the same time - and they could both decide it was safe to move there. Smiley Surprised

I liked Lynn's suggestion of having a semaphore for each vat.  Keep them in an array, either pass the array to the barrels on launch, or have this Semaphores-array in a Global.  Force Barrels to acquire the specific Vat-semaphore before issuing the Lift's move-command.  I'd have the Lift-driver release the semaphore as it unloaded a Vat.  I'd also make the lift smart-enough to know when a vat was occupied - and raise an alarm if it received an illegal move-command.

... not that that could ever happen! Smiley Wink

Cheers!

"Inside every large program is a small program struggling to get out." (attributed to Tony Hoare)
Message 18 of 23
(1,304 Views)
Okay I think it clicked now. I hadn't seen multiple semaphores being used within an array and got confused. Thank you both for your invaluable help!
 
-- Matt
0 Kudos
Message 19 of 23
(1,282 Views)

In fact, the search string " +labview +semaphores +array " on google brings up this very thread as the first two responses. Crazy internet tubes!

So is storing semaphores in an array not something one typically does in LabVIEW?

 

-- Matt

Message Edited by LabViewNubie on 02-12-2007 11:35 AM

0 Kudos
Message 20 of 23
(1,269 Views)