From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, 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: 

DAQmx in LabVIEW: PWM 0% Duty Cycle at end of program

I have a slightly modified PWM code "Complete PWM.vi" I stole from: http://zone.ni.com/devzone/cda/tut/p/id/2991

I'm using a DAQCard-6024E and the Duty Cycle cannot be set to 0% just 0.001% or else I get an error.  But even if I could set it to 0% as soon as the task stops the counter pin returns to a solid 5V.

I am controlling a heater in my application, and this is undesirable because I don't want the heater to be full on when the program is aborted Smiley Indifferent.

Is there a way to set the output of the counter pin to just 0V?  I have tried using a pull down resistor w/ no luck.  I've tried changing the counter into an input with no luck.

The only solution that I have found so far is using one of my digital IO pins.

1. Wire a digital IO pin to the ground of my circuit.
2. When program starts set the digital IO pin to be an output and set the value to 0. (not inverted).
3. Run the PWM loop with the digital IO pin sinking the current.
4. After the user stops the loop set the digital IO pin to 1 (5V) before terminating the program.

This works, however I have some problems with this setup:

1. I don't feel comfortable with this in regards to failure mode.  If the digital IO pin fails to source 5V because of hardware failure and the counter pin sources 5V as it does by default then I have an out of control heater that is heating up.
2. It waists a digital IO pin.
3. I don't think that my digital IO pins can sink as much current as the digital ground pin can.  I seem to be able to still assert my relay fine, but that bothers me.

Is there a work around for this so that the counter pin is grounded when not in operation?

thanks!
-Nickerbocker
0 Kudos
Message 1 of 5
(2,911 Views)
Nevermind.  The Idle state needs to be set to Low, not High :P.
0 Kudos
Message 2 of 5
(2,904 Views)
Is there anyway to force a counter into an idle state in the middle of operation without stopping the task?
0 Kudos
Message 3 of 5
(2,902 Views)

Hello Nickerbocker. 

You can force the counter into an idle state in one of two ways.  First, you can use the Counter Gate to disable the count.  When the gate is high, the pulses can be counted and when the gate is low, the pulses will not be counted.  You could also use the pause trigger to pause the counter acquisition.  This can be done with DAQmx triggering property nodes, namely Pause.TrigType and Pause.DigLvl.Src.

Let me know if this answers your question completely, or if further clarification is necessary.  We would love to help. 

Have a great day!

Brian F
Applications Engineer
National Instruments

0 Kudos
Message 4 of 5
(2,884 Views)
An example is always useful.  Currently what I have done is setup the task to "stop" when the duty cycle is 0 and than restart when the last loop's cycle duty cycle is 0 and the current loop's duty cycle is not 0.  The "=0" and "Not=0" gates make me nervous when dealing w/ a floating point data type Smiley Indifferent

I think your solution may be more graceful but I'm not sure I follow how I would apply the triggering.  Are the counter gates input only, or can I set them in my program.  I'd hate to have to waist a digital IO pin.

Also, w/ my hardware I get a lot of errors along the lines of "do not change the duty cycle until the current operation is complete."  This error especially became a problem once I added my start and stop task code that gets me my 0% duty cycle.  I had to disable listening to errors all together, which isn't ideal.  Is there anyway to only block out that particular error message w/o ignoring all errors?

Attached is my current code.  The "false' segments of my conditional blocks are just "wired through."
0 Kudos
Message 5 of 5
(2,877 Views)