I am trying to write a program in C (WinXP, MS Visual C++ 6.0) that uses a USB-6009 board to perform
real-time control, that is, each time the internal clock of the board ticks I need to execute the
Step 1: read the values from 1 or more AD converters,
Step 2: perform some calculations with these values,
Step 3: then write some values to1 or more DA converters.
Step 4: wait until the next timer tick and go back to step 1.
I have already studied the documentation of the board and I have a working program.
The problem is, even if I just want to write to the DA the value that I get from the AD, there is a delay larger
than one sampling period between these operations. I am using an osciloscope to measure this delay.
My current program is as follows:
1) create and configure the tasks (AD and DA conversions, 1 input and 1 output):
DAQmxErrChk (DAQmxCreateAIVoltageChan(Tarefa_Entrada,Canal_Entrada,"", Modo_Aquisicao, Tensao_Min_PE, Tensao_Max_PE, DAQmx_Val_Volts,NULL));
DAQmxErrChk (DAQmxCreateAOVoltageChan(Tarefa_Saida1,Canal_Saida1,"", Tensao_Min_PS, Tensao_Max_PS, DAQmx_Val_Volts,""));
2) create the clock:
DAQmxErrChk (DAQmxCfgSampClkTiming(Tarefa_Entrada,"",Amostras, DAQmx_Val_Rising,DAQmx_Val_ContSamps, (int64)Buffer));
3) start the tasks:
4) execute the control loop:
printf("Starting the control loop ...\n\n");
DAQmxErrChk (DAQmxReadAnalogF64(Tarefa_Entrada, 1, Timeout, DAQmx_Val_GroupByScanNumber, leitura, 2, &num_leit, NULL));
}while(kbhit()==0); //Loop é interrompido quando alguma tecla é pressionada
What is wrong with this program? How I should modify it?
Many thanks for any help.
Cairo L. Nascimento Jr. and Jeeves L. dos Santos
ITA - Brazi
Dear Cairo and Jeeves,
This USB-6009 take a longer time because it´s not used for real-time applications. This board takes the signal from AD and send it through DA, but the calculations aren´t made by the board.
National Instruments has products for applications that requests determinisms and real-time processor.
Refer the follow link for more information about Real-Time, but one important point to consider is how fast your application is.
RegardsJailton – NIB – SR 1246123