01-13-2010 07:39 PM
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
01-14-2010 03:45 AM
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
01-14-2010 11:23 AM
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.
01-14-2010 12:45 PM
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?
01-14-2010 12:52 PM
01-14-2010 12:53 PM
thanks,
is there a way to do without using the wait time at all?
01-15-2010 06:47 AM
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