08-13-2008 07:23 AM
Hi everyone,
Part of my job is to acquire continously on multiple channels using NIDAQmxBase.
As I faced problems in my application I decide to work with the provided examples but I doesn't succeed to make them work.
Here are my needs :
12 Channels
48000 Hertz
Here is my code (contAcquireNChan.c with a few modifications):
#include "NIDAQmxBase.h"
#include <stdio.h>
#include <time.h>
#define DAQmxErrChk(functionCall) { if( DAQmxFailed(error=(functionCall)) ) { goto Error; } }
int main(int argc, char *argv[])
{
// Task parameters
int32 error = 0;
TaskHandle taskHandle = 0;
char errBuff[2048]={'\0'};
int32 i,j;
time_t startTime;
bool32 done=0;
// Channel parameters
// char chan[] = "Dev1/ai0, Dev1/ai1";
char chan[] = "Dev1/ai0, Dev1/ai1, Dev1/ai2, Dev1/ai3, Dev1/ai4, Dev1/ai5, Dev1/ai6, Dev1/ai7, Dev1/ai8, Dev1/ai9, Dev1/ai10, Dev1/ai11";
float64 min = -10.0;
float64 max = 10.0;
// Timing parameters
char clockSource[] = "OnboardClock";
uInt64 samplesPerChan = 1000;
float64 sampleRate = 48000.0;
// Data read parameters
#define bufferSize (uInt32)1000
float64 data[bufferSize * 12];
int32 pointsToRead = bufferSize;
int32 pointsRead;
float64 timeout = 10.0;
int32 totalRead = 0;
printf("Press Ctrl-C to exit\n");
DAQmxErrChk (DAQmxBaseCreateTask("",&taskHandle));
DAQmxErrChk (DAQmxBaseCreateAIVoltageChan(taskHandle,chan,"",DAQmx_Val_Cfg_Default,min,max,DAQmx_Val_Volts,NULL));
DAQmxErrChk (DAQmxBaseCfgSampClkTiming(taskHandle,clockSource,sampleRate,DAQmx_Val_Rising,DAQmx_Val_ContSamps,samplesPerChan));
DAQmxErrChk (DAQmxBaseCfgInputBuffer(taskHandle,144000));
DAQmxErrChk (DAQmxBaseStartTask(taskHandle));
// The loop will quit after 10 seconds
printf ("Acquisition starting\n");
startTime = time(NULL);
while( time(NULL)<startTime+50 ) {
DAQmxErrChk (DAQmxBaseReadAnalogF64(taskHandle,pointsToRead,timeout,DAQmx_Val_GroupByScanNumber,data,bufferSize*12,&pointsRead,NULL));
totalRead += pointsRead;
printf("Acquired %d samples. Total %d\n",pointsRead,totalRead);
// Just print out the first 10 points of the last data read
for (i = 0; i < 10; ++i)
printf ("data0[%d] = %f\tdata1[%d] = %f\n",i,data[2*i],i,data[2*i+1]);
}
printf("\nAcquired %d total samples.\n",totalRead);
Error:
if( DAQmxFailed(error) )
DAQmxBaseGetExtendedErrorInfo(errBuff,2048);
if(taskHandle != 0) {
DAQmxBaseStopTask (taskHandle);
DAQmxBaseClearTask (taskHandle);
}
if( DAQmxFailed(error) )
printf("DAQmxBase Error: %s\n",errBuff);
return 0;
}
With my values (12 channels, 48000Hz) it doesn't seems to work; I get the following message when readingAnalogF64 :
DAQmxBase Error: RLP Invoke Node <err>There is <b>not enough data</b> in the DMA buffer to fill the VI's read buffer. Either request less data, or wait until there is additional data in the DMA buffer.
With smallers values (10 channels or 30000Hz) it works better, even if sometimes I still get this error message.
After a few investigation it seem's that this not an error but just a warning (code 42), but I don't know if the values are correctly acquired.
As someone still faced this problem and have more information.
Thank in advance
Sylvain
08-13-2008 07:27 AM
A few more informations (forgotten) :
I run on linux (RHEL4 and RHEL5)
I tried on two differents machines (PentiumD 2.8Ghz, 1Go RAM and C2D 3GHz, 2Go RAM)
The approximately same code works with NIDAQmx (but this last isn't supported on RHEL5 that's the reason why I try NIDAQmxBase)
08-14-2008 10:50 AM
Hi Sylvain.
Could you send us a screen of the error message?
Thanks in advance.
Regards.
Romain D.
National Instruments France
08-19-2008 02:47 AM
Of course I can,
You can find enclosed a screen shot of my console.
I have tried many combination with no more results.
I'm thinking about a lack of optimisation in NIDAQmBase cause it works well with NIDAQmx.
Thanks for any help
08-25-2008 10:48 AM
Hello Atos.
Did you solve your problem?
Could you tell me the version of DaqmxBase did you use?
Thanks.
Regards.
Romain D.
National Instruments France
08-27-2008 02:26 AM
Well, I didn't solve the problem cause it's currently impossible to do this with DaqmxBase.
NI support, reproduce the problem with their example given below.
They also confirm that today the DAQmxBase layer is unable to acquire at the samplerate given in the hardware specification.
It seems to be a problem with the DMA writing/reading at high rates.
For me it's not very straight that NI sell a card with hight hardware specifications and linux support, althought they do not provide the software that enable to achieve this.
A bit incomprehensible ...
08-27-2008 10:37 AM
Hi Sylvain-
Which version of NI-DAQmx Base are you using? Which PCI/PXI hardware device are you using?
The error you are seeing is an internal software error that should not appear to the user in most cases. Some enhancements were made in NI-DAQmx Base 3.2 to help avoid this error, so I'm curious if you might be using an older version.
Thanks-
08-27-2008 12:28 PM
Hi Tom,
Thanks for replying.
Actually I've tried with 2 configurations
+ RHEL4, DAQmxBase 3.2 and 6259PCI Card
+ RHEL5, DAQmxBase 3.2 and 6254PCI Card
I've got the same problem. It seems that I try to acquire at too high rates.
Moreover there's not many configuration's functions provided with the DAQmxBase C API, so I can't try many configuration's combinations.
If someone can tell me more ...
09-15-2008 01:10 PM
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)
09-22-2008 07:52 AM - edited 09-22-2008 07:57 AM
Hi Jo,
Thanks for your answer,
Sorry for my being late on replying, I was a few day on holydays...
Actually when I start working on this project, I've began with NIDAQmx on RHEL4.
At that time, I was given instructions, drivers and the NI card and I didn't know that NIDAQmx doesn't support RHEL4.
Almost every things worked well ...
But today we have upgrade on RHEL5 (we've got new computers unsupported on the previous versions of RedHat).
That's the reason why we try NIDAQmxBase (Only this driver, supports the last versions of RedHat)
We faced the above problems ...
But as I have just said, every things run well with NIDAQmx on RHEL4/5 ... even thought it's not supported.
Does someone know in which circumstances the kernel stack overflow happens ?
This could help us make more test on the reliability of our application ...
Actually it's quite simple, it can be summarized as an infinite acquiring task.
Thans for any help,
Sylvain