Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

pxi-6509 WriteDigitalLines (hello world)

Hi everybody,

my 6509 works fine with the test panel and the DAQmx example programs (CVI 8).
Now, I need to use each of the 96 lines as independent output, i.e. put HI on ch.12 and do nothing on the rest of lines.
This is apparently not possible unless write 8 bit on Dev1/port1 which contains ch.12.
So:
1. How to write only the selected bit?
2. How to put that line back to zero?
My questions are due to my nonfunctional code:

clock on ch.12:
/*********************************************/
chan = "Dev1/port2/line8:15"
data = {0,0,0,0,1,0,0,0}

        SetWaitCursor(1);
        DAQmxErrChk (DAQmxCreateTask("",&taskHandle));
        DAQmxErrChk (DAQmxCreateDOChan(taskHandle,chan,"",DAQmx_Val_ChanForAllLines));
        DAQmxErrChk (DAQmxStartTask(taskHandle));
        DAQmxErrChk (DAQmxWriteDigitalLines(taskHandle,1,1,10.0,DAQmx_Val_GroupByChannel,data,NULL,NULL));
        DAQmxStopTask(taskHandle);
        DAQmxClearTask(taskHandle);

data = {0,0,0,0,0,0,0,0}      

        SetWaitCursor(1);
        DAQmxErrChk (DAQmxCreateTask("",&taskHandle));
        DAQmxErrChk (DAQmxCreateDOChan(taskHandle,"Dev1/port2/line8:15","",DAQmx_Val_ChanForAllLines));
        DAQmxErrChk (DAQmxStartTask(taskHandle));
        DAQmxErrChk (DAQmxWriteDigitalLines(taskHandle,1,1,10.0,DAQmx_Val_GroupByChannel,data,NULL,NULL));
        DAQmxStopTask(taskHandle);
        DAQmxClearTask(taskHandle);
/**********************************************************/  

Thanks,
Rabdo
0 Kudos
Message 1 of 2
(3,231 Views)

Hello Rabdo,

sorry for the late answer, but I figured out a possible solution. In order to write a digital line you must create a DO channl this way:

DAQmxCreateDOChan (taskHandle, chan, "", DAQmx_Val_ChanPerLine);

then you must call the write function this way:

DAQmxErrChk (DAQmxWriteDigitalLines(taskHandle,1,1,10.0,DAQmx_Val_GroupByChannel,data_single,NULL,NULL));

where data_single is 1D array with dimension 1.

I attached a CVI project slightly modified from the one in the CVI library.

Hope this helps

Best regards,

Fabio

Fabio M.
NI
Principal Engineer
0 Kudos
Message 2 of 2
(3,188 Views)