From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

USB6008 in continuous acquisition mode - doesn't work

I am using a USB6008 to sample a voltage on channel A0 and displaying the results on a graph.  Very simple configuration.  If I set the device up for the 'n-samples' mode, I get n samples and it stops running.  All well and fine.  However, if I switch to the 'continuous' mode, I still get only n samples, n corresponding the value in the clock settings box.  Does any one have any thoughts on this?
 
Bob
0 Kudos
Message 1 of 7
(3,378 Views)
I advise you to search for example in the LV example database, for a continuous analog input voltage acquistion. Do you have an error or something like that ?
Please post your VI or a screen copy of your diagramm to help us to understand your problem.
Wilfried.
0 Kudos
Message 2 of 7
(3,368 Views)
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;
}
0 Kudos
Message 3 of 7
(3,365 Views)
Bob, we are talking about LabVIEW or something else ??
Wilfried.
0 Kudos
Message 4 of 7
(3,363 Views)

Hi Bob,

As Wilfried mentioned, it will be very helpful to know if you are seeing this problem in LabVIEW or in another programming language. Does this behavior repeat if you use Test Panels in Measurement and Automation Explorer? A screen shot of both configurations would help to determine exactly what is happening. One theory that I do have is that if you are using LabVIEW that you verify that the sample mode input on the DAQmx Timing.vi is set to the appropriate configuration.

JaceD
Signal Sources Product Support Engineer
National Instruments
0 Kudos
Message 5 of 7
(3,342 Views)

I appologise for the delay.  I am attaching (I think - never did this before) the vi that I am using.  Please bear with me, I am new to this and learning.

 

Bob

0 Kudos
Message 6 of 7
(3,337 Views)
Thanks all.  I have a working solution.  I had previously tried VI Logger, finding that it would give me exactly what I wanted: real time results and a data log; except that I could not get the database path to work.  I tried loading VI Logger onto a virgin computer, and all works perfectly.
0 Kudos
Message 7 of 7
(3,321 Views)