02-04-2009 12:16 PM
The error message "DAQmxBase Error: Attempted to write data that is too large or too small." typically means:
I would re-check your task settings; changing the driver will not resolve this problem.
Knights Who Say NI wrote:
The reason your code doesn't work on your 625x is that DAQmx Base is not supported on that card. You will need to use DAQmx for the 625x. Your existing DAQmx Base VIs will need to be replaced with the corresponding DAQmx VIs. This is because DAQmx and DAQmx Base are two different codebases.
I'd like to make a small correction here. On Linux, all of the PCI M Series devices are supported by DAQmx Base, but not all of their functionality [1]. In any case, DAQmx [2] is a better-performing driver and would be the preferable choice for PCI M Series on Linux. Keep in mind, though, that only Base supports USB on Linux. If you have a USB device and want to use it with Linux, you need to use DAQmx Base. Both drivers will happily co-exist on Linux, so you can use PCI devices with DAQmx and USB devices with DAQmx Base.
[1] NI-DAQmx Base readme
http://ftp.ni.com/support/softlib/multifunction_daq/nidaqmxbase/3.2/Linux/readme.txt
[2] NI-DAQmx for Linux
http://joule.ni.com/nidu/cds/view/p/id/1194/lang/en
Joe Friedchicken
NI Configuration Based Software Get with your fellow OS users
[ Linux ] [ macOS ]Principal Software Engineer :: Configuration Based Software
Senior Software Engineer :: Multifunction Instruments Applications Group (until May 2018)
Software Engineer :: Measurements RLP Group (until Mar 2014)
Applications Engineer :: High Speed Product Group (until Sep 2008)
02-10-2009 06:23 AM
Hi John,
As per your advice I modified the MultVoltUpdate-IntClk example program (NIDAQmx, Linux) to create analog_input and analog_output tasks to transmit 10 samples and receive 10 samples at a rate of 10 samples/s, as shwon below:
TaskHandle taskHandle_In=0,taskHandle_Out=0;
DAQmxErrChk (DAQmxCreateTask("",&taskHandle_In));
DAQmxErrChk (DAQmxCreateTask("",&taskHandle_Out));
DAQmxErrChk (DAQmxCreateAIVoltageChan(taskHandle_In,"Dev1/ai0","",DAQmx_Val_Cfg_Default,-10.0,10.0,DAQmx_Val_Volts,NULL));
DAQmxErrChk (DAQmxCreateAOVoltageChan(taskHandle_Out,"Dev1/ao0","",-10.0,10.0,DAQmx_Val_Volts,NULL));
DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandle_In,"",10.0,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,10));
DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandle_Out,"ai/SampleClock",10.0,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,10));
DAQmxErrChk (DAQmxWriteAnalogF64(taskHandle_Out,10,0,10.0,DAQmx_Val_GroupByChannel,data_out,&written,NULL));
DAQmxErrChk (DAQmxStartTask(taskHandle_Out));
DAQmxErrChk (DAQmxReadAnalogF64(taskHandle_In,10,10.0,DAQmx_Val_GroupByChannel,data_In,10,&read,NULL));
DAQmxErrChk (DAQmxStartTask(taskHandle_In));
Once I execute the aforesaid code, I am unable to obtain any synch at all, and the receive array 'data_In' contains arbitrary values ranging from -10.5V to -9.8V. Please suggest the correct sequence of function calls if there is a mistake.
Thanks,
Adeel
02-11-2009 05:54 PM
Hi Joe,
It seems to me that the reason you're not seeing any synchronization, is because you are using different clocks for your tasks. I would recommend using the aiSample Clock for both your taskHandle_In and your taskHandle_out.
I also wonder if your card is railing on negative values. One way to check the behavior of your card outside of your program is to open up a test panel in Measurement and Automation Explorer (MAX),which can be found by going to Start»All Programs»National Instruments»Measurement and Automation. Expand Devices and Interfaces and Expand NI-DAQmx Devices. When you select your device, you should be able to right click on it and select "Test Panel". Using the test panel in MAX will give you a better idea of your card's behavior.
Regarding your code, I believe you need to switch the following two lines:
DAQmxErrChk (DAQmxReadAnalogF64(taskHandle_In,10,10.0,DAQmx_Val_GroupByChannel,data_In,10,&read,NULL));
DAQmxErrChk (DAQmxStartTask(taskHandle_In));
The two lines above that are correct, you will need to write before you start, however, the opposite is true when you are reading. Start, and then read, and you should hopefully see better results. Additionally, I believe that you'll want a start trigger before your Analog Write.
Let me know how these things go-
aNIta B
Applications Engineer
National Instruments
02-12-2009 05:01 AM
Hi aNIta,
Thanks for your reply. After switching the lines of code, I received correct data, but it was still out of synch. For example if I send data_out=[0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5], i receive data_in = =[5 0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5]. So the last sample sent appeared as first sample received, first sample sent appeared as 2nd sample received, 2nd sample sent appeared as 3rd sample received and so on.
Regarding the Analog Trigger, i was bit unsure whether to configure taskhandle_out to analog trigger or taskhandle_in and also which source to use. I assumed I should configure taskhandle_out to use "ai/SampleClock" as analog trigger since I wanted to trigger the sending process at arrival of first rising edge of "ai/SampleClock". But NIdaqmx gave it an error as "invalid analog trigger source", though I was using the same signal for source of analog_out task.
Could you please suggest how to overcome this issue ?.
Regards,
Adeel
02-12-2009 09:56 AM
Joe Friedchicken
NI Configuration Based Software Get with your fellow OS users
[ Linux ] [ macOS ]Principal Software Engineer :: Configuration Based Software
Senior Software Engineer :: Multifunction Instruments Applications Group (until May 2018)
Software Engineer :: Measurements RLP Group (until Mar 2014)
Applications Engineer :: High Speed Product Group (until Sep 2008)
03-10-2009 04:07 AM
Hi,
I am using following code to synchronise the analog_input and analog_output tasks for NI-6251 Card using N-DAQmx Base
DAQmxErrChk (DAQmxCreateTask("",&taskHandle_In));
DAQmxErrChk (DAQmxCreateTask("",&taskHandle_Out));
DAQmxErrChk (DAQmxCreateAIVoltageChan(taskHandle_In,"Dev1/ai0","",term_config,-10.0,10.0,DAQmx_Val_Volts,NULL));
DAQmxErrChk (DAQmxCreateAOVoltageChan(taskHandle_Out,"Dev1/ao0","",0.0,5.0,DAQmx_Val_Volts,NULL));
DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandle_In,"",Sample_rate,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,2000+1));
DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandle_Out,"ai/SampleClock",Sample_rate,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,2000));
//Triggering
DAQmxErrChk (DAQmxCfgDigEdgeStartTrig(taskHandle_Out,"ai/StartTrigger",DAQmx_Val_Rising));
while (1)
{
DAQmxErrChk (DAQmxWriteAnalogF64(taskHandle_Out,2000,0,10.0,DAQmx_Val_GroupByChannel,data_out_2000,&written,NULL));
DAQmxErrChk (DAQmxStartTask(taskHandle_Out));
DAQmxErrChk (DAQmxStartTask(taskHandle_In));
DAQmxErrChk (DAQmxWaitUntilTaskDone(taskHandle_Out,10.0));
DAQmxErrChk (DAQmxReadAnalogF64(taskHandle_In,2000+1,10.0,DAQmx_Val_GroupByChannel,data_in_2000,2000+1,&read,NULL));
DAQmxErrChk (DAQmxWaitUntilTaskDone(taskHandle_In,10.0));
DAQmxStopTask(taskHandle_In);
DAQmxStopTask(taskHandle_Out);
.
.
.
}
If I do not require synchronisation such that both the analog_out and analog_in tasks are running continuously and independently without stopping, what simple changes should I make in the afore-mentioned code ?. Do I still need to use 'trigger' for analog_out task ?.
Thanks,
Adeel
03-11-2009 03:12 PM
Hi Adeel,
Is this code working for you currently? You do not need to have a trigger set up if your application does not require synchronization. The trigger used in your code allows the two tasks to start at the same time. Since, you are using one device the clock is already shared.
As far as changing your code, i believe that you do not need to make any other changes because all the other functions are required to set up and run the tasks.
03-18-2009 04:56 AM
Hi Jordan,
Yes this code is working but for the case when both the analog_out and analog_in tasks are synchronised by sharing the clock as well as trigger signal.
What I want is separate/independent but simulataneous operation of both channels. To achive this, I commented the trigger command, along with configuring the 'SampleClkTiming' for both tasks to acquire continuous samples instead of finit samples. Then I started both the analog_in and analog_out tasks before the while loop only for once as i wanted continuous acquisition and tranmission. Also I commented the 'stop'task)' operation because I didn't want to stop the task during the continuous operation. So my modified code looked like this:
DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandle_In,"",Sample_rate,DAQmx_Val_Rising,DAQmx_Val_ContSamps,2000+1));
DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandle_Out,"ai/SampleClock",Sample_rate,DAQmx_Val_Rising,DAQmx_Val_ContSamps,2000));
//Triggering commented out
//DAQmxErrChk (DAQmxCfgDigEdgeStartTrig(taskHandle_Out,"ai/StartTrigger",DAQmx_Val_Rising));
DAQmxErrChk (DAQmxStartTask(taskHandle_Out));
DAQmxErrChk (DAQmxStartTask(taskHandle_In));
while (1)
{
DAQmxErrChk (DAQmxWriteAnalogF64(taskHandle_Out,2000,0,10.0,DAQmx_Val_GroupByChannel,data_out_2000,&written,NULL));
DAQmxErrChk (DAQmxWaitUntilTaskDone(taskHandle_Out,10.0));
DAQmxErrChk (DAQmxReadAnalogF64(taskHandle_In,2000+1,10.0,DAQmx_Val_GroupByChannel,data_in_2000,2000+1,&read,NULL));
DAQmxErrChk (DAQmxWaitUntilTaskDone(taskHandle_In,10.0));
//Task stopping commented out
//DAQmxStopTask(taskHandle_In);
//DAQmxStopTask(taskHandle_Out);
.
.
.
}
Once I run the code, my PC halts with error code 200479. I wanna know what chamges I have to make in the aforesaid code so that both the tasks can operate concurrently without any synch at all.
Thanks,
Adeel
03-19-2009 12:38 PM
Hi Adeel,
First off I see that you start the Analog output task before you write the waveform to the card which could be causing problems. You need to write the waveform before you start that task. Also, does your code work when you include the the stop task and not have it commented out?
I would definitely recommend to check out the DAQmx base C examples that are shipped with the Driver on how to set up an Analog input task and an Analog Output Task. That way you can get a better idea of the programming flow and what needs to be included in your program. The link below shows how to navigate to these examples.
Where Can I Find NI-DAQmx Base Examples?
http://digital.ni.com/public.nsf/allkb/BEA8C88ED8B09AF286256ED0004544F7?OpenDocument