Quantcast
Viewing all articles
Browse latest Browse all 66774

Multiple PWM output channels with variable Duty cycle including 0% and 100%

Hello,

This is my typical configuration :

Windows 7 or Windows XP. Labview 2012. PCI-6602 for 8 channels PWM generation. I am using Counter Outputs in MAX (1 counter output per task). I am also using a few digital outputs lines from the PCI-6602.

I am running tests where I need to generate 8 PWM simultaneously. The frequencies are typically between 1 and 1000Hz and the duty cycles vary from 0 to 100% (limits included!) during the tests. Frequency and duty cycles can be different per channel.

The only issue that I have is when one or more channels have to be set to 0 or 100% duty cycle (0.001… and 99.999…% are not accepted by my customers). Because those values are not accepted by the DAQmx Write (Counter Frequency 1Chan 1Samp).vi I am forced to use the following trick:

-          Unreserve the task

-          Stop the task

-          Change the task’s idle State to either Low (DC=0%) or High (DC=100%)

-          Start the task

-          Stop the task

-          Reserve task

-          And when a value <> 0 or 100% is requested then restart the task with the new duty cycle

Even worse, as soon as one of the 8 channels requires 0 or 100% I am forced to apply the procedure above to all the channels to avoid the error -201133:

Possible reason(s):

Device cannot be configured for input or output because lines and/or terminals on this device are in use by another task or route. This operation requires temporarily reserving all lines and terminals for communication, which interferes with the other task or route.

If possible, use DAQmx Control Task to reserve all tasks that use this device before committing any tasks that use this device. Otherwise, uncommit or unreserve the other task or disconnect the other route before attempting to configure the device for input or output

I have never understood why I need to reserve the tasks as they are all output tasks and not a mix of inputs and outputs but if I do not do this I keep getting this error -201133. http://digital.ni.com/public.nsf/allkb/0495B7D5E2345DF386257730007EFD17

This leads to a very cumbersome coding as you can see in the attached file. It shows what I did for the ‘simple’ case where I have only 2 PWM channels to take into account.

Isn’t there a nicer or easier way to manage this? Would it be possible that the MAX layer takes into account the 0 and 100% all by himself?

Thanks

Christophe


Viewing all articles
Browse latest Browse all 66774

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>