From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
10-17-2012 08:42 AM
Hi,
I am using a PCIe 6341 board and coding under visual c++ 2010. I need to do an analog acquisition of 10 points at 500kHz every 200µs. In order to be fast, I permit the card to overwrite the buffer and take the last 10 points written in the buffer. Unfortunately, the time to take the data is of 10ms which is too slow for me who need to read the data every 0.2ms. What do I do wrong ?
My code is :
#include "stdio.h"
#include "NIDAQmx.h"
#include <time.h>
#define DAQmxErrChk(functionCall) if( DAQmxFailed(error=(functionCall)) ) goto Error; else
#define nb_point 10
#define frequence 500000
int main(void)
{
int32 error=0;
TaskHandle taskHandle=0;
int32 read;
float64 data[nb_point];
char errBuff[2048]={'\0'};
int64 samplesToAcquire=100000 ;
int cpt ;
// essai pour mesure du temps
int
temps_initial,
temps_final;
float
temps_cpu;
/*********************************************/
// DAQmx Configure Code
/*********************************************/
DAQmxErrChk (DAQmxCreateTask("",&taskHandle));
DAQmxErrChk (DAQmxCreateAIVoltageChan(taskHandle,"Dev1/ai0","",DAQmx_Val_Cfg_Default,-10.0,10.0,DAQmx_Val_Volts,NULL));
DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandle,"",frequence,DAQmx_Val_Rising,DAQmx_Val_ContSamps,samplesToAcquire));
DAQmxErrChk (DAQmxSetReadRelativeTo(taskHandle,DAQmx_Val_MostRecentSamp));
DAQmxErrChk (DAQmxSetReadOffset(taskHandle,nb_point));
/***********************/
// debut de mesure avant le lancement de la tache
/***********************/
printf("Parti?\n");
getchar();
/*********************************************/
// DAQmx Start Code
/*********************************************/
DAQmxErrChk (DAQmxStartTask(taskHandle));
/*********************************************/
// DAQmx Read Code
/*********************************************/
for ( cpt = 0 ; cpt <11 ; cpt++ )
{
temps_initial = clock ();
DAQmxErrChk (DAQmxReadAnalogF64(taskHandle,nb_point,10.0,DAQmx_Val_GroupByChannel,data,nb_point,&read,NULL));
/***********************/
// fin de mesure du temps
/***********************/
temps_final = clock ();
temps_cpu = ((float)temps_final - temps_initial)/CLOCKS_PER_SEC;
printf("Temps d execution : %f\n",temps_cpu);
printf("Acquired %d points\n",read);
}
Error:
if( DAQmxFailed(error) )
DAQmxGetExtendedErrorInfo(errBuff,2048);
if( taskHandle!=0 ) {
/*********************************************/
// DAQmx Stop Code
/*********************************************/
DAQmxStopTask(taskHandle);
DAQmxClearTask(taskHandle);
}
if( DAQmxFailed(error) )
printf("DAQmx Error: %s\n",errBuff);
printf("End of program, press Enter key to quit\n");
getchar();
return 0;
}
Thanks a lot for your help !!!! I am quite desesperate to solve this problem !!!!
10-23-2012 10:24 AM
Samuel G. | GEMESIS
Certified LabVIEW Architect
Certified TestStand Developer
10-23-2012 02:11 PM
Je pense que si la reactvite et l efficacite de vos servives avaient plus grande je n aurai pas eu a poster sur le forum 3 fois la meme question.
Merci d avoir apporte tant de reponses a mon probleme