03-29-2016 12:05 PM
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
Solved! Go to Solution.
03-29-2016 12:11 PM - edited 03-29-2016 12:15 PM
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.
Cheers
--------, Unofficial Forum Rules and Guidelines ,--------
'--- >The shortest distance between two nodes is a straight wire> ---'
03-29-2016 01:20 PM
@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.
I'm notricing two other things:
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.
03-29-2016 01:49 PM
So the timing and waveform are both a bit off. something like this wold work better
03-30-2016 03:27 AM
the problem isnt with this program with with the other one the test one that used this program as subVi
03-30-2016 03:29 AM
thanks very much
03-30-2016 03:53 AM - edited 03-30-2016 03:55 AM
@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