Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

digital i/o in ansi c with clock sync

I am new to the pci-6733 and have a number of questions. I am programming in ansi c. My task is to control an external device-i need to generate a digital clock and 3 other digital output signals which will output on the rising clock edge. The clock rate must be 2MHz. One of the three outputs is a fram sync signal running at 100k that is 11111 11111 11111 11110. The other two outputs are position controls for X and Y axes and need to be scanned. I have been able to code this but I am having a serious problem. So far I have set up 1 digital channel with 3 output lines. I am using continuous sampling as I want to repeat the scan pattern until the user says stop.

---The X and Y data consists of '001' at the beginning and then 16 bit position followed by a not used bit. Is there any way that I can simply input an integer, say X-position = 126 (decimal), and have the output be the 16 bit binary form of this number (with 1 bit sent every clock cycle? It seems to me that regardless of whether i use 1 channel with 3 lines or 3 channels, one for each line, if I send uInt8=126=[1111110] in binary, I will read 0 on line0, 1 on line1 and 1 on line2, in 1 clock cycle.

---Furthermore, even if I can do this, as evidenced above I actually need 20 bits (and therefore 20 clock cycles) for each data position-is there any way that I can do this, again in integer format? If I cannot use integer format then I will be stuck incrementing everything in binary form, which is doable but very tedious and will require a whole lot of code.

---My final issue is about reading-i also need to read another digital line on the faling edge of each clock tick. In this case should the size of the read buffer equal the size fo the write buffer? and do i need to make the read/write buffers as bug as the entire scan pattern?

 

I'd appreciate any guidance, especially with respect to my first two issues. Thanks in advance.

0 Kudos
Message 1 of 2
(3,297 Views)

Hi Tokayer,

 

You can write your integers to the channel with  DAQmxWriteDigitalU16.  You can find help with DAQmx in C in the C Reference Help located at Start >> All Programs >> National Instruments >> NI DAQ >> Text Based Code Support >> NI DAQmx C Reference Help.  You can also find example programs located at Start >> All Programs >> National Instruments >> NI DAQ >> Text Based Code Support >> ANSI C Examples.

Regards,
Jim Schwartz
0 Kudos
Message 2 of 2
(3,275 Views)