LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Sub Vi not displaying output

I'm having trouble with a simple VI I wrote. I made a vi that is basically a pulse wave generator, with a specified amplitude, period and duty cycle. When I run the vi by itself, the voltage displays correctly. However, when I make a subvi and include it in a different project, the vi does not display the the proper voltage (it stays static at the specified voltage). Attached is the vi I have created. Is there something I have to do in order to display this voltage correctly? Thank you for your time.

0 Kudos
Message 1 of 12
(3,850 Views)

Presumably you are expecting to be able to use the "voltage" output at the higher level. Well, that won't work. When the higher level VI calls this subVI, LabVIEW is sitting inside this subVI, and the top-level VI waits until the subVI has finished. Since you have a loop inside the subVI (and WORSE, it's an infinite loop WITH NO WAY TO STOP IT OTHER THAN TO PRESS THE ABORT BUTTON IN THE TOOLBAR), then the top-level VI will only see the value once the subVI has finished - i.e., the last value. Your loop should be in the higher-level VI, not the subVI.

 

This is a basic programming question.

0 Kudos
Message 2 of 12
(3,845 Views)

A couple of pointers

  • Do not write infinite loops and depend on the abort button to stop the vi.
  • Wire to terminals whenever possible one of those write locals should wire directly to the voltage terminal
  • Im not sure what you are doing with Max voltage and Voltage anyhow.  they don't seam to have much coupling with any of the other operations in the vi.

"Should be" isn't "Is" -Jay
0 Kudos
Message 3 of 12
(3,844 Views)

Edit: So basically what you guys are saying, it's going to finish the timing diagram completely, and then output that voltage at that point? Is that why only the final value is showing? What can I do to update it continuously?

0 Kudos
Message 4 of 12
(3,840 Views)

@j00z wrote:

Edit: So basically what you guys are saying, it's going to finish the timing diagram completely, and then output that voltage at that point?


Yes


Is that why only the final value is showing?

Yes


What can I do to update it continuously?

That really depends on what you are trying to accomplish. What exactly are you trying to write? You could simply use one of the existing VIs to create a waveform. You could do the calculations at the higher-level VI. You could call this VI dynamically, and pass it the control reference for the indicator on the main VI that's supposed to be updated. You could ....


0 Kudos
Message 5 of 12
(3,831 Views)

Typically, your sub-vi will be within your "non-infinite" loop.Smiley Wink  If you just want it to execute once, wire a boolean constant true to the stop terminal; however, that negates the reason for having the while loop to begin with, doesn't it.  I'm with Jeff, I don't know what your trying to accomplish with your Max Voltage.  Wiring a control directly, or indirectly through a local variable, to an indicator makes no sense, and only use locals when necessary.  Wires are always the best way to do it.

-----------------------------------------------------------------------------------------
Reese, (former CLAD, future CLD)

Some people call me the Space Cowboy!
Some call me the gangster of love.
Some people call me MoReese!
...I'm right here baby, right here, right here, right here at home
0 Kudos
Message 6 of 12
(3,818 Views)

So with the max voltage, its just a matter of what the user wants in terms of maximum voltage. Essentially I'm trying to make a square wave that goes from 0 to the maximum voltage. I could of course change it to a constant voltage, but I just want that adaptability.

0 Kudos
Message 7 of 12
(3,812 Views)

Understood, I just don't understand why you were feeding it into an indicators local variable.

-----------------------------------------------------------------------------------------
Reese, (former CLAD, future CLD)

Some people call me the Space Cowboy!
Some call me the gangster of love.
Some people call me MoReese!
...I'm right here baby, right here, right here, right here at home
0 Kudos
Message 8 of 12
(3,807 Views)

The problem does not stem from turning your code into a sub vi. I'm afraid the code never made sense. It only appears to do what you intended it to do.

It does not create a rectangular wave at all. All it does is write zero and "Max Voltage" to an indicator alternately. If you observe this indicator ("Voltage") it SEEMS to display a rectangular wave, but it doesn't.

At any given time there is either zero or "Max Voltage" in the indicator - but there is never a wave in there. Actually a wave would have to be at least a 1D array of points, meaning it couldn't possibly be in the indicator as is.

 

Regards

Florian

0 Kudos
Message 9 of 12
(3,784 Views)

If the value alternates between two values, inherently it will be a square wave. The change between the two voltages ideally cannot be instantaneous, and theres going to be a rise time and fall time.

0 Kudos
Message 10 of 12
(3,778 Views)