ni.com checkout is currently experiencing issues.

Support teams are actively working on the resolution.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Queuing strategy to manage 3 cases for commands to VISA.

Hello,

     I am hoping this problem is a simple one and my inability to properly describe it is why I haven't had any luck in searching for a previous answer.

 

Myself: 

     I'm a graduate student (after 15 years in industry), however, I have no prior LabVIEW experience. In an effort to gain experience as fast and efficiently as possible, I have taken CORE 1 and CORE 2 online courses.  (I'm not through all the exercises yet though)

My Project:

     I inherited a biaxial testing device that needs significant revisions to the VI.  I have avoided asking many foolish questions that were a result of the 3 embedded sequence structures,  I've deleted those and replaced them with a state machine.  Super happy to be this far.

The Device:

     I'm controlling a biaxial testing device which measures force and stretch along two axes.  The part of the VI I am rewriting is the motion control.  (Thus I have only included a couple screenshots of the relevant code.  I can post the whole VI, but it doesn't seem necessary.)  The control strategy I am implementing is simple: the motion of each axis is started and then the force from the load cells is compared to the desired setpoint.  When the setpoint is reached, each axis is shut off individually.  This is 2 of the string commands I need to send to VISA.  The third command is the safety stop, which stops both axes in case the force is never reached.

My programming Challenge:

     I will never know which of the three cases will happen first, therefore, I thought this could be managed by a SubVI as only 1 caller can use it at a time.  Couple issues:  how do I send 3 different signals to the same input  (See the broken line in the screenshot)?  Also, if the SubVI is busy with one case, and another case is ready, will it execute this second case once it finishes executing the first case?

     Any advice or strategy is welcomed, this seems like a simple problem, but I haven't figured out a way to manage it yet.  I suspect going to a queue system may be the way to do it, but thought I would ask if there is a simpler way first. 

 

Thank you,

-Jason

Download All
0 Kudos
Message 1 of 4
(2,190 Views)

I am leaving on travel, so I will make some general comments:

  1. Since everything is in a single loop(what you have shown), you shouldn't need local variables. Read values via shift register. (You can bundle them all up into a giant clustersauros). It may not be a problem now, but it is good practice.
  2. I am a bit confused by your logic.
    1. Where are you reading the Forces? How is it being updated? You are reading every 10 ms, but in your other picture you say it takes 100 ms to respond to a command.
    2. What happens if one of your loops get stuck? That is, what if the force never reaches its setpoint? You will be stuck. Think about putting a timeout in your loops. That is, you are reading every 10 ms, assume a timeout of 1 s, then after 100 iterations of your loop, stop it. (this is one suggestion, there are other ways to do this.)
  3. You can combine your outputs from the 3 while loops into a boolean array. You wll need to change the numbers to booleans. Then convert the array to a number. You then act on that number. For example, 1 means stop X-axis, 2, means stop y axis, 4(or 3) means stop both axises.

Without seeing the other parts of the code it is difficult to offer other suggestions.

 

mcduff

0 Kudos
Message 2 of 4
(2,170 Views)

mcduff,  

     Thank you for the reply, I chose to leave the rest of the code out, I suspected that providing it would be opening up a big can of worms. The rest of the code is functional, but it needs some (or a lot) of work and it would be distracting.  The couple screen shots I provided were already more distracting than I thought they would be.  To answer some of your comments:

     Great suggestion to remove the local variables that are reading the Load Cell forces.  I'll make that simplification when I get the state machine running and gain some confidence with it.  This is the first state machine I've ever built.

     Regarding the timing, the 10 ms sampling of the analog load cell signal is a random number I picked to get started. I plan to adjust this in the future.  The 100 ms in the visa execution loop is there to give the motor controllers some time to execute the commands.  I'm not confident I can send back to back visa commands without causing an error.  I thought a short pause would help with this (at least for the short term until I can learn more about the VISA subVI and figure out if it is written correctly).

     The logic to shut off all the loops had not been added yet.  I have been so frustrated with trying to send 3 commands to one input that I was focused on that part of the code and not worried about the rest of it yet.  The updated screen shot has the shutoff logic included, I'm sure no one is going to like the additional local variables I used.  

   Many thanks for the Number to Boolian Array suggestion, this was exactly the simple information I needed to move forward.  My exposure to all the various nodes is limited, I have not come across this one until now.  I'm not sure if I used it correctly, but the wires aren't broken anymore.

     I am now cleaning up some random errors so I can run it and start troubleshooting.  I'm hoping to get some basic functionality yet tonight.  

Thanks again, I'm super appreciative for any comments.  One thing I'm lacking is a Labview mentor/peer, the professor who used to teach it retired a few years ago, and there is currently no other users that I know of. Having peers would spare me from asking basic questions on the forum, but alas, everyone here is my only resource.  As is usual forum etiquette, I will search first and ask last.  

Thanks,

-Jason

0 Kudos
Message 3 of 4
(2,141 Views)

You did the number to the boolean array different than I was intending. You can cut out all of the number to Boolean array functions and just or the numbers directly. The Boolean functions work with integers besides Boolean.

 

good luck

mcduff

0 Kudos
Message 4 of 4
(2,129 Views)