Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Can I produce 3 complementary PWM signals with 120 degree phase shift with USB-6001

I would like to generate 3 complementary 75 kHz PWM signals (a total of six channels) with 120 degrees phase shift using a USB-6001. NI's website has examples that detail how to use the counter of digital IO devices to output a PWM signal. Can I use a single counter to control the timing of the outputs or will I need a device that has multiple counters? Can software timing produce a pulse train as fast as 75 kHz?

 

To produce the complementary signal, I thought of generating the same pulse on two different channels, then I'll invert the polarity of the second channel to my DUT. With the single counter, is it possible to offset the timing of the other channels so that they're 120 degrees out of phase, that would a mean a 4.4 microsecond offset ((1/75,000) ÷ 3). Can this be handled by software?

0 Kudos
Message 1 of 6
(1,639 Views)

The 6001 cannot generate even 1 pulse train.  It has only 1 counter which can only count edges (and only 1 polarity I think).  Software timing with digital output will definitely not be a possibility either.

 

You either need 6 fully capable counters or 3 plus some external inverter circuitry to make the complementary signals.

 

X-series devices (NI 63xx) will have 4 capable counters and will also have support for at least 8 hardware-clocked digital output lines.

 

Dunno all the requirements of these signals, but I'd lean toward a 6-line DO task that gets its sample clock from a separate counter pulse train task.  That would let you define a DO buffer of data representing an integer # of total cycles of these signals, and you could potentially vary the overall signal speed on the fly by updating the counter pulse train frequency (effectively changing the sample rate).

 

 

-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.
Message 2 of 6
(1,628 Views)

Thank you Kevin_Price for the speedy response.

 

Here's my signal requirement: 5V TTL, 75 kHz, 3 complementary phases (6 signals), 120 degree phase shift.

 

"X-series devices (NI 63xx) will have 4 capable counters and will also have support for at least 8 hardware-clocked digital output lines."

 

In this statement, I can't fully decipher what the capabilities of the NI 63xx X-series devices are. To produce the six signals that I need, will I have to add two more external clocks?

 

Is it possible to use three counters and have it control timing to two channels? Having one go high and one low in the same instance?

 

I've been looking into the USB-6341 device. Can this device possibly be something I can use?

0 Kudos
Message 3 of 6
(1,584 Views)

You won't need additional clocks on a USB-6341.  You may not even need the single counter task I mentioned, provided you just want to generate these signals at constant frequency.  X-series boards are able to derive their own sample clocks for DIO (unlike prior generations of MIO boards like M-series and E-series).

 

However, there *are* some caveats.  While some DIO boards can do 10 MHz sampling, the USB-6341 is limited to 1 MHz.

 

I'm also assuming each of these signals will be 50% duty cycle -- is that right?  If so, then you'll have 6 distinct state changes per cycle of your digital pattern.  So to generate 75 kHz on each DO line, you'll need a sample rate that's 6x that -- 450 kHz.

 

The sample rate comes from dividing down an internal timebase, so you probably won't be able to hit 450 kHz *exactly*.   Very roughly, you might miss by as much as ~0.5% (the ratio between your target sample rate and the 100 MHz internal timebase).  Just so you're aware of this limitation.

 

So if you can live with that, you can just define a buffer of digital states that you regenerate.  You might be able to offload the regeneration buffer down to the board and leave the PC's CPU out of it entirely!  For 50% duty cycle, the 6 states could be (1 state/sample per line, bits 3-5 are the inverse of bits 0-2):

0 1 0 1 0 1

1 1 0 0 0 1

1 0 0 0 1 1

1 0 1 0 1 0

0 0 1 1 1 0

0 1 1 1 0 0

 

 

-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 4 of 6
(1,576 Views)

Greetings,

 

Yes, I would like to produce all six signals at a constant frequency, but I would need to be able to vary the duty cycle of the signals from 0% - 100%.

 

https://forums.ni.com/t5/Example-Code/M-Series-Hardware-Timed-DIO-with-Counter-Clock-Generation/ta-p...

 

I found this link that talks about creating digital IO tasks using a counter for clock generation. Would this be a good place to start? If so, which M series devices would you recommend? If not, disregard.  

0 Kudos
Message 5 of 6
(1,568 Views)

Screeeeeeech!   That's me putting on the brakes.  If you also need to vary duty cycle to more than a very (very) few possible % values, a Digital task on a USB-6341 is *NOT* going to work.  Now we're much more squarely in the realm of counters.

 

If you've already got a USB-6341, you can use 3 of its counters directly and an external circuit to invert those signals to make the other 3.  An alternative might be an NI 6612 and its 8 counters, but I don't believe that one comes in USB form in case that's a requirement.

 

Much as I'm a fan of counters, I'd say that if you *can* consider a desktop device, you still might be best off overall with a PCIe X-series board and external inverter circuitry (I think Schmitt trigger chips invert for example).  They have an awful lot of versatility compared to the 6612 which offers no analog capability.

 

When defining a counter pulse train, beyond the freq and duty cycle inputs there's an often-overlooked input for 'initial delay'.  That one's crucial for properly setting up the 120 deg phase (which you'd specify in time units, such as the 4.4 microsec you calc'ed). 

    You'd be setting up 3 distinct counter tasks, all configured to trigger off some common signal.  I often use a software-timed DO pin on port 1 or 2 that serves double-duty as a PFI pin that can be configured as a digital start trigger.  Then I can be sure to start all my counter tasks before generating the DO pulse that triggers them all simultaneously.

   Finally, there's a subtle quirk when you want to update duty cycle alone.  New duty cycle values only get used if you *also* write a frequency value.  It can be the same frequency value every time, you just have to write it explicitly.  Using DAQmx Write requires both parameters anyway.  Using a DAQmx Channel property node would require you to write the frequency after writing the duty cycle.  (Multiple properties in the same node are written in top to bottom order.)

   The duty cycle changes won't be perfectly sync'ed among your 3 counter tasks because it takes 3 separate software calls to update them.  It also seems that changes won't take effect immediately either, even when the pulse frequencies are very low (like 1 Hz).  But for you pulsing at 75 kHz, it'll be imperceptible.   If curious, see this recent thread for more info.

 

 

-Kevin P

 

[Edit: P.S. Your available duty cycles will still be quantized due to the fact that all pulse times are derived from the internal 100 MHz timebase.  At 75 kHz, your quantized steps will be increments that are a bit under 1%.   That should be fine for dynamic control, but if you have very specific needs for steady-state, it's possible none of your available duty cycles will land you at exactly the right place.

   In such a case, I'd advise you rethink your nominal 75 kHz.  Different nearby output freqs would give you different available quantized duty cycles.  And some of them will get you much closer to the specific % duty cycle you need.]

 

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