Hi,
I'm working on a software using NI6533 and Ni-Daqmx
I must get continuously data on 32 bits(port 0-3) and I want to send data on the control line not used(port5).
I build 2 tasks:
- 1 to read data each 0.5s
- 1 to write data on demand
here is a summary of my code:
// continuous acquisition
i_res = DAQmxCreateTask("Tache Acquisition Dev2",&AcqDev2TaskHandle);
if(i_res == 0)
i_res = DAQmxCreateDIChan(AcqDev2TaskHandle, "Dev2/port0_32", "Start Dev2", DAQmx_Val_ChanForAllLines);
if(i_res == 0)
i_res = DAQmxCfgSampClkTiming (AcqDev2TaskHandle, "OnboardClock", 2, DAQmx_Val_Rising, DAQmx_Val_ContSamps, ONE_SAMPLE_PER_CHANEL);
if(i_res == 0)
{
i_res = DAQmxSetBufferAttribute(AcqDev2TaskHandle, DAQmx_Buf_Input_BufSize, 10000);
}
// output task
if(i_res == 0)
i_res = DAQmxCreateTask("Tache output",&SyncDev2TaskHandle);
if(i_res == 0)
i_res = DAQmxCreateDOChan(SyncDev2TaskHandle, "Dev2/port5/Line1", "", DAQmx_Val_ChanForAllLines);
if(i_res == 0)
i_res = DAQmxCreateDOChan(SyncDev2TaskHandle, "Dev2/port5/Line3", "", DAQmx_Val_ChanForAllLines);
if(i_res == 0)
e_res = ACQ_OK;
// read function used
i_res = DAQmxReadDigitalU32 ( AcqDev2TaskHandle,
READ_ALL_SAMPLE,
NO_TIMEOUT,
DAQmx_Val_GroupByChannel,
pui_sample,
ONE_SAMPLE_PER_CHANEL,
&iNumRead,
NULL );
// write function
int i_sample_written = 0;
unsigned char pc_data[2] = {0,1};
DAQmxWriteDigitalLines (SyncDev2TaskHandle, 1, 0, -1, DAQmx_Val_GroupByChannel, pc_data, &i_sample_written, 0) ;
My problem:
I read data correctly until I write data on port 5!
After a first call of the writing function, I can always read but when I call the write function for the second time, my read function returns always 0 as buffer read!!!
The Ni-DAQmx functions do not return any error.
If someone can help me, It would be wonderfull!!
Thanks
Greg