Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

How to send a 'temporal' buffer to digital output in C API?

Hi,

I am trying to send an arbitrary series of pulses stored in a buffer to a digital port in C API. I use usb-6259 or usb-6016 for this.

Here is the idea:

  1. Input the pulse buffer, this could be as simple as: 000110001111000111000... where 0 stands for low and 1 stands for high.
  2. Set the sampling frequency of the buffer, that is, each 0 or 1 in the above is corresponded to, for example, 10 ms.
  3. Wait for an external trigger.
  4. Once the trigger is received, output the buffer with the specified sampling frequency.
this shouldn't be impossible to code with the above cards?
0 Kudos
Message 1 of 2
(2,859 Views)
Hi,
 
Have you tried looking at the examples that ship with the NI-DAQmx driver for ANSI C? They will be installed in the following directory on your machine (assuming default installation): C:\Program Files\National Instruments\NI-DAQ\Examples\DAQmx ANSI C.
 
This should give you an example to follow - try WriteDigChan and WriteDigChan-ExtClk which you can find in the \Digital\Generate Values\ folder of the above directory.
 
Using the USB-6016 you wont be able to specify a frequency to output your array at - this device uses software timing for the digital lines. If you want to use the USB-6259, you can use an external clock as the sampling clock (so the rate to output at), but this device also doesn't have an onboard sample clock for the digital lines.
 
Look at the WriteDigChan-ExtClk example, it wont be too hard to modify this so that it works the way you need.
 
You'll need to set up the code so that it works on an external trigger - take a look at the DAQmx C reference help for more information on the DAQmxCfgDigEdgeStartTrig function to see how you can use this. (assuming you want to start on a digital edge?)
 
Then all you need to do is create a way to enter the data array manually, but this can be as simple or as complex as you like!
 
Hope this helps
 
Regards
Hannah
NIUK & Ireland
0 Kudos
Message 2 of 2
(2,834 Views)