LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Timeout on Read and Write operations

Hello,

I am trying to re-write an applicatin from Traditional to DAQmx library functions. This is my first attempt to play with the DAQmx library.
I have 2 DAC and 8 ADC (differential) channels. I am also setting a trigger(Square wave: Hi to Low). Consequtive write and read operations always fail. Read operation gives a TimeOut. I have noticed that if I do NOT setup the trigger, I am able to write and read the proper values.
Is there any document that compares the Traditional DAQ functions to the NIDAQmx library functions?

Library and RTE: NIDAQmx Library with CVI 7.1
My Code:

DAQmxErrChk (DAQmxCreateTask ("", &DAC_taskHandle));
DAQmxErrChk (DAQmxCreateAOVoltageChan (DAC_taskHandle, "Dev1/ao0:1", "", 0, 10.0, DAQmx_Val_Volts, ""));


// ADC
DAQmxErrChk (DAQmxCreateTask("",&ADC_taskHandle));
DAQmxErrChk (DAQmxCreateAIVoltageChan (ADC_taskHandle, "Dev1/ai0:7", "", DAQmx_Val_Diff, 0, 10, DAQmx_Val_Volts, NULL));


// Trigger Source PFI0 and PFI1 are connected in a loop
DAQmxErrChk (DAQmxCreateTask ("", &Trig_taskHandle));
DAQmxErrChk (DAQmxCreateDIChan (Trig_taskHandle, "/Dev1/PFI1","",DAQmx_Val_ChanForAllLines));

// DAC
DAQmxErrChk (DAQmxCfgSampClkTiming (DAC_taskHandle, "", DAC_rate, DAQmx_Val_Falling, DAQmx_Val_ContSamps,samplesPerChan));
DAQmxErrChk (DAQmxCfgDigEdgeStartTrig (DAC_taskHandle, "/Dev1/PFI0", DAQmx_Val_Falling));

DAQmxErrChk (DAQmxCfgSampClkTiming (ADC_taskHandle, "", ADC_rate, DAQmx_Val_Falling, DAQmx_Val_ContSamps, 1000));
DAQmxErrChk (DAQmxCfgDigEdgeStartTrig (ADC_taskHandle, "/Dev1/PFI0", DAQmx_Val_Falling));


// To generate the square wave for the Trigger
for(i=1;i>=0;i--)
{
if(i==1)
singleBit_array[0]=1.0;
else
singleBit_array[0]=0.0;

DAQmxErrChk (DAQmxCreateTask ("", &taskHandle));
DAQmxErrChk (DAQmxCreateDOChan (taskHandle, "/Dev1/PFI0", "", DAQmx_Val_ChanForAllLines));
DAQmxErrChk (DAQmxStartTask (taskHandle));
DAQmxErrChk (DAQmxWriteDigitalLines(taskHandle,1,0,10.0,DAQmx_Val_GroupByChannel,singleBit_array,NULL,NULL));
DAQmxErrChk (DAQmxStopTask (taskHandle));
}



Copy1D (outputarrayy, INDENTNUMDACPTS, DAC_Data);
DAQmxErrChk (DAQmxStartTask (DAC_taskHandle));
DAQmxErrChk (DAQmxWriteAnalogF64 (DAC_taskHandle,1, 0, 10.0, DAQmx_Val_GroupByChannel, DAC_Data, &written, NULL));
DAQmxErrChk (DAQmxStopTask (DAC_taskHandle));

// ADC
DAQmxErrChk (DAQmxStartTask (ADC_taskHandle));
DAQmxErrChk (DAQmxReadAnalogF64 (ADC_taskHandle, 1, 10, DAQmx_Val_GroupByChannel, ADC_Data, 8, &read,NULL));
DAQmxErrChk (DAQmxStopTask (ADC_taskHandle));

Any suggestions would be helpful.

regards,

Dwivedi
0 Kudos
Message 1 of 7
(4,294 Views)
Hi Dwivedi,

It sounds like you are trying to use DAQmx to have simultaneous Analog Input/Output and be starting everything with a trigger.

I went to ni.com and searched for 'daqmx ai ao trigger' in the search field and found this example program:
NI-DAQmx: Simultaneous AI/AO with External Digital Trigger in CVI

This example should show you how to do what you are attempting and will save some development time by providing a ready solution.

If the example does not work, make sure that all of the equipment is being addressed properly. If there are still problems, then it could indicate a hardware problem.

Have fun trying this out!
0 Kudos
Message 2 of 7
(4,265 Views)
Hi Otis,
Thanks for the reply. I tried running the example code on my machine and I still get a TIMEOUT on the read. Moreover, my requirement is to read multiple channels at each instance of time.

However, I have been able to figure out the 'write' part of the process and am able to Write the DAC values using the trigger setup but somehow the similar setup for Read operations is still not responding.

Following is the code for the read:

DAQmxErrChk (DAQmxCreateTask("",&ADC_taskHandle));
DAQmxErrChk (DAQmxCreateAIVoltageChan (ADC_taskHandle, "Dev1/ai0:7", "", DAQmx_Val_Diff, 0, 10, DAQmx_Val_Volts, NULL));

DAQmxErrChk (DAQmxCfgSampClkTiming (ADC_taskHandle, "", 1000, DAQmx_Val_Falling, DAQmx_Val_FiniteSamps, 1000));
DAQmxErrChk (DAQmxCfgDigEdgeStartTrig (ADC_taskHandle, "/Dev1/PFI1", DAQmx_Val_Falling));

DAQmxErrChk (DAQmxStartTask (ADC_taskHandle));
DAQmxErrChk (DAQmxReadAnalogF64 (ADC_taskHandle, 1000, 10, DAQmx_Val_GroupByChannel,ADC_Data, 8000, &read, NULL));
DAQmxErrChk (DAQmxStopTask (ADC_taskHandle));

// To generate the Trigger pulse
for(i=1;i>=0;i--)
{
if(i==1)
singleBit_array[0]=1.0;
else
singleBit_array[0]=0.0;

DAQmxErrChk (DAQmxCreateTask ("", &taskHandle));
DAQmxErrChk (DAQmxCreateDOChan (taskHandle, "/Dev1/PFI0", "", DAQmx_Val_ChanPerLine));
DAQmxErrChk (DAQmxStartTask (taskHandle));
DAQmxErrChk (DAQmxWriteDigitalLines(taskHandle,1,0,10.0,DAQmx_Val_GroupByChannel,singleBit_array,NULL,NULL));
DAQmxErrChk (DAQmxStopTask (taskHandle));
}

Any ideas on this..??

regards,

Dwivedi
0 Kudos
Message 3 of 7
(4,262 Views)
Hi Otis,

I get the following message at the ReadAnalogF64() function:

Function DAQmxReadAnalogF64: (return value == -200284 (0xfffcf1a4))
Some or all of the samples requested have not yet been acquired.


Property: DAQmx_Read_RelativeTo
Corresponding Value: DAQmx_Val_CurrReadPos

Property: DAQmx_Read_Offset
Corresponding Value: 0

regards,

Dwivedi
0 Kudos
Message 4 of 7
(4,250 Views)
Dwivedi,

Since the reading portion of the code seems to be the area that you are having issues with can you try doing an example that just reads the data? If you do a read-only opperation do you find that it still gives you that error? Does everything appear to read properly?

From the code you placed on the forum it appears to be missing the *MultiFunctionSynchAIAOExtDigTrig functions. You will need to synchronize the triggers if you want simultaneous starting of your AI and AO tasks.

Basically, see if you can get all of the necessary tasks running individually. If there are any problems that can give us a smaller piece to try and work with.

Regards,
0 Kudos
Message 5 of 7
(4,235 Views)
Hi Otis,

Thanks for the reply.
I figured out the solution to the issues that I was having with the ReadAnalog function TIMEOUT.

I had a PFI0 line connected to PFI1 line for the trigger generation. Apparantely, it is not a valid choice. I needed to generate the trigger pulse at a DIO line and then connect it to one of the In-configured PFI lines. When I did this, I was able to read and write simultaneously with the same trigger.

Thanks for all the help.

regards,

Dwivedi
0 Kudos
Message 6 of 7
(4,230 Views)
Dwivedi,

That's great to hear that you were able to find the problem there.

Best of luck with the rest of your application!
0 Kudos
Message 7 of 7
(4,214 Views)