06-20-2010 10:04 PM
I want to turn on (write 1) to P0.0 and P0.1. I've found two functions that are likely candidates: DAQmxWriteBinary() and DAQmxWriteDigital(). What's the difference?
Both of these functions require an array argument (WriteArray) to specify the output. Seems like a single 8-bit binary number with the correct bit pattern should turn on the desired lines. Why do the functions require arrays of numbers instead of a single binary number?
Which function should I use and how do I set WriteArray to turn these lines on?
06-21-2010 12:02 AM
This code should work:
uInt8 x[2];
x[0] = 1; x[1] = 1;
DAQmxChk (DAQmxCreateTask ("", &taskH));
DAQmxChk (DAQmxAddGlobalChansToTask (taskH, "Dev1/port0/line0:1"));
DAQmxChk (DAQmxStartTask (taskH));
DAQmxChk (DAQmxWriteDigitalLines (taskH, 1, 1, 10, DAQmx_Val_GroupByChannel, x, &written, 0));
06-22-2010 05:20 PM
Roberto,
Your solution works great but I don't know why. What do the bits in each element of array x[] represent? Is bit 0 the only one that matters? Or are the other bits significant? This doesn't seem to be described very clearly in the help text.
thanks!
06-22-2010 07:00 PM
I'm not trying to be rude here and tell you to "RTFM" but you really have to read the function panel help and the help on each input control. (Right click the panel for the panel help, the control for the control help). The help for those functions explains all of what you want to know.
Most of the function help is pretty good, it's a resource you should turn to prior to posting in the forum.
But to answer your question without going into all the details, the arrays are there to provide multiple samples out each DIO port. If you want to send a data pattern, you set it up in the array, tell the function how many samples there are and configure the timing.