Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

No 1 or 0 Duty Cycle on NI-6221? (DAQmx Error: Pulse duty cycle specified is not supported, Status Code: -200684)

Hi,
We are trying to do PWM over the Counter Output of a NI-6221 PCI (68 Pin) Card.
The included example, i.e. DigPulseTrain-Cont, works fine, but it is impossible to set a duty cycle of 1.0 or 0.0 -
when trying to set it with DAQmxWriteCtrFreq, the program crashes (here for 0.0):

DAQmx Error: Pulse duty cycle specified is not supported for this device given the pulse frequency and Counter Timebase Rate.
Data:  0.000000
Specified Range Minimum:  75.0 e-6
Specified Range Maximum:  999.925000 e-3

Task Name: _unnamedTask<0>

Status Code: -200684


Can anyone give advice on how to accomplish this? The modified example code is attached, interesting Lines start at 94.
Thanks
-Jan

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

1. This is a physical limitation of the pulse generation hardware.  The minimum allowed low time and high time for a pulse train will be 2 edges of the timebase clock.  True 0 is not possible.  (There is a similar maximum equal to the largest 32-bit unsigned int).

2. Many external devices won't show any difference in behavior between 100% duty cycle and 99.98% duty cycle.  In these cases, you just accept the limitation and keep your data acq tasks and software fairly simple.

3. Another idea might work to give true constant-high or constant-low, but I'm not near hardware to be able to test & verify.  The concept goes like this:

a. Configure your PWM output to be pause-triggered by a static digital output bit.

b. In software, you'll normally set that bit to mean ON before starting the PWM task.

c. When you want a true 0 or 100% duty cycle, you'd first change the pulse properties on the fly so that your desired state is the Max allowed value and the other state is the Min.  The output will very soon be going to the state you desire and staying there for a considerable duration.  Your job is to wait just long enough for it to get to the desired output state, then turn the pause-triggering digital output bit to OFF before it leaves that state.

d. Hope that pause-triggering is implemented on the input side.  If so, then setting the pause-triggering bit OFF prevents the pulse generation from reacting to timebase clock edges.  Thus it remains stuck at the desired output state as long as you wish.  If it's implemented on the output side, the PWM output might always revert to idle state when the pause trigger is OFF.  Then you could generate a true 0 but not a true 100.  I would think it's more natural and sensible to implement on the input side though.

-Kevin P.

***  edited for clarity  ***

Message Edited by Kevin Price on 12-14-2006 10:52 AM

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 2 of 5
(5,218 Views)

Too late for another edit, but just remembered one other point to make.

When you change the output pulse specs on the fly, you must allow the counter to generate 1 full cycle of output with those specs before you change them again.  This could affect what you do when trying to revert from, say 100% to 80%.   I believe there's a DAQmx property buried deep, deep down in one of the DAQmx Property Node menus that you can query to find out whether it's ok to change pulse specs yet.  You may need to monitor this to decide when you can revert back to 80%.

All this may lead you to choose a time value much smaller than the max possible, which may be as much as minutes or hours.    You really just need to hold your desired state long enough to (a) detect it and (b) toggle your digital pause-trigger bit OFF.   With care in coding, 250 msec or less should be enough.

An alternative if you must get from 100% to 80% as fast as possible: toggle the digital pause-trigger to OFF, stop the pulse generation task (don't clear it!), write the normal pulse parameters down while the task is stopped, re-start the task.

-Kevin P.

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 3 of 5
(5,210 Views)
Thanks for the quick answer!
-jan
0 Kudos
Message 4 of 5
(5,208 Views)

It may work to Stop the task, then use its Idle state as Low to have it at 0 duty cycle or Idle state as High to have it at 1 duty cycle.  I do not know if the Idle state can be changed after the task has been configured.

Stopping and changing the Idle state if necessary and restarting the task is probably slower than changing the duty cycle using property nodes.

 

Steve

 

0 Kudos
Message 5 of 5
(4,207 Views)