LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to emit a continuous PWM signal on a digital output with DAQmx?

Solved!
Go to solution

I would like to use a cDAQ 9189 with NI 9375 module to generate a PWM signal on the latter's DO line. To my understanding I can only write a PWM signal to a counter, which the 9375 itself doesn't provide. What other options are there? Another thread suggests creating a PWM waveform and writing that on the DO line, but unless I'm mistaken lacking periodicity that would require a loop which I'd like to avoid. The cDAQ 9189 has an internal counter, can I use that somehow and route its input to the DO line? I guess for that I somehow have to determine the DO line's terminal, right?

0 Kudos
Message 1 of 8
(3,456 Views)

You can buy a motor controller. They are fairly cheap and can drive pretty good size motors. You give them an analog voltage and the convert to PWM signal. What are you trying to drive?

 

Tim
GHSP
0 Kudos
Message 2 of 8
(3,446 Views)

Oh I'm not driving a motor, I really just want to generate a PWM output for a periodic on/off process with those 24V. Certainly no additional hardware required...

0 Kudos
Message 3 of 8
(3,424 Views)

What kind of frequency are you looking for? Have you looked that the signal generation examples? They show how to generate different types of signals. You might be able to use one of these to generate a signal and then output it to a digital line.

Tim
GHSP
Message 4 of 8
(3,413 Views)
Solution
Accepted by topic author tkienzler-tt

Why do you need to avoid a loop? You won't lose timing info, the DAQmx drivers handle all of that. You will be able to output the waveform, then call DAQmx write again, which will block until there is space in the buffer to write your new data. There is enough onboard data that you won't miss any samples.

 

I'd suggest at least 200-300 ms worth of samples at a minimum though- if your period is like 2 ms then the loop has to run 500x a second, which is pushing it a bit. In that case, I'd write multiple periods worth of data (say, 100 periods) to get the buffered amount to 200 ms worth. Different devices will behave differently so you might need to experiment with different buffer lengths.

 

This works because there is some time delay/overhead for each buffer write, so sending 1000 samples one time is faster than sending 10 samples 100 times, and MUCH faster than 1 sample 1000 times.

Message 5 of 8
(3,360 Views)

@Bert Oh right, somehow I forgot about the buffer/block combination... Of course it would still be more convenient not having to run a loop in parallel to the measurement tasks, hence my thoughts about somehow using the internal counters ( e.g. _ctr0) on which I couldn't find much documentation... But for now the loop will do fine, thanks!

 

@aeastet The frequency is just in the few-digit Hz range, so after a night's rest I realize I've been overthinking this 😅 Clearly you're right, creating the waveform in LabView and feeding that to the digital line should do the trick

0 Kudos
Message 6 of 8
(3,322 Views)

So I did some more digging around and found a definite answer to your question. This was obnoxiously hard to find, and it wasn't in the manual for either the cDAQ chassis or the module:

 

http://www.ni.com/product-documentation/54453/en/

 

The 9375 is in the table "Modules That Can Not Access Counters", so you will need to do this with a digital output waveform, as mentioned earlier in the thread. There are a few modules with that voltage range that CAN access counters (also mentioned in the linked article) so if you want to switch you'll need to get a different module, but the digital out method should work fine for what you're doing.

 

What you want to do (in a general sense) can be done with DAQmx (there is an example under DAQmx- Counter Output in the example finder in LabVIEW) but this module doesn't support counter access.

Message 7 of 8
(3,300 Views)

Great find, thanks a lot! I have a 9344 (4 LEDs and 4 manual switches), so I can at least evaluate the counter method with its LEDs later on if ever deemed necessary...

0 Kudos
Message 8 of 8
(3,272 Views)