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: 

Time sensitive pwm

I am trying to write a burst fire pwm control for a 60W incandescent light bulb (and eventually a heater). I'm using the cRIO digital I/O module hooked up to an SSR (not zero-crossing). I've tried in both FPGA and the scan interface, but I've had problems in both. In my first attempt, the light shines and dims/brightens as expected, but there is another pulse every so often that makes the light even brighter. I have no idea where that comes from. In the second attempt, it doesn't do at all what is expected, it flashes at what seems like arbitrary times even when the duty cycle is 0%. I realize that my code isn't very precise on timing. How do I control the timing of the loops to be equal, and is there something else wrong with my code?

Download All
0 Kudos
Message 1 of 5
(2,178 Views)

There are many different ways to accomplish a PWM on a crio, but the simplest way is to use a loop timer. Please look at the "PWM Out, Simple - cRIO" example in the Examples Finder. I have attached the main program to give you a previes.

PWM CRIO.png

0 Kudos
Message 2 of 5
(2,163 Views)

Thanks for the response. The example looks pretty similar to my FPGApwm vi. The timers work, but it seems like the cycles of the while loop as a whole have inconsistent timing. Something is happening to make the light pulse inconsistently.

0 Kudos
Message 3 of 5
(2,158 Views)

You should really be using a timed loop for your FPGA code. Depending on your clock speed, you are probably hitting the limit of while loops with delays. Please check out this whitepaper from NI.

0 Kudos
Message 4 of 5
(2,156 Views)

My problem with using a timed loop was that I couldn't write to my digital node in it. What is the best way to go about doing that?

0 Kudos
Message 5 of 5
(2,149 Views)