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: 

SubVI doesn't enter the loop

Solved!
Go to solution

Hi im woring on a project that needs PWM signal with variable frequency, the thing is the PWM vi is working however when i used the PWM as a subVI in another program for some reason it seems to not enter the for loop inside the PWM vi any ideas why or how to solve this problem? it seems really a trivial thing but i really dont get it. its like im calling a method that has a loop in it but it doesnt enter this loop

Download All
0 Kudos
Message 1 of 7
(3,585 Views)

I ran your VI and it operated inside the For loop just fine. What makes you think it isn't running the loop?

What are your input values that you're usingand seeing an issue?

 

Your problem is your output is a single numeric value. You need to output an array of values from the subVI. You're only getting the single last value out.

Wire your Output out of the For loop and enable Auto-indexing to create an array of points.

All Out.png

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 2 of 7
(3,579 Views)

@James.M wrote:

I ran your VI and it operated inside the For loop just fine. What makes you think it isn't running the loop?

What are your input values that you're usingand seeing an issue?

 

Your problem is your output is a single numeric value. You need to output an array of values from the subVI. You're only getting the single last value out.

Wire your Output out of the For loop and enable Auto-indexing to create an array of points.

All Out.png


I'm notricing two other things:

  1. When Ferquency has a meaningful value for PWM your delay will get very large!
  2. A delay of Inf contains a HARD Limit where LabVIEW saves is from ourselves! IDNKT moment

Capture.PNG

 

In theory there is exactly one ms timer value that is a multiple of 4294967295 the example code runs much faster than once per ms timer rollover.


"Should be" isn't "Is" -Jay
0 Kudos
Message 3 of 7
(3,555 Views)
Solution
Accepted by topic author peterRFA

So the timing and waveform are both a bit off.  something like this wold work better

Capture.PNGCapture1.PNG


"Should be" isn't "Is" -Jay
0 Kudos
Message 4 of 7
(3,541 Views)

the problem isnt with this program with with the other one the test one that used this program as subVi

 

0 Kudos
Message 5 of 7
(3,491 Views)

thanks very much

0 Kudos
Message 6 of 7
(3,487 Views)

@peterRFA wrote:

the problem isnt with this program with with the other one the test one that used this program as subVi

 


That was not exactly clear.  which vi and which loop did you think the problem was in?  The caller merely had slight timing issues and could be improved by using a waveform data type (the snippet on the left in my previous post resolved that)  The subvi was full of bugs as mentioned by all responders, replacing it with the second snippet in my last post results in the Chart showing approprate data.

 

You do know about snippets right? they are actual running code! just drag n drop to a blank block diagram and Poof vi built!  Sometimes you need to drag them to your desktop first depending on you browser.

 

You will get a missing subvi in the caller (because the name of the subvi will change) simply swap it out for the new and improved subvi.  

 

A bit of advice:  Read the help file closely on Square waveform.vi The ratio between fs and s determines the time the signal represents, keep them even and you get 1 second waveforms.  fs, Sample Frequency, must be at least 2x Frequency and the ratio between frequency and fs will also impact Duty Cycly resolution The higher your sample the better the duty cycle resolution.  So, determine the highest frequency you will use, then multiply that by 100/DC resolution (In %). to set fs and s


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