LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Configure timed loop from another front panel

Solved!
Go to solution

Hello,

Basic question here. Is it possible to configure a timed loop (period, priority, deadline, etc.) in one vi that has no front panel from the front panel of another vi? I just wanted a numeric control on one front panel that can make those adjustments while the program is running. It sounds really easy but I was having some trouble doing that.

Any help would be very greatly appreciated.

0 Kudos
Message 1 of 21
(4,037 Views)

The easiest way would probably be a shared variable. You could also use a functional global vi or a global variable for that matter.

0 Kudos
Message 2 of 21
(4,013 Views)
Solution
Accepted by topic author nano_era

On the subvi where the timed loop is, create controls for each parameter you want to set.  Connect these controls to the terminal pane.  Pass in values from the main vi.  No need for shared variables or globals.21555iB0F6442F9814575E

- tbob

Inventor of the WORM Global
0 Kudos
Message 3 of 21
(4,010 Views)

Thanks for the replies.

I was wanting to have a slider on one front panel that controls these parameters on a loop in another vi. I understand what you are saying. I am just having trouble making it happen, as silly as that may sound. If you could have a few more images or instructions that would be very greatly appreciated.

0 Kudos
Message 4 of 21
(4,001 Views)

May want to post what you have. I was assuming you had different loops or even parallel VI's. If it is a sub vi of the main vi, tbob's solution would be the best.

0 Kudos
Message 5 of 21
(3,988 Views)

Well, the loop I want to control is inside a subvi, which is inside the other vi. On that other vi, I want the front panel to have a slider that allows the user to adjust the sub vi loop, without having to go back into the development environment. I only want to be able to adjust one of the loops, a loop that is vital to the program.

Yeah I know this is a simple one, but I am having some trouble with it as I have progressed thus far without having done this before. I am sure I will be able to do it. I was just confused on exactly how, as I had been trying to use global variables with no success.

0 Kudos
Message 6 of 21
(3,977 Views)

Hi

Could you specify a little bit more what you want to do?

 

When do you want to change the period of the timed loop? Do you want to set the period in the main VI, run the sub-VI with the timed loop and then the next time the sub-VI executes use another period? Or do you want to be able to change the period of the timed loop while still running it?

0 Kudos
Message 7 of 21
(3,965 Views)

If you want to change the timed loop parameters while the timed loop is running, I would recommend a queue-based system.

 

In the VI with the GUI:

 

  • Initialize a queue which contains a cluster of an enum (the command) and a variant (the data).
  • Use an event structure to capture UI events
  • When something changes (e.g. the frequency to run the loop) enqueue the appropriate command and data (e.g. changePeriod, 25 cycles).

 

In the VI with the timed loop:

 

  • Dequeue the same queue with a timeout of zero inside the timed loop.
  • If the queue times out, do nothing
  • If the queue contains something, use the command to switch a case structure and the data to set whatever needs to be set

 

You can either use a named queue or pass the queue reference from the GUI VI to the loop VI at startup.

 

Good luck.  If you need more information, let us know.  If you have never used queues, you may want to read up on them in the LabVIEW help and check out a few of the examples.

 

If you are doing this on RT, you may want to use the RT FIFO instead of the queue.

0 Kudos
Message 8 of 21
(3,956 Views)

@AndersSvensson wrote:

Hi

Could you specify a little bit more what you want to do?

 

When do you want to change the period of the timed loop? Do you want to set the period in the main VI, run the sub-VI with the timed loop and then the next time the sub-VI executes use another period? Or do you want to be able to change the period of the timed loop while still running it?


The latter is correct.

The sub vi inside the main vi will execute and so will its main loop. While that loop is running, I would like to be able to change its parameters from the front panel of the main vi. This is important for what I am tring to do. I cannot really share the code, but I am sure that it is a simple enough task that most labview users could understand.

I was thinking, would it be better to wire a control to the "next iteration" box inside the loop in order to do this rather than the one on the outside?
Either way, after I wire a control to the parameters I want to change, I am not sure how to link that to the front panel on the other vi. I was thinking of including some code in the main loop for the main vi that makes that happen

Basically, what is the easiest way to have that slider on the main vi front panel, control the sub vi loop parameters without stopping the loop? If someone could provide a visual example of that like the one that has been shown here but with more steps as to how to connect that control to the front panel on the main vi? That would be a great help.

0 Kudos
Message 9 of 21
(3,952 Views)

The main vi is basically just a loop with controls, calculations, and variables. Outside this loop is a call to the sub vi, which has its own main loop that I am trying to control. That being said, do I not need to use variables to acheive this?

0 Kudos
Message 10 of 21
(3,947 Views)