From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Multi channel pulse generation with NI-DAQmx

I'm new to using DAQmx, so forgive me if I'm barking up the wrong tree.

I am trying to generate a multi-channel pulse sequence using counter outputs on a PCI6602 with the BNC-2121 accessory. Eventually I want different pulses on all the channels (by specifying different delays/durations when configuring each channel) but for now I am just trying to get 4 synchronous square pulses out.

In MAX, I create a task and add 4 counter channels to it (Ctr2 through Ctr5), all with the same initial delay/high time/low time, run the task, and look at the output on the scope. The 4 pulses are made and have the correct durations, but are not synchronous. The 2nd pulse configured starts a few microseconds after the 1st one, and so on, even though they are identically configured. I can fudge it a bit by configuring an initial delay to each of the pulses, but that feels pretty kludgey and unreliable.

I have also tried this in code using the PyDAQmx wrapper (since my final application is written in Python), and get the same result. I tried making a separate task for each channel, and using CfgDigEdgeStartTrig to trigger Ctr3 off of Ctr2InternalOutput. I feel like this worked once, but now I am only getting "resource reserved" errors - and from reading the manual I get the impression that running multiple tasks in the same subsystem is not something that is supposed to work at all.

I'm pretty new to a lot of these DAQ concepts and would appreciate any help orienting me toward the proper way of making multi-channel pulse trains. Thanks!

0 Kudos
Message 1 of 7
(4,514 Views)

sounds like you want synchronization   http://www.ni.com/white-paper/4322/en/

0 Kudos
Message 2 of 7
(4,482 Views)

Depending on the signals you want to create, one solution to have them in sync with only one timer: Create a (continious) output stream of a complete 8/16/32 bit port, where the output rate is controlled by the timer.  The pulse timing resolution is defined by the timer/update rate ...

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


0 Kudos
Message 3 of 7
(4,458 Views)

Thank you both for your thoughtful responses.

 

Henrik: That is a good idea, and I gave it a try in MAX, however I found that my hardware (PCI-6602) does not support continuous output for the DIO port. It is only on demand, or software timed output.

 

nyc: Thank you for linking that document. The examples I see there are for synchronizing measurments of different types (e.g., analog input with output) by putting them in separate tasks and configuring a trigger. Since I am trying to synchronize several actions of the same type (counter output), I'm constrained (I think) by the limitation that only one task can run per subsystem.

 

It could be that I'm trying to do something that the hardware is just not capable of doing. I'm just surprised to learn that with so many counters on the board I can only make practical use of one at a time, in this case.

0 Kudos
Message 4 of 7
(4,442 Views)

You are rigth.. 😕

OK, have you tried to trigger your counters?

the Counter- continious output.vi example give an idea... 

Nothing more I can do, sorry. 

 

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


0 Kudos
Message 5 of 7
(4,429 Views)

Hello Baldwint,

 

I found these examples which hopefully could be helpful:

 

"Community: Synchronize Two Counter Output Tasks Using a Dummy AI Task"
https://decibel.ni.com/content/docs/DOC-11755

 

"Community: Synchronizing Two Counter Tasks in NI-DAQmx"
https://decibel.ni.com/content/docs/DOC-5706

 

Regards!

 

Daniel C.

 

0 Kudos
Message 6 of 7
(4,412 Views)

Thank you Daniel. You link a very illuminating example. My hardware (PCI-6602) does not have any analog in, so the specific approach (and VI) won't work, but the principle of using a 'dummy' task to trigger the others is the solution I was looking for.

 

Previously, by putting all 4 counter output channels in one task, I found that the pulses were staggered by 7us or so. By putting them each in their own task, and configuring three of them to trigger off of the fourth (the dummy channel), I was able to get the three non-dummy pulses to go at the same time. However it works best if the dummy channel is not paired with any of the others - that is, using channel 5 to trigger channels 1,2, and 3 works better than using channel 5 to trigger channels 2,3, and 4 (since I think chs 4 and 5 share something hardware wise).

 

There is a delay between the pulse used to trigger and the others. This is about 40ns or so, which is much more acceptable than the 7us I was getting before.

 

Thank you all for your help! For posterity I am posting my exploratory code here: http://nbviewer.ipython.org/gist/baldwint/0c96f2f7bbeb90af4626

0 Kudos
Message 7 of 7
(4,398 Views)