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.

Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

Control PWM idle state

I need to be able to turn off and on the pwm with 1ms intervals, is this possible?

Presently, I can control the wdiths of the pulses at that resolution, but I cannot turn the pwm off.  How do you do this?
0 Kudos
Message 1 of 3
(3,372 Views)
It'll help to know what board you have and more details about the app.

The simp-lest approach is software-timed.  Stop the task (but don't Clear it) to turn PWM off.  Start it again to turn it back on.  This method allows you to vary the timing between on and off cycles.  However, you won't be able to get absolutely reliable 1 msec intervals without a real-time OS. 

Another approach is to configure your PWM generator to be "pause-triggered" by another counter.  Your PWM generator will then produce output only when the other counter's output is, say, high.  This method allows you to produce precise and repeating on-off cycles.


-Kevin P.
CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 2 of 3
(3,367 Views)
Hi Kevin -

Thanks for the expanation and tips.  I'd like to elaborate a little bit to help TEster out:
  • A software-timed task (one that turns the pulses on and off using commands in the program) will be very slow, event with the LabVIEW Real-Time OS.  The Windows OS has a jitter of about 10 ms.  This means that if you want to turn a pulse on, then off every 1 ms, it could take up to 11 ms to perform.  LVRT is deterministic, so it executes a timed loop in exactly the same amount of time, every time.  But it isn't necessarily faster than Windows.  This Developer Zone article discusses LVRT benchmarks in detail: Benchmarking Single-Point Performance on National Instruments Real-Time Hardware
  • As you said, a DAQ or counter/timer device has onboard counters that can be paired to generate a hardware-timed PWM signal.  This is a MUCH faster output with deterministic timing, since it's driven entirely in hardware.  A simple modification to a DAQmx shipping example yields the result (attached).

David Staab, CLA
Staff Systems Engineer
National Instruments
0 Kudos
Message 3 of 3
(3,357 Views)