Hello
I have some problem with data acquisition...
I would say that it is incredible or I am becoming mad :
here is my code:
int main (int argc, char *argv[])
{
....
status = CmtNewTSQ (QUEUE_SIZE, sizeof (double),OPT_TSQ_AUTO_FLUSH_EXACT, &queue);
// create new pools that will hold threads.
CmtNewThreadPool (1, &poolpublish); // one to publish data after
CmtNewThreadPool(1, &poolpid); // after for a PID loop
// install a callback function that will launch notify when there are new items in queue
CmtInstallTSQCallback (queue, EVENT_TSQ_ITEMS_IN_QUEUE, 100, Notify,NULL, poolpublish, &callbackId);
// Lock creation to protect threads (no interation between them)
CmtNewLock (NULL, 0, &mylock);...
status = NIDAQmx_NewPhysChanAICtrl(tabpanelHandlepos,TABPANEL_ChANPSDWTX,1);
status = NIDAQmx_NewPhysChanAICtrl(tabpanelHandlepos,TABPANEL_ChANPSDWTY,1);
//strong trap X and Y
status = NIDAQmx_NewPhysChanAICtrl(tabpanelHandlepos,TABPANEL_ChANPSDSTX,1);
status = NIDAQmx_NewPhysChanAICtrl(tabpanelHandlepos,TABPANEL_ChANPSDSTY,1);
//weak trap sumX and sumY
status = NIDAQmx_NewPhysChanAICtrl(tabpanelHandlepos,TABPANEL_ChANPSDWTSUMX,1);
status = NIDAQmx_NewPhysChanAICtrl(tabpanelHandlepos,TABPANEL_ChANPSDWTSUMY,1);
//strong trap sumX and sumY
status = NIDAQmx_NewPhysChanAICtrl(tabpanelHandlepos,TABPANEL_ChANPSDSTSUMX,1);
status = NIDAQmx_NewPhysChanAICtrl(tabpanelHandlepos,TABPANEL_ChANPSDSTSUMY,1);
...}
I ave a callback for data acquisition:
int CVICALLBACK AcquireData (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
if (event == EVENT_COMMIT)
status= DAQmxCreateTask ("TaskVoltageInputPSD", &TaskVoltageInput);
taskCreated = 1;
/*---------------------------------------------/*
//WEAK TRAP PSD reading position :
/* channel 0 input X weak trap*/
status= DAQmxCreateAIVoltageChan (TaskVoltageInput, "Dev1/ai0", "InputVoltWKX",
DAQmx_Val_Cfg_Default, -5.0, 5.0,
DAQmx_Val_Volts, "");
/* channel 1 input Y weak trap*/
status= DAQmxCreateAIVoltageChan (TaskVoltageInput, "Dev1/ai1", "InputVoltWKY",
DAQmx_Val_Cfg_Default, -5.0, 5.0,
DAQmx_Val_Volts, "");
/*--------------------------------------------/*
//STRONG TRAP PSD reading position :
/* channel 2 input X strong trap*/
DAQmxCreateAIVoltageChan (TaskVoltageInput, "Dev1/ai2", "InputVoltSTX",
DAQmx_Val_Cfg_Default, -5.0, 5.0,
DAQmx_Val_Volts, "");
/* channel 3 input Y strong trap*/
DAQmxCreateAIVoltageChan (TaskVoltageInput, "Dev1/ai3", "InputVoltSTY",
DAQmx_Val_Cfg_Default, -5.0, 5.0,
DAQmx_Val_Volts, "");
.....there are other channels made on the same scheme
// the clock
status = DAQmxCfgSampClkTiming (TaskVoltageInput, "OnboardClock", SAMPLING_RATE,
DAQmx_Val_Rising, DAQmx_Val_ContSamps, SAMPLING_RATE);
// start the task
status= DAQmxStartTask (TaskVoltageInput);
// launch the publish thread :
status= CmtScheduleThreadPoolFunction (poolpublish,Publish,NULL, &thread);
while (stop ==0)
{
/* find out how many samples are available and read them */
status= DAQmxGetReadAttribute (TaskVoltageInput, DAQmx_Read_AvailSampPerChan,&data.daq);
// read data and put them in the matrix data.values , data are grouped by channels
status = DAQmxReadAnalogF64 (TaskVoltageInput, DAQmx_Val_Auto, 1,DAQmx_Val_GroupByChannel, data.values, NUM_VALUES, &data.count, NULL);
/* write the data to the queue if successful */
// lock this thread to avoid interferences
CmtGetLock (mylock);
status =CmtWriteTSQData (queue, &data, NUM_VALUES*nbchan, 0, NULL);
CmtReleaseLock (mylock);
// for the end of the other thread
ProcessSystemEvents ();
}
// stop and clear the task
DAQmxStopTask (TaskVoltageInput);
DAQmxClearTask (TaskVoltageInput);
}
Then in publish, there are different plotstripchart function and plotpoint..... But i am using the same functions in the same order as the one in the example :Cont Acq-Int Clk that is in the folder samples , DAQ mx, Input volatge
And these example manage to acquire data.....
Please help
estelle