Hello Bob,
I'm using USB with no problem.
source code from examples..:
----------------------------------------------------------------------------------
#include <stdlib.h>
#include <cvirte.h>
#include <userint.h>
#include <math.h>
#include <NIDAQmx.h>
#include <DAQmxIOctrl.h>
#include "ContAcq-IntClk-EveryNSamplesEvent.h"
#define DAQmxErrChk(functionCall) if( DAQmxFailed(error=(functionCall)) ) goto Error; else
static int panelHandle;
static TaskHandle taskHandle=0;
static uInt32 numChannels;
static float64 *data=NULL;
int32 CVICALLBACK EveryNSamplesCallback(TaskHandle taskHandle, int32 everyNsamplesEventType, uInt32 nSamples, void *callbackData);
void Cleanup (void);
int main(int argc, char *argv[])
{
if( InitCVIRTE(0,argv,0)==0 )
return -1; /* out of memory */
if( (panelHandle=LoadPanel(0,"ContAcq-IntClk-EveryNSamplesEvent.uir",PANEL))<0 )
return -1;
SetCtrlAttribute(panelHandle,PANEL_DECORATION_BLUE,ATTR_FRAME_COLOR,VAL_BLUE);
SetCtrlAttribute(panelHandle,PANEL_DECORATION_GREEN,ATTR_FRAME_COLOR,VAL_GREEN);
NIDAQmx_NewPhysChanAICtrl(panelHandle,PANEL_CHANNEL,1);
DisplayPanel(panelHandle);
RunUserInterface();
DiscardPanel(panelHandle);
return 0;
}
int CVICALLBACK StartCallback(int panel, int control, int event, void *callbackData, int eventData1, int eventData2)
{
int32 error=0;
char chan[256];
uInt32 sampsPerChan;
float64 min,max,rate;
char errBuff[2048]={'\0'};
if( event==EVENT_COMMIT ) {
GetCtrlVal(panel,PANEL_CHANNEL,chan);
GetCtrlVal(panel,PANEL_MINVAL,&min);
GetCtrlVal(panel,PANEL_MAXVAL,&max);
GetCtrlVal(panel,PANEL_RATE,&rate);
GetCtrlVal(panel,PANEL_SAMPSPERCHAN,&sampsPerChan);
SetCtrlAttribute(panel,PANEL_STRIPCHART,ATTR_XAXIS_GAIN,1.0/rate);
SetCtrlAttribute(panel,PANEL_STRIPCHART,ATTR_POINTS_PER_SCREEN,sampsPerChan);
/*********************************************/
// DAQmx Configure Code
/*********************************************/
DAQmxErrChk (DAQmxCreateTask("",&taskHandle));
DAQmxErrChk (DAQmxCreateAIVoltageChan(taskHandle,chan,"",DAQmx_Val_Cfg_Default,min,max,DAQmx_Val_Volts,NULL));
DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandle,"",rate,DAQmx_Val_Rising,DAQmx_Val_ContSamps,sampsPerChan));
DAQmxErrChk (DAQmxGetTaskAttribute(taskHandle,DAQmx_Task_NumChans,&numChannels));
DAQmxErrChk (DAQmxRegisterEveryNSamplesEvent(taskHandle,DAQmx_Val_Acquired_Into_Buffer,sampsPerChan,0,EveryNSamplesCallback,NULL));
if( (data=malloc(sampsPerChan*numChannels*sizeof(float64)))==NULL ) {
MessagePopup("Error","Not enough memory");
goto Error;
}
/*********************************************/
// DAQmx Start Code
/*********************************************/
DAQmxErrChk (DAQmxStartTask(taskHandle));
SetCtrlAttribute(panel,PANEL_STRIPCHART,ATTR_NUM_TRACES,numChannels);
SetCtrlAttribute(panel,PANEL_START,ATTR_DIMMED,1);
ProcessDrawEvents();
}
Error:
SetWaitCursor(0);
if( DAQmxFailed(error) )
{
DAQmxGetExtendedErrorInfo(errBuff,2048);
Cleanup ();
MessagePopup("DAQmx Error",errBuff);
SetCtrlAttribute(panel,PANEL_START,ATTR_DIMMED,0);
}
return 0;
}
int32 CVICALLBACK EveryNSamplesCallback(TaskHandle taskHandle, int32 everyNsamplesEventType, uInt32 nSamples, void *callbackData)
{
int32 error=0;
int32 numRead;
char errBuff[2048]={'\0'};
/*********************************************/
// DAQmx Read Code
/*********************************************/
DAQmxErrChk (DAQmxReadAnalogF64(taskHandle,nSamples,10.0,DAQmx_Val_GroupByScanNumber,data,nSamples*numChannels,&numRead,NULL));
if( numRead>0 )
PlotStripChart(panelHandle,PANEL_STRIPCHART,data,numRead*numChannels,0,0,VAL_DOUBLE);
Error:
if( DAQmxFailed(error) )
{
DAQmxGetExtendedErrorInfo(errBuff,2048);
Cleanup ();
MessagePopup("DAQmx Error",errBuff);
SetCtrlAttribute(panelHandle,PANEL_START,ATTR_DIMMED,0);
}
return 0;
}
void Cleanup (void)
{
if( taskHandle!=0 )
{
/*********************************************/
// DAQmx Stop Code
/*********************************************/
DAQmxStopTask(taskHandle);
DAQmxClearTask(taskHandle);
taskHandle = 0;
}
if( data )
{
free(data);
data = 0;
}
}
int CVICALLBACK PanelCallback(int panel, int event, void *callbackData, int eventData1, int eventData2)
{
if( event==EVENT_CLOSE ) {
Cleanup();
QuitUserInterface(0);
}
return 0;
}
int CVICALLBACK StopCallback(int panel, int control, int event, void *callbackData, int eventData1, int eventData2)
{
if( event==EVENT_COMMIT )
{
Cleanup();
SetCtrlAttribute(panel,PANEL_START,ATTR_DIMMED,0);
}
return 0;
}
0;
}