Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

NI6009 Timing & PC transfer rate

We are trying to develop a robotic arm control system. The devices involved in this project include a NI USB-6009 DAQ. We know that this device can sample at 42 KSamples/second, but we assume it is not the frequency at which samples arrive to the PC. We are working with NI DAQmx Base, on a Linux platform. The samples arrive to the PC (by calling the DAQmxBaseReadAnalogF64 C function - see attached code). Then are processed, and the resultant signals are send back to the motors to move the joints. 
The fact is that the samples arrive to the PC at about 100 S/Sec... It's not enough for our requirements. We need at least 1 KS/S (for each channel, and about 8 channels). 
What device do you recommend us? Is it possible to reach those requirements with the NI 6009 DAQ?

Regards

Federico
 

#include "NIDAQmxBase.h"#include <stdio.h>#define DAQmxErrChk(functionCall) { if( DAQmxFailed(error=(functionCall)) ) { goto Error; } }int main (int argc, char *argv[]){ unsigned int j; // Task parameters int32 error = 0; TaskHandle taskHandle = 0; TaskHandle taskHandlew = 0; char errBuff[2048]={'\0'}; int32 i; // Channel parameters char chan[] = "Dev1/ai0"; // Canal a leer. char chan_out[] = "Dev1/ao0"; // Canal a escribir. float64 min = 0.1; // Valor minimo de lectura (para el caso, tension minima). float64 max = 4.9; // Valor maximo de lectura (para el caso, tension maxima). #define bufferSize (uInt32)1 // Tamano del buffer. #define channels 1 // Cantidad de canales a analizar. // Timing parameters char source[] = "OnboardClock"; // Fuente de clock. uInt64 samplesPerChan = bufferSize; // Muestras por canal. float64 sampleRate = 20.0; // Frecuencia de muestreo (hay que ver como mejorar). // Data read parameters float64 data[bufferSize]; // Buffer de datos (punto flotante). int16 data_int[bufferSize]; // Buffer de datos (enteros). int32 pointsToRead = 1; // Muestras a obtener (si es -1 obtiene las muestras requeridas por la tarea). int32 pointsRead[channels]; // Cantidad de muestras leidas de cada canal. float64 timeout = 2.0; // Data write parameters float64 dataw = 2.77; int32 pointsWritten; bool32 isTaskDone = FALSE; // Creacion de la tarea. DAQmxErrChk (DAQmxBaseCreateTask ("Tarea de captura", &taskHandle)); DAQmxErrChk (DAQmxBaseCreateTask ("Tarea de escritura", &taskHandlew)); // Crea un canal analogico (voltage) de entrada. // Tiene como parametros: tarea, canal, NULL, modo (se, seref, diff, etc), minimo, maximo, unidad, NULL. DAQmxErrChk (DAQmxBaseCreateAIVoltageChan (taskHandle, chan, NULL, DAQmx_Val_Cfg_Default, min, max, DAQmx_Val_Volts, NULL)); // Crea un canal analogico (voltage) de salida. // Tiene como parametros: tarea, canal, NULL, minimo, maximo, unidad, NULL. DAQmxErrChk (DAQmxBaseCreateAOVoltageChan (taskHandlew, chan_out, NULL, min, max, DAQmx_Val_Volts,NULL)); // Establece la configuracion de tiempos para la tarea seleccionada. // Tiene como parametros: tarea, fuente de clock, frecuencia de muestreo, flanco de captura, modo (continuo o finito), cantidad de muestras (si modo es finito). DAQmxErrChk (DAQmxBaseCfgSampClkTiming (taskHandle, source, sampleRate, DAQmx_Val_Rising, DAQmx_Val_ContSamps, samplesPerChan)); // Muestreo continuo. DAQmxErrChk ( DAQmxBaseCfgInputBuffer (taskHandle, 0)); // Inicia la tarea seleccionada. Cuando la tarea finaliza, esta funcion retorna? DAQmxErrChk (DAQmxBaseStartTask (taskHandle)); DAQmxErrChk (DAQmxBaseStartTask (taskHandlew)); for(j=0;j<1000;j++){ // Punto flotante. DAQmxErrChk (DAQmxBaseReadAnalogF64 (taskHandle, pointsToRead, timeout, DAQmx_Val_GroupByChannel, data, bufferSize, pointsRead, NULL)); printf("%d. Muestra: %f (cantidad total de datos: %d)\n", j, data[0], pointsRead[0]); DAQmxErrChk (DAQmxBaseWriteAnalogF64(taskHandlew, samplesPerChan,0,timeout,DAQmx_Val_GroupByChannel,data,&pointsWritten,NULL)); printf("Puntos escritos: %d.\n\n",pointsWritten); }// ERROR HANDLING//Error: ...

 

 
0 Kudos
Message 1 of 3
(3,800 Views)
First, you posted to the instrument control board and it should have been the multifunction DAQ board. Second, the format of your code makes it next to impossible to read. What I was able to determine is that you are only requesting a single sample at a time. You are then using software time input. If you had a single channel and set for 42 kS/sec and requested 42 kSamples, you would get that number of samples each and every second. That uses the onboard clock for acquisition instead of your loop. I can't understand much of the rest of your code. In order to obtain the faster acquisition rate, make sure you start the task once, outside the loop, and stop the task once, when the loop finishes.
Message 2 of 3
(3,796 Views)

Sorry, the code was unreadable because of the explorer I was using.

I'll post my doubt in the correct board.

 

Regards

 

Federico 

0 Kudos
Message 3 of 3
(3,791 Views)