Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

How to output a non-periodic digital output

I'm programming a PCI 6221 M-series card in C, and need some help with understanding digital output.

I'm interested in outputting  a digital sequence, on a single digital line, repeatedly. The output sequence is like: 1, 0, 1, 0, 0, 0, 0, 0
I can set up my counter to create a DO clock and output 10 pulses per second, but what format should my data array be in to output the above example sequence? Would data[10] = {1, 0, 1, 0, 0, 0, 0, 0} be correct? By data array I'm referring to the writeArray argument in DAQmxWRiteDigitalU32.

thanks
0 Kudos
Message 1 of 4
(3,285 Views)
Hi,

I recommend not using the WriteDigitalU32.  The DAQmxWriteDigitalLines would let you do this with simple boolean data.  However if you want to use the integer write, then as long as your array is set the way you have it either 1 or zero you will get the same behavior.  I think you would have a better understanding of the application if you used the digital lines command.  The U32 write is simultaneously writing to 32 ports, which will give you the same behavior , but it is just important to consider that you are actually writing 32 channels, So writing a zero will set the first line to one, and other lines will be zero.  If you use the DAQmxWriteDigitalLines, then you only be writing to that first line.  So the answer is that your data array should work fine, but it might not be the best or most efficient way to do it.  Please let me know if you have further questions on this issue?

Your subject says that your signal was non periodic, but then you say you want to repeatedly output a sequence.  That would mean your sequence was periodic.  I was just wondering what you meant by non-periodic, sense I can not address that part of your topic.

Have a great day,

Michael Denton
Applications Engineering
National Instruments

Message Edited by MickeyD on 02-19-2007 03:29 PM

0 Kudos
Message 2 of 4
(3,252 Views)

Hi, thanks for the information. By non-periodic, I was referring to the pattern of data on a single repeat, e.g. {1,0,  1,0,  0,0,  0,0,  0,0}. It's not {1,0} repeated 5 times.

What would you suggest to make it more efficient? I'll try your suggestion of using DAQmxWriteDigitalLines.

Also, if I created a data sequence in another program (e.g. Matlab), and wanted to read it into the application, what format should it be saved in? For example, little-endian, uInt32?

Thanks for the assistance

 

0 Kudos
Message 3 of 4
(3,246 Views)
Hi,
 
I believe when MickeyD was referring to efficiency he was referring to minimizing the amount of data saved or written unnecessarily.  When you write to a single line, technically all you need is a boolean (high or low) for each update, however a different number of bits/bytes will be used depending on which command you use.  Writing 32 bits or 4 bytes (DAQmxWriteDigitalU32), where only one bit is used is not the most efficient.  Both DAQmxWriteDigitalLines and DAQmxWriteDigitalU8 use a U8 format.  This cuts down on the number of bytes which need to be transferred or stored in a file as you mention. 
 
One Byte is used for each update (i.e. 00000001 or 00000000).  So for a repeated pattern of 10 bits, ten U8 bytes are used.  The first value in your array would be the first value output.  If you could save the data as a U8 you could save a lot of space in your file (although if you only have 10 values this isn't critical).  Format (Little or Big-Endian) shouldn't matter so long as you read the data back in the same format that it was written.  Also, since you are dealing with only 1 byte at a time, the format will not make a difference.  If however you were using 9 channels, requiring 2 bytes per update, format would be a factor.
 
Hope this helps,
 
Jennifer O.
Applications Engineer
National Instruments
0 Kudos
Message 4 of 4
(3,231 Views)