LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

REQ: Example of Dig Pulse Train where PWM varies.

Solved!
Go to solution

I use hardware that doesn't do buffered DIO or have counters.  I just use a loop at a fixed cycle time (200 ms, say), and have the loop turn on the output for a fraction of the time then turn it off.  So if the PID called for 45% power, I would turn to DO on, wait 45% of 200ms, then turn it off.  A case structure handles 100% (turn on and leave on) and 0% (turn off and leave off).  This works on any hardware with a digital output.  There is a limit to how fast the loop can run, but this is not important with heaters, where 5 Hz is plenty fast.

 

-- James 

Message 11 of 15
(1,090 Views)

Glad you posted - I'd forgotten to upload this code.  Here it is.  It allows you to adjust the frequency and duty cycle continuously and enable or disable pulse train generation.

Message 12 of 15
(1,089 Views)

jdpowell: Have you considered having the output of your controller determine the speed of the loop instead of having set 200ms interavals?  For instance, if your Duty Cycle Frequency were 1Hz and your determined duty cycle output was 80%, you could assert your DO then wait for 800ms and on the next loop iteration deassert your DO then wait 200ms.  That is how I was thinking about doing it until I realized I had buffered outputs and decided to take advantage of that since I never had before.

 

Idk...there are a billion and 1 ways to do PWM.  I still think my op-amp circuit is my favorite because it uses those Analog Outputs which I never seem to have any use for in my projects.  Counters and DOs are used a LOT though.

 

nathand: thanks!  I'll check it out.

0 Kudos
Message 13 of 15
(1,069 Views)
jdpowell: ahh wait..nvm.  I see what you are doing now and it seems simpler than what I was suggesting.
0 Kudos
Message 14 of 15
(1,065 Views)

Yes, I actually generally do have the PID loop set the speed of the power output cycle.  My temperature measurements are about every 1.2 seconds, so that is the time.  However I recently started to use a separate 200 ms loop with Peltier thermoelectric cooler modules because I was worried about thermal cycling on a 1.2 second time scale causing wear on the tiny thermoelectric elements.  Both methods should work fine with standard heaters.

 

-- James 

0 Kudos
Message 15 of 15
(1,064 Views)