LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

boolean to stay on/off by pulse width amount ??

Hi,

 

I need a boolean that stays on/off for a give duty cycle time or pulse width time.

 

attached is my code, but it uses the while loop wait (m)to generate , i need to put in more code inside the same loop and this wait (ms) avoids it to run at full speed.

 

tried to use square wave gen with duty cycle but doesnot give out the off time,

 

any ideas?  plz help

0 Kudos
Message 1 of 7
(3,355 Views)

Your example works only with frontpanel elements. Is it the desired functionality of the code that the PWM is displayed on the frontpanel at all?

If so, please keep in mind that UI updates are slow in general, so a PWM with 1ms pulse width makes no sense.  Additionally, even if the UI updates would be faster, you have to consider: the human eye only "samples" about 30 fps (frames per seconds meaning around 30 images a second). So the "updaterate" of a human eye in general is 1/30 = 33.34 ms. Updates occuring faster will not take any effect for the user.

So any duty cycle less than 33.34 ms will result in a visual "always off" LED. This assumes that the UI update takes less time than this value though.

 

just some thoughts,

Norbert 

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 2 of 7
(3,324 Views)

Hi freemason,

 

Try this attached VI snippet on for size. You could add some more math to the timer input, but it would basically do what you're looking for.

Jeff | LabVIEW Software Engineer
0 Kudos
Message 3 of 7
(3,307 Views)

Hi norbert, thanks for the reply,

 

yes, the chart is required but not the boolean, I am using the boolean value (ex: 900ms T-on+ 100ms T-off)  to open and close the shutter of a light source for these values of time. the chart shows the frequency and PWM widths..

 

at the same time in this loop there is other code inside which i want to run at max speed, but due to the wait(ms) it doesnot run at full speed.

 

any ideas?

0 Kudos
Message 4 of 7
(3,290 Views)
If you want code to execute at different rates, then the answer would be to use separate loops.
0 Kudos
Message 5 of 7
(3,286 Views)

thanks,

 

is there a way to do without using the wait time at all?

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

As Dennis suggested, you should use seperate loops if you have programmatic tasks to be executed in different timeframes.

Removing waiting times in loops is not recommended because this will lead to 100% CPU load at least at a single core. Therefore, you always should include waiting times in loops which run for an indefinate time. Loops which are executed a limited time (most often for loops) can possibly not include waiting times though.....

 

Norbert 

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 7 of 7
(3,256 Views)