Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

NI-DAQmx: M Series Pulse Width Modulation (PWM) not working with USB-6211

I have a USB-6211 DAQ and I am trying to generate PWM on the four digital outputs using the internal counter as the source for the sample clock. I downloaded NI-DAQmx: M Series Pulse Width Modulation (PWM) VI and I keep getting error-200077. This says that I can't use it as a sample clock and can select only on demand. I have looked up this error code and found that the USB devices only have software timers and this apparently is the source of the error.  The link to the VI I am trying to use is http://zone.ni.com/devzone/cda/epd/p/id/5043 

 

Unfortunately I am an entry-level labview programmer so any suggestions to work around this problem would be greatly appreciated.

 

Thank you

0 Kudos
Message 1 of 11
(8,206 Views)

Hello,

 

Good work on doing your research about the error first! I commend you! As far as generating the PWM, what kind of frequency are you looking for? Also, to make this a true PWM signal, what were your plans for controlling the duty cycle? 

 

The issue you were looking at was that the digital lines on that board are only software timed, which means there is not availability to correlate their timing with one of the onboard timing sources, like the AI sample clock for example. This presents a bit of a problem for something like PWM generation, since that usually has strict frequency/duty cycle stipulations. Even if you were generating at a very slow speed, there is really no way of guaranteeing a uniform frequency output using the digital lines, since their values will only be able to updated when the processor can get around to changing them. Also, with USB devices there are even more issues with latency, so unfortunately this likely isn't going to work out for your application. 

 

You can generate pulse trains using the 2 counters at much higher speeds, but changing the duty cycle is then a little tricky. What is the application you're looking at?

 

Chris W

0 Kudos
Message 2 of 11
(8,197 Views)

"You can generate pulse trains using the 2 counters at much higher speeds, but changing the duty cycle is then a little tricky. What is the application you're looking at?"

 

I currently have this already setup  and running but the problem is that it is limited to only two channels because there are only two counters on my DAQ. I need to be able to control 4 channels. I have already figured out how to vary the duty cycle on-the-fly but again I need to be able to control 4 channels. 

 

I have 4 linear actuators that are run by a set of H-bridge controllers (powered by an external power supply) which accepted servo PWM control. 

 

I guess my other option is to find a PWM controller that uses the analog outputs. I have two of these as well but I would like to stay consistent with the digital outputs.

0 Kudos
Message 3 of 11
(8,194 Views)

Unfortunately, this device is not going to be a good fit for your application. I would suggest either using two of them and using the 2 counters on each device or looking at a device like the USB-6221, which has hardware and software timed Digital I/O.

 

The other questions I have is whether you need the pulse train outputs to be sychronized in any way? Are their duty cycles changing at the same time? You could implement a separate AO task and just write an analog pulse train with calculated duty cycle. Then modify that duty cycle programmatically.

 

Chris

0 Kudos
Message 4 of 11
(8,175 Views)

I do have another question. I currently have a single pulse train setup so that I can run one channel of Pwm at a time using https://knowledge.ni.com/KnowledgeArticleDetails?id=kA03q000000x1P0CAI&l=en-US. How would I modify this so that I could have both channels running simutaneously with independent control over the duty cycle. The frequency is the same between the two (about 500hz) I don't need them to be syncronized at all, however they duty cycles would be changing individually for each channel.

0 Kudos
Message 5 of 11
(8,171 Views)

If you implement a counter output task in LabVIEW, you can have each task use a separate while loop. Inside that while loop is where you can implement your on the fly modification of the duty cycle. You can certainly have parallel tasks for each of your counter outputs. Basically you can have as many of these PWM output tasks as you have counters and if you have another board with 2 more counters, then you will have all 4 that you need.

 

Chris

0 Kudos
Message 6 of 11
(8,157 Views)

@Chris_W. wrote:

..

Basically you can have as many of these PWM output tasks as you have counters and if you have another board with 2 more counters, then you will have all 4 that you need.


 

Is that true?

 

I faced the problem, that two counters are necessary for generating one PWM output task, hence I could not generate two PWM signals at the same time with my NI USB 6221.

 

Cheers, Mace

0 Kudos
Message 7 of 11
(6,146 Views)

If you make the tasks continuous you can do 2 at once, so if you don't care about the exact number of pulses generated I would just do this.  On M Series, finite counter output tasks use both counters.

 

 

Best Regards,

John Passiak
0 Kudos
Message 8 of 11
(6,124 Views)

Hi, I have problems with generating PWM signals through the counter output terminal (USB 6211).

Not sure if my coding is wrong or my wiring is incorrect.

I am trying to control a DC motor.

 

Please advice.

 

Deakin_user2013

0 Kudos
Message 9 of 11
(5,885 Views)

Attached is the coding used...

Download All
0 Kudos
Message 10 of 11
(5,883 Views)