ContGen-IntClk - DoneCallback

I followed this code example, ContGen - IntClk.c.


#include
#include

#define DAQmxErrChk (functionCall) if( DAQmxFailed(error = (functionCall)) ) goto Error; else
#define PI 3.1415926535
#define DAQmxFailed(error) ((error)<>

int32 CVICALLBACK DoneCallback (TaskHandle taskHandle, int32 status, void *callbackData);

int main(void)
{
int32 error = 0;
TaskHandle taskHandle = 0;
float64 data [1000];
char errBuff [2048] = {'\0'};
int i = 0;

for (; i < 1000;="" i++)="" data="" [i]="9.95" *="" sin(="" (double)="" i="" *="" 2.0="" *="" pi="">

/*********************************************/
// DAQmx Configure Code
/*********************************************/
DAQmxErrChk (DAQmxCreateTask ("",&taskHandle) );
DAQmxErrChk (DAQmxCreateAOVoltageChan (taskHandle,"Dev1/ao0","",-10.0,10.0,DAQmx_Val_Volts,NULL) );
DAQmxErrChk (DAQmxCfgSampClkTiming (taskHandle,"",1000.0,DAQmx_Val_Rising,DAQmx_Val_ContSamps,1000) );
DAQmxErrChk (DAQmxRegisterDoneEvent (taskHandle,0,DoneCallback,NULL) );

/*********************************************/
// DAQmx Write Code
/*********************************************/
DAQmxErrChk (DAQmxWriteAnalogF64 (taskHandle,1000,0,10.0,DAQmx_Val_GroupByChannel,data,NULL,NULL) );

/*********************************************/
// DAQmx Start Code
/*********************************************/
DAQmxErrChk (DAQmxStartTask(taskHandle));

printf ("Generating voltage continuously. Press Enter to interrupt\n");
getchar ();

Error:

if ( DAQmxFailed (error) )
DAQmxGetExtendedErrorInfo (errBuff,2048);

if ( taskHandle != 0 )
{
/*********************************************/
// DAQmx Stop Code
/*********************************************/
DAQmxStopTask (taskHandle);
DAQmxClearTask (taskHandle);
}

if ( DAQmxFailed(error) )
printf ("DAQmx Error: %s\n",errBuff);

printf ("End of program, press Enter key to quit\n");
getchar ();

return 0;
}

int32 CVICALLBACK DoneCallback (TaskHandle taskHandle, int32 status, void *callbackData)
{
int32 error = 0;
char errBuff [2048] = {'\0'};

// Check to see if an error stopped the task.
DAQmxErrChk (status);

Error:
if( DAQmxFailed (error) )
{
DAQmxGetExtendedErrorInfo (errBuff,2048);
DAQmxClearTask (taskHandle);
printf ("DAQmx Error: %s\n", errBuff);
}

return 0;
}

I would ask what generates the DoneCallback() function call.  Thank you.

It is easy to find by yourself

The code for the name of the search function and you will see that this recall is due to DAQmxRegisterDoneEvent, then the callback function is executed when the task of acquiring stop.

Tags: NI Software

Similar Questions

  • Bad analog output help Every_N_Samples-NI-9263 cDAQ-9172 chassis (works with cDAQ-9178 chassis)

    Hello

    The NOR-9263 analog output voltage geberation works correctly with the cDAQ-9178 chassis but gives wrong result using the chassis NOR cDAQ-9172.

    In the attached code example, a single cycle of a sine wave is composed of 40000 samples and came out in the background using Every_N_Samples at a rate of production of 5000 samples per second.

    The output buffer size is set to 10000 samples.

    Prepare us the buffer writing 10000 samples 1, then write the remaining data in the background using the Every_N_Samples callback.
     
    Bug: Using the cDAQ-9172 chassis, to the 5000 s/s sampling rate with the help of an external field (or through closure to another HAVE), we observed that 1 10000 samples came out twice, followed by the rest of the waveform. The last 10000 samples are never exits. If you are working properly, we would expect to see 1 full cycle of a sine wave.

    The bug does not occur with the chassis NOR cDAQ-9178. I use the driver NIDAQmx v9.2.1f0 on Windows XP
    The bug does not happen with simulation devices, so you will need to use harwdare real to reproduce.

    Please find attached an example of code C based on the example program OR "ContGen - IntClk.c" to reproduce this bug.

    Thank you

    whemdan,

    The MathWorks

    Hi whemdan,

    By default, DAQmx regenerate old samples if no new data is available.  To give the correct behavior, you can:

    Use DAQmxSetWriteRegenMode to disable the regeneration (DAQmx_Val_DoNotAllowRegen).  In most cases, this is recommended if new data are written continuously in the buffer as the build is in progress.

    If you just need to generate 40 k samples, you can write them just all at once, rather than in 10 pieces of k (the code you attached probably is just an example, so I'll assume that you have a reason to write the data into segments in your actual code).

    I think the difference in behavior between 9172 and 9178 can if explained by the different way, buffering is set up on each product.  The 9172 uses a buffer of 8 k (on the STC2) in all cases (source).  The 9178 uses an 8 k of memory buffer (on the STC3) If you use regeneration shipped, but uses the 127 samples FIFO cartridge, if you use no on-board regeneration (source).

    Then... on the 9172 8191 samples are immediately transferred to the FIFO.  By default, the hardware is going to request new data when the FIFO is less to fill (this is configurable with DAQmxSetAODataXferReqCond).  I'm not sure what the transfer data request size is in your case (you can set the maximum value with DAQmxSetAOUsbXferReqSize), but obviously it is bigger than the other 1809 samples that you have not yet sent to the Board of Directors of your first entry.  At this point, the pilot will regenerate 10 existing k samples so that sufficient data will be available to meet the demand of data transfer.

    The 9178 however use the FIFO of 127 smaller samples so you will not have the same behavior in your case.

    In summary, the behavior is explainable by the difference of material.  If you want to avoid to regenerate old samples, you should ban the regeneration using DAQmxSetWriteRegenMode.

    Best regards

  • frequency max USB-6251

    I use a box NI USB-6251 and frequency max I can carry out to an0 an1 is 8 kHz using the following parameters. Is there a way to reach a frequency higher on the analog output ports?

    Config:

    Capture of the oscilloscope:

    I've reconfigured the config to try and hit 10 kHz and captured the following response.

    config:

    Oscilloscope Capture: (before port analog flat doubled)

    The signal is emitted for 7ms then faints.

    Any ideas how to set up the analog interface for a sine wave of 100 kHz to the stable address? I could only create a stable 8 kHz wave.

    To use higher frequencies, you'll need to use LabVIEW or custom code. I used the example of "ContGen - IntClk.c" located in "C:\Users\Public\Documents\National Instruments\NI - DAQ\Examples\DAQmx C\Analog Out\Generate Voltage\Cont Gen Volt Wfm - Int Clk ANSI" and changed the two lines of code to achieve higher frequencies.

    2 changed lines:

     1. data[i]=1*sin((double)i*2.0*PI/25.0);
    
     2. DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandle,"",2800000.0,DAQmx_Val_Rising,DAQmx_Val_ContSamps,1000));
    

    Output waveform:

    Thank you TO help me with this. =)

  • Analog output PCI-6251-DAQ-200016 memory overflow error

    NI PCI - 6251 DAQmx, AIMD-752 motherboard, dual core processor, a lot of speed and the ram running WinXP Pro & LabWindows/CVI

    get DAQ-200016 memory overflow error when I try to generate a signal of analog output with a rate higher than about 32 000 samples/second (?)

    going on what?  I have never seen it before.   Is this a problem with the motherboard?    "It's the same product on the CVI code example" \Cont Gen Volt Wfm - Int Clk\ContGen - IntClk.cws.

    If someone has had this problem, and is there a solution?

    Thank you

    PS: full text of the message reads:

    Measurements: On-board memory precision passing. Due to the limitations of system and/or the bandwidth of the bus, the driver could not write data to the device fast enough to track the rate of output of the device.  Reduce your sampling rate, change the method of transfer of data (from interruptions on DMA), use a product with more on-board memory or reduce the number of programs that your computer runs simultaneously. Task name: _unnamedTask<1> Code of State:-200016

    Well, I found my answer.   For later use, Olivia NI Apps Engineering suggested I have change the mechanism of data transfer by this Knowledge Base document:

    http://digital.NI.com/public.nsf/WebSearch/C326F7D33CA6DB0E86256DFE008043B7?OpenDocument

    ... so I inserted the line of code between the creation of the area of OCCUPANCY of the channels and set up the example of clock calendar.

    DAQmxCreateAOVoltageChan( ...
    
    DAQmxSetAODataXferMech(TaskHandle,chan,DAQmx_Val_Interrupts);
    
    DAQmxCfgSampClkTiming(...
    

    now, I am able to generate output to a 2.35 MS/sec... max sampling frequency not quite the 2.86MS / sec indicated in the specification 6251, but close enough that I'll stop complaining

  • Problem in ANSI C for example - error TDMS-ContAcq-IntClk 200877

    Hello

    I tried the examples in the 'ANSI C examples' folder and ran into a snag with the example in:

    "" \DAQmx ANSI C\Analog In\Measure Voltage\Acq TDMS-Cont-Int Clk".

    When I run it as it is, I get the following error:

    DAQmx error: requested each interval of N samples event is not supported for the given the mechanism of transfer of data and the buffer size. To keep the DMA or USB in bulk as the data transfer mechanism, change the size of the buffer or the interval of event Every N samples so the size of the buffer is a multipleof even interval event Every N samples. To keep the same each event interval of N samples and the size of the buffer, modify the mechanism for transfer of data interruptions if taken in charge. Property: DAQmx_Every N samples CQI event IntervalRequested value buffer: size 1000Buffer: 12288Task name: _unnamedTask<0>State :-200877End of the program Code, press the Enter key to exit

    As I was typing this, I did a quick test. I tried to comment this line in the code:

    / / * / / PDM DAQmx Configure Code / * / DAQmxErrChk (DAQmxConfigureLogging(taskHandle,"C:\\example.tdms",DAQmx_Val_LogAndRead,"GroupName",DAQmx_Val_OpenOrCreate));)

    and it worked, as I suspected.

    My gut feeling is that the DAQmxConfigureLogging function expects a block of 12 288 bytes, and in the rest of the code, the number of samples is set to 1000, with a sampling frequency of 10000.

    In any case, I fixed it by changing from 1000 to 1024 (1024 because * 12 = 12288) anywhere in the code, so solve the original problem.

    I don't have a few new questions now:

    1. is this an error in the example, or am I missing something?

    2. How do you change the default size 12288 DAQmxConfigureLogging() waiting for let say 5000?

    Thank you.

    Hall

    Hey Bob,

    In fact, it is a bug with this example.  It comes with the value 1000 for the wrong sampling interval since it is an example of logging.  When logging is enabled on a task, default buffer sizes are slightly different from the default values without connecting.  This is because the default buffer sizes are powers of 10, while hard drives prefer to powers of 2.  It is a maneuver of performance as we listen to disc directly from the buffer DAQmx.

    I think you should be able to use 1024 as your sampling instead of 1000 interval in this example.  In this example, the default value will change so that it is not immediately error (Corrective Action Request #177199).

  • PCI-6132 redeclenchables

    Dear all,

    I have a problem with my acquisition of data PCI-6132. I need
    to acquire the signal with a finished sample. Data acquisition signal of early acquisition of
    Digital edge of the trigger of the beginning, start signal to the spesified collection
    quantity of the sample were acquired. Its beginning to collect a finished sample
    Yet once when another trigger of early digital dashboard detected.

    Therefore,.
    I put the attribute trigger digital beginning as retrigerable. But when I
    called DAQmxErrChk (DAQmxSetStartTrigRetriggerable (taskHandle, true)), it
    who says:

    DAQmx error: the specified property is not supported by the device or is not applicable to the task.
    Property: DAQmx_StartTrig_Retriggerable

    Task name: _unnamedTask<0>

    State code:-200452
    End of the program, press the Enter key to exit

    First of all,
    I think that the DAQmx_StartTrig_Retriggerable property is not supported by
    My DAQ (PCI-6132). But when I read Help reference C-NOR-DAQmx, suite
    Well supported by heading device, redeclenchables start is one of OR
    PCI-6132 taken in charge the property. Why this error eccur?

    My code
    is the same as ContAcq-IntClk-DigStart - Retrig.c

    Int32 = 0 error;
    TaskHandle taskHandle = 0;
    tank errBuff [2048] = {'\0'};

    /*********************************************/
    DAQmx Configure Code
    /*********************************************/
    DAQmxErrChk (DAQmxCreateTask("",&taskHandle));
    DAQmxErrChk (DAQmxCreateAIVoltageChan(taskHandle,"Dev1/ai0","",DAQmx_Val_Cfg_Default,-10.0,10.0,DAQmx_Val_Volts,NULL));
    DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandle,"",1000.0,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,100));
    DAQmxErrChk (DAQmxCfgDigEdgeStartTrig(taskHandle,"/Dev1/PFI1",DAQmx_Val_Rising));
    DAQmxErrChk (DAQmxSetStartTrigRetriggerable (taskHandle, true));

    DAQmxErrChk (DAQmxRegisterEveryNSamplesEvent (taskHandle, DAQmx_Val_Acquired_Into_Buffer, 100, 0, EveryNCallback, NULL));
    DAQmxErrChk (DAQmxRegisterDoneEvent(taskHandle,0,DoneCallback,));

    /*********************************************/
    Starting code DAQmx
    /*********************************************/
    DAQmxErrChk (DAQmxStartTask (taskHandle));

    printf ("absorbent samples continuously. Press Enter to interrupt\n ");
    GetChar ();

    Error:
    If (DAQmxFailed (error))
    DAQmxGetExtendedErrorInfo (errBuff, 2048);
    If (taskHandle! = 0) {}
    /*********************************************/
    Stop DAQmx code
    /*********************************************/
    DAQmxStopTask (taskHandle);
    DAQmxClearTask (taskHandle);
    }
    If (DAQmxFailed (error))
    printf ("error DAQmx: %s\n",errBuff); ")

    Thank you
    You

    Hi oktanto,

    I simulated the device, but I was not able to run a redeclenchables VI of analog input. It seems that this property is not supported by the 6132. There may be a workaround is possible: you may be interested by the following code example. Although it is a little older, he should probably still work for you

  • input analog/sync problem

    Hi all

    I use USB - 6363 CVI 2013 with patches and trying to solve this problem for days. But just does not know what the problem is.

    Basically I have a finite periods display analog sine wave (which works fine), then I would like to receive (or other stuff) to an analog pathway for the objective test.

    The thing is that I can't get anything this either port HAVE, straight zeros in this table. I tried to put some DAQmxCfgAnlgEdgeStartTrig on the port of AI0 but still no result. and right now

    I don't have the ability to test if APFI0 method will work or not. So now I'm on an internal trigger.

    Here's what I did to get so far, no error. But all I see on the result of the sinearrayfin table is zeros. sinearrayf matches the entry and tested to have the data in it.

    sinearrayf = (float64 *) malloc (800 * arraysize4 * sizeof (float64));
    for (int f = 0; f)<>
    {
    sinearrayf [f] = sinearray (float64) [f];
    }
    sinearrayfin = (float64 *) malloc (800 * arraysize4 * sizeof (float64));
    for (int f = 0; f)<>
    {
    sinearrayfin [f] = 0;
    }

    error int = 0;
    char errBuff [2048] = {'\0'};
    trigName char [256];
    Written Int32 = 0;

     DAQmxErrChk (DAQmxCreateTask("",&AItaskHandle));
    DAQmxErrChk (DAQmxCreateAIVoltageChan(AItaskHandle,"/Dev1/ai0","",DAQmx_Val_Cfg_Default,-10.0,10.0,DAQmx_Val_Volts,NULL));
    DAQmxErrChk (DAQmxCfgSampClkTiming(AItaskHandle,"",800000.0,DAQmx_Val_Rising,DAQmx_Val_ContSamps,800*arraysize4));
    DAQmxErrChk (GetTerminalNameWithDevPrefix(AItaskHandle,"ai/StartTrigger",trigName));

    DAQmxErrChk (DAQmxCreateTask("",&AOtaskHandle));
    DAQmxErrChk (DAQmxCreateAOVoltageChan(AOtaskHandle,"Dev1/ao0","",-10.0,10.0,DAQmx_Val_Volts,NULL));
    DAQmxErrChk (DAQmxCfgSampClkTiming(AOtaskHandle,"",800000.0,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,800*arraysize4));
    DAQmxErrChk (DAQmxCfgDigEdgeStartTrig (AOtaskHandle, trigName, DAQmx_Val_Rising));

    DAQmxErrChk (DAQmxWriteAnalogF64 (AOtaskHandle, 800 * arraysize4, 0, 10.0, DAQmx_Val_GroupByChannel,sinearrayf, & writing, NULL));
    DAQmxErrChk (DAQmxRegisterDoneEvent(AOtaskHandle,0,DoneCallback,));

    DAQmxErrChk (DAQmxRegisterEveryNSamplesEvent (AItaskHandle, DAQmx_Val_Acquired_Into_Buffer, 10000, 0, EveryNCallback, NULL));

    /*********************************************/
    Starting code DAQmx
    /*********************************************/

    DAQmxErrChk (DAQmxStartTask (AOtaskHandle));
    DAQmxErrChk (DAQmxStartTask (AItaskHandle));
          
    Error:
    If (DAQmxFailed (error))
    DAQmxGetExtendedErrorInfo (errBuff, 2048);
    If (AItaskHandle! = 0) {}
    /*********************************************/
    Stop DAQmx code
    /*********************************************/
    DAQmxStopTask (AItaskHandle);
    DAQmxClearTask (AItaskHandle);
            
    }
    If (AOtaskHandle! = 0) {}
    /*********************************************/
    Stop DAQmx code
    /*********************************************/
    DAQmxStopTask (AOtaskHandle);
    DAQmxClearTask (AOtaskHandle);
            
    }
        
        
    If (DAQmxFailed (error))
    printf ("error DAQmx: %s\n",errBuff); ")

    .......

    Int32 CVICALLBACK EveryNCallback(TaskHandle taskHandle, int32 everyNsamplesEventType, uInt32 nSamples, void *callbackData)
    {
    Int32 error = 0;
    char errBuff [2048] = {'\0'};
    public static int totalAI = 0;
    readAI of Int32;

    DAQmxErrChk (DAQmxReadAnalogF64 (AItaskHandle,-1, 10.0, DAQmx_Val_GroupByChannel,sinearrayfin, 800 * arraysize4 & readAI, NULL));

    fflush (stdout);

    return 0;
    }

    What I see from a quick look at the code that you understood, looks that you stop tasks without giving a sample of 10,000 time to accumulate in the buffer.  This section of code here: does the following:

        /*********************************************/
    Starting code DAQmx

    /*********************************************/
    DAQmxErrChk (DAQmxStartTask (AOtaskHandle)); Start the task of AO
    DAQmxErrChk (DAQmxStartTask (AItaskHandle)); Start the task of HAVE

    There is no waiting or anything here which would be
    stop the section error to be executed immediately
    Error:
    If (DAQmxFailed (error)) / / there is no error if this section does not
    DAQmxGetExtendedErrorInfo (errBuff, 2048);
    If (AItaskHandle! = 0) {/ / there is a task of so HAVE this section not}
    /*********************************************/
    Stop DAQmx code
    /*********************************************/
    DAQmxStopTask (AItaskHandle); Task of is stopped and deleted
    DAQmxClearTask (AItaskHandle);

    }
    If (AOtaskHandle! = 0) {/ / there is a task AO so this section runs as well}
    /*********************************************/
    Stop DAQmx code
    /*********************************************/
    DAQmxStopTask (AOtaskHandle); Task of the AO is arrested and cleared
    DAQmxClearTask (AOtaskHandle);

    } / / The two tasks are arrested and cleared samples before
    are allowed to accumulate in the buffer and call
    the callback to perform playback DAQmx.

    If you look at the example of ' ContAck - IntClk.c ", he has a GetChar(); function between startup tasks and the block of the error.  This actually awaits as you press a button before stopping and compensation tasks.

  • How to sample multiple sensors in a vital task?

    I need to a thermocouple sensor and voltage sensor in a vital task of the sample. My hardware configuration includes a cDAQ-9172 chassis with a NI9211 TC module and a NI9221 voltage input module.

    I started with the example C code for thermocouple measurement found here:

    Instruments\NI-national DAQ\Examples\DAQmx C\Analog In\Measure Temperature\Cont Thrmcpl samples-Int Clk\ContThrmcplSamps ANSI - IntClk.c

    I then added a few lines of code for the measurement of additional tension.

    The task runs for about 20 seconds, until the buffer overflow with the error 200279.

    I can run task, thermocouple or voltage, indefinitely. It's only when I include them both in the same task as the buffer overflow.

    I have tried many combinations of sampling rate, the size of the buffer and DAQmxRegisterEveryNSamplesEvent nSample size.

    Below is the code I'm running.  Changes to the original file are marked in bold. I've attached a screenshot of the output of command line.

    Can anyone offer a C program example showing how to sample multpile sensors permanently in a task?

    #include 
    #include 
    
    #define DAQmxErrChk(functionCall) if( DAQmxFailed(error=(functionCall)) ) goto Error; else
    
    int32 CVICALLBACK EveryNCallback(TaskHandle taskHandle, int32 everyNsamplesEventType, uInt32 nSamples, void *callbackData);
    int32 CVICALLBACK DoneCallback(TaskHandle taskHandle, int32 status, void *callbackData);
    
    int main(void)
    {
        int32       error=0;
        TaskHandle  taskHandle=0;
        char        errBuff[2048]={'\0'};
    
        /*********************************************/
        // DAQmx Configure Code
        /*********************************************/
        DAQmxErrChk (DAQmxCreateTask("",&taskHandle));
        DAQmxErrChk (DAQmxCreateAIThrmcplChan(taskHandle,"cDAQ1Mod1/ai0","",0.0,100.0,DAQmx_Val_DegC,DAQmx_Val_K_Type_TC,DAQmx_Val_BuiltIn,25.0,""));
     DAQmxErrChk (DAQmxCreateAIVoltageChan(taskHandle,"cDAQ1Mod4/ai0","",DAQmx_Val_Cfg_Default,-60.0,60.0,DAQmx_Val_Volts,NULL));
        DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandle,"",1000.0,DAQmx_Val_Rising,DAQmx_Val_ContSamps,1000));
    
        DAQmxErrChk (DAQmxRegisterEveryNSamplesEvent(taskHandle,DAQmx_Val_Acquired_Into_Buffer,1000,0,EveryNCallback,NULL));
        DAQmxErrChk (DAQmxRegisterDoneEvent(taskHandle,0,DoneCallback,NULL));
    
        /*********************************************/
        // DAQmx Start Code
        /*********************************************/
        DAQmxErrChk (DAQmxStartTask(taskHandle));
    
        printf("Acquiring samples continuously. Press Enter to interrupt\n");
        getchar();
    
    Error:
        if( DAQmxFailed(error) )
            DAQmxGetExtendedErrorInfo(errBuff,2048);
        if( taskHandle!=0 ) {
            /*********************************************/
            // DAQmx Stop Code
            /*********************************************/
            DAQmxStopTask(taskHandle);
            DAQmxClearTask(taskHandle);
        }
        if( DAQmxFailed(error) )
            printf("DAQmx Error: %s\n",errBuff);
        printf("End of program, press Enter key to quit\n");
        getchar();
        return 0;
    }
    
    int32 CVICALLBACK EveryNCallback(TaskHandle taskHandle, int32 everyNsamplesEventType, uInt32 nSamples, void *callbackData)
    {
        int32       error=0;
        char        errBuff[2048]={'\0'};
        static int  totalRead=0;
        int32       read=0;
        float64     data[1000];
     uInt32 i;
    
        /*********************************************/
        // DAQmx Read Code
        /*********************************************/
        DAQmxErrChk (DAQmxReadAnalogF64(taskHandle,-1,10.0,DAQmx_Val_GroupByScanNumber,data,1000,&read,NULL));
    
        if( read>0 ) {
     for (i = 0 ; i < 2*read ; i++ ) { printf("%.5f\n", data[i]); }
            printf("Acquired %d samples. Total %d\r",read,totalRead+=read);
            fflush(stdout);
        }
    
    Error:
        if( DAQmxFailed(error) ) {
            DAQmxGetExtendedErrorInfo(errBuff,2048);
            /*********************************************/
            // DAQmx Stop Code
            /*********************************************/
            DAQmxStopTask(taskHandle);
            DAQmxClearTask(taskHandle);
            printf("DAQmx Error: %s\n",errBuff);
        }
        return 0;
    }
    
    int32 CVICALLBACK DoneCallback(TaskHandle taskHandle, int32 status, void *callbackData)
    {
        int32   error=0;
        char    errBuff[2048]={'\0'};
    
        // Check to see if an error stopped the task.
        DAQmxErrChk (status);
    
    Error:
        if( DAQmxFailed(error) ) {
            DAQmxGetExtendedErrorInfo(errBuff,2048);
            DAQmxClearTask(taskHandle);
            printf("DAQmx Error: %s\n",errBuff);
        }
        return 0;
    }
    

    One more thing I've noticed is that the size of the data [] has not be increased to include additional channels. Wear in 2000 and also to increase arraySizeInSamps (parameter 5) and 2000 to the DAQmxReadAnalogF64 function call. Given that it was only the value 1000 samples, it will get only 500 samples per channel causing the overflow.

  • DAQmxRepeatTask syntax

    I want to build an oscilloscope limited to card PCI-4474 with four analog inputs and level trigger similar on one of these four analog inputs. With CVI "CQI-IntClk-AnlgStart" example I have most of the code.

    Then with one - button start stop, I want it repeated acquisition 1000 samples in the analog-trigger, trace the curves of four and goes for the next trigger. The option (that I found in this forum) for redeclenchables DAQmxSetTrigAttribute is (according to the CVI debug information) not supported for this Council.

    Next ideais (probably not unique) to divide the example in some functions with the use of DAQmxRegisterDoneEvent:

    create tasks with and others.

    DAQmxErrChk (DAQmxCreateTask("",&gTaskHandle));
    DAQmxErrChk (DAQmxCreateAIVoltageChan(gTaskHandle,chan,"",DAQmx_Val_Cfg_Default,min,max,DAQmx_Val_Volts,));
    DAQmxErrChk (DAQmxCfgSampClkTiming (gTaskHandle",", rate, DAQmx_Val_Rising, DAQmx_Val_FiniteSamps, gSampsPerChan));
    DAQmxErrChk (DAQmxCfgAnlgEdgeStartTrig (gTaskHandle, triggerSource, triggerSlope, triggerLevel));
    DAQmxErrChk (DAQmxSetTrigAttribute (gTaskHandle, DAQmx_AnlgEdge_StartTrig_Hyst, triggerHysteresis));
    DAQmxErrChk (DAQmxGetTaskAttribute (gTaskHandle, DAQmx_Task_NumChans, & gNumChannels));

    Start with and others.

    DAQmxErrChk (DAQmxRegisterDoneEvent(gTaskHandle,0,DoneCallback,));
    DAQmxErrChk (DAQmxStartTask (gTaskHandle));

    DoneCallback that is called when the task has completed the acquisition of its finite number of samples

    DAQmxErrChk (DAQmxReadAnalogF64 (gTaskHandle,...))

    DeleteGraphPlot (panelHandle, PANEL_GRAPH,-1, VAL_DELAYED_DRAW);
    If (Seek_set > 0)
    for (i = 0; i<>
    Foot (panelHandle, PANEL_GRAPH, &(gData...)
    RefreshGraph (panelHandle, PANEL_GRAPH);
    DAQmxErrChk (DAQmxStartTask (gTaskHandle));

    This does NOT work unless I have insert in this DoneCallback DAQmxStopTask before starting the task. This isn't what I expected, because the callback function is called because the task has completed. And this is not what I prefer, because the manual of the CVI reports this judgment and start a task will reduce performance. So I have two questions:

    Can Q: you someone explain or refer to a text What's the difference between the task accomplished and task-stopped in combination with the start task?

    Q: what is the best syntax of DAQmxRepeatTask (not yet found) when re-trigger is required for the synchronisation and when this special attribute is not supperted for card PCI-4474?

    Kind regards, Jos

    Hi Jos,

    Help OR-DAQmx said the task performed the following:

    When a task is completed?

    If the measure or the generation is finished, the task is made when you acquire or generate the final sample or when you call the function stop task/VI. If the measure or the generation is continuous (including synchronization on demand), the task is not made until you call the function stop task/VI. In addition, the task is performed if a fatal error is generated during the execution of the measure or generation, or you give up the measurement or generation. Search for the errors and warnings to check the task completed successfully.

    > This does NOT work unless I have insert in this DoneCallback DAQmxStopTask before starting the task. This isn't what I expected, because the callback function is called because the task has completed.

    The callback function is called because the task is finished and the final sample was acquired. Acquisition of the final sample don't automatically pass the task of the "running" State to the "committed" State, it must always stop the task before you can start it again. See that section for help NOR-titled DAQmx 'model task status' for an explanation of the different States.

    > And this is not what I prefer, because the manual of the CVI reports this judgment and start a task will reduce performance.

    Yes, but in this case, I think that stop is necessary. In other cases, it is not necessary. For example, you wouldn't stop and start the task between each sample.

    There is a way to reduce the overhead of the judgment and the task to start: commit the task by calling DAQmxTaskControl(..., DAQmx_Val_Task_Commit) in the front. In this way, you don't waste time uncommitting, unreserving, re - book and re-engaging the task each time.

    Anyway, the performance does not satisfy your needs? If not, what are your performance requirements?

    Brad

  • example of blocking software signal in C++

    Hello

    I am new to the NC and data acquisition. Just posted this question before http://forums.ni.com/t5/Signal-Conditioning/usb-6211-DAQ-frequency-question/td-p/3202422and discovered that the signal cannot be locked on a hardware level.

    Can anyone provide an example in C / C++ to lock a 400 hz signal. I used the example of ContAcq - IntClk.c to read the data of a resolver (Sindh and cosine) and a reference signal. However as the signal moves to the right (in this case) it becomes difficult to determine the position of the resolver.

    Thank you in advance.

    Kind regards

    Gerhard

    Looks that I itself can solve another of my posts solitaire here in this forum... sort of...

    Well, since I asked for an example of code, I'll give my solution here. This is probably by far not perfect, but it works. Suggestions for improvement are welcome.

    	DAQmxErrChk (DAQmxReadAnalogF64 (taskHandle, 1000, 10.0, DAQmx_Val_GroupByChannel, data, 3000, & read, NULL));
    If (read > 0) {}
    < 2999;="">
    {
    If (data [loopa] > highestRef)
    {
    highestRef = data [loopa];
    highestPos = loopa;
    }
    }
    References = data [highestPos];
    continue = data [highestPos-1999];
    cosine = data [highestPos-999];

    radians = atan2 (cosine, continue);
    angle = radians * (180 / M_PI);

    <>
    angle += 360;

    printf ("D: %f %f Ref: %f refH: %f Pos: %i angle: %f\r", continue, references, highestRef, highestPos, cosine and angle);
    fflush (stdout);
    }

  • RTSI meter / NI6143

    Hello

    I want to connect the physical channel cnt0 to the rtsi port0. I tried to edit one of the examples using the DAQmxConnectTerms function, but only the 89137 error appeared:

    DAQmx error: specified route can not be satisfied, because it requires resources
    that are currently in use by another way.
    Source device: Dev1
    Terminal of source: Ctr0Source
    Target unit: Dev1
    Destination terminal: RTSI0

    Resources in use by
    Source device: Dev1
    Terminal of source: Ctr1InternalOutput
    Target unit: Dev1
    Destination terminal: Ctr0Source

    State code:-89137

    I need to use the rtsi0 with another card pci compatible TTL signal. This is generally possible?

    Here are the essential source code:

    ErrChk is just the error-check-normal operation

    ErrChk (DAQmxCreateTask("",&taskHandle));
    ErrChk (DAQmxCreateCOPulseChanFreq(taskHandle,"Dev1/ctr0","",DAQmx_Val_Hz,DAQmx_Val_Low,0.0,1.00,0.50));
    ErrChk (DAQmxCfgImplicitTiming (taskHandle, DAQmx_Val_ContSamps, 1000));

    ErrChk (DAQmxRegisterDoneEvent(taskHandle,0,DoneCallback,));

    ErrChk (DAQmxConnectTerms ("/ Dev1/Ctr0Source ', ' / RTSI0/Dev1", DAQmx_Val_DoNotInvertPolarity));

    the error comes to the function StartTask
    DAQmxErrChk (DAQmxStartTask (taskHandle));

    How can I avoid this error?

    The RTSI uses its own protocol?

    What are the switching voltage level of the RTSI Bus?

    Thank you

    Christian

    Hello

    Here is the essential code I m use now:

    DAQmxErrChk (DAQmxConnectTerms("/Dev1/Ctr0InternalOutput","/Dev1/RTSI0",DAQmx_Val_DoNotInvertPolarity));

    When you´ve run this function, the connection between the stays CTR0 and RTSI0 and is saved overall, but where?

    is there a way to see the connected terms?

    DAQmxErrChk (DAQmxDisconnectTerms("/Dev1/Ctr0InternalOutput","/Dev1/RTSI0"));

    This function disconnect them and before you´ve called this function, it remains connected

    I measured the tensions of up - and down - level of the physical line:

    top: 3, 4V

    low: on 0V

    Result: It is compatible TTL

    Kind regards

    Christian

  • DAQmx DAQmxRegisterEveryNSamplesEvent when called.

    HI, I confued on what the event called DAQmxRegisterEveryNSamplesEvent:

    Here howa to create my task, with many channels:

    DAQmxCreateTask("",&device.taskHandle);

    DAQmxCreateAIVoltageChan(device.taskHandle,"Dev1/ai0","",DAQmx_Val_Cfg_Default,-10,10,DAQmx_Val_Volts,);

    DAQmxCreateAIVoltageChan(device.taskHandle,"Dev1/ai1","",DAQmx_Val_Cfg_Default,-10,10,DAQmx_Val_Volts,);

    DAQmxCreateAIVoltageChan(device.taskHandle,"Dev1/ai2","",DAQmx_Val_Cfg_Default,-10,10,DAQmx_Val_Volts,);

    samplesRate = 1000;

    DAQmxCfgSampClkTiming(device.taskHandle,"",samplesRate,DAQmx_Val_Rising,DAQmx_Val_ContSamps,100);

    DAQmxRegisterEveryNSamplesEvent (device.taskHandle, DAQmx_Val_Acquired_Into_Buffer, 10, 0, EveryNCallback, NULL);

    DAQmxRegisterDoneEvent(device.taskHandle,0,DoneCallback,);

    data = malloc (100 * numChannels * sizeof (float64));
    DAQmxStartTask (device.taskHandle);

    }

    Int32 CVICALLBACK EveryNCallback(TaskHandle taskHandle, int32 everyNsamplesEventType, uInt32 nSamples, void *callbackData)

    {

    Public int = 0;
    DAQmxReadAnalogF64 (device.taskHandle, 100, 10.0, DAQmx_Val_GroupByChannel, data, 100 * numChannels & Seek_set, NULL);

    }

    When pulled EveryNCallback here, I have difficult when the buffer data has 10 samples, but when I call, he has 100 samples read for each channel.

    If the sampling frequency is 1000 samples per seocnd by channel, it would be 0.3 seconds to 100 samples per channel (3). What if

    EveryNCallback is called every 10 samples, then it must be called each 0.030 seconds? or am I wrong.

    Thank you much in advance.

    In theory, it should work, but you will have no warranty on the scanning speed. You can query the actual crawl rate by calling DAQmxGetTimingAttribute (taskHandle, DAQmx_SampClk_Rate, & rate, 0); But if you want to change it, you must use DAQmxCfgSampClkTiming.

    If you wish to purchase on demand, you can set your task as usual (including timetable with a finite sample amount) and finish the preparation of task with DAQmxTaskControl (taskHandle, DAQmx_Val_Task_Commit); After this point you can have your loop or timed processes which, at each race, called DAQmxStartTask and bed measures

  • CVI 8.0 OR-DAQmx 8.9.5 compatibility?

    New laptop, installed CVI 8.0.1 then NOR-DAQmx 8.9.5 driver provided with acquisition of data USB-6211. Unit works very well with the help of MAX.

    When you select tools/create/edit the CVI DAQmx tasks... a pop message says: "this feature requires NEITHER-DAQmx. Please install OR-DAQ from device drivers CD OR or check your installation. »

    However, NEITHER-DAQmx appears in libraries.

    The sample program compiled Acq-IntClk, but some error message is displayed when the application is run:

    "Procedure entry point not found SetEnableResourceTracking in cvirte.dll.

    "Unable to load nicvidu.dll, check your installation.

    If I continue through errors, the application seems to work.

    Any installation or compatibility obvious problems here?

    CVIRTE to version 9.0.1 update fixed everything.

  • How to read voltage on several channels using the 6255\SCB-68

    Hi all

    I have been able to get the following code to compile, run and display the data as expected. When you read the tension (CSR) on Dev0/ai65

    ... Instruments\NI-national DAQ\Examples\DAQmx ANSI C\Analog In\Measure Voltage\Cont Acq - Int Clk\ContAcq - IntClk.c

    * I think I'm using CSR, but I have no idea since I don't see an argument to specify

    I'm reading two different data points:

    1 discovered (CSR) tension on Dev0/ai65

    2 show the (differential) voltage difference between Dev0/ai17 and Dev0/ai25

    Can someone point me to an example (or a web link) where two different data points are read.

    * edit - I am filling this task using C++

    Thank you

    Chad

    This code is a start, and it works


    using namespace std;





    using namespace std;

    #define DAQmxErrChk (functionCall) if (DAQmxFailed (error = (functionCall))) goto error; on the other

    int main (void)
    {

    <>
    < "\t="" starting="" the="" ni="" daqmx="" data="">
    <>

    int loop;

    < 3;="">
    {
    Int32 = 0 error;
    TaskHandle taskHandle1 = 0;
    TaskHandle taskHandle2 = 0;
    Int32 read1.
    Int32 Read 2;
    float64 data1 [1000];
    float64 data2 [1000];
    tank errBuff [2048] = {'\0'};

    Channel settings and the schedule of the analog voltage DAQmx
    DAQmxErrChk (DAQmxCreateTask ("task1", & taskHandle1));
    DAQmxErrChk (DAQmxCreateAIVoltageChan (taskHandle1, "ai25/Dev1", "", DAQmx_Val_Cfg_Default,-10,0, 10.0, DAQmx_Val_Volts, NULL));
    DAQmxErrChk (DAQmxCfgSampClkTiming (taskHandle1, "", 10000.0, DAQmx_Val_Rising, DAQmx_Val_FiniteSamps, 1000));

    DAQmxErrChk (DAQmxCreateTask ("task2", & taskHandle2));
    DAQmxErrChk (DAQmxCreateAIVoltageChan (taskHandle2, "Dev1/ai17", "", DAQmx_Val_Cfg_Default,-10,0, 10.0, DAQmx_Val_Volts, NULL));
    DAQmxErrChk (DAQmxCfgSampClkTiming (taskHandle2, "", 10000.0, DAQmx_Val_Rising, DAQmx_Val_FiniteSamps, 1000));

    Starting code DAQmx
    DAQmxErrChk (DAQmxStartTask (taskHandle1));

    Reading DAQmx code
    DAQmxErrChk (DAQmxReadAnalogF64 (taskHandle1, 1000, 10.0, DAQmx_Val_GroupByChannel, data1, 1000, & read1, NULL));
    < read1;="">
    < data1[i]="">< "="">
    <>

    DAQmxStopTask (taskHandle1);
    DAQmxClearTask (taskHandle1);

    Starting code DAQmx
    DAQmxErrChk (DAQmxStartTask (taskHandle2));

    Reading DAQmx code
    DAQmxErrChk (DAQmxReadAnalogF64 (taskHandle2, 1000, 10.0, DAQmx_Val_GroupByChannel, data2, 1000, & read2, NULL));
    < read2;="">
    < data2[i]="">< "="">
    <>
    DAQmxStopTask (taskHandle2);
    DAQmxClearTask (taskHandle2);

    Stop and clear spots
    Error:
    If (DAQmxFailed (error))
    DAQmxGetExtendedErrorInfo (errBuff, 2048);
    If (taskHandle1! = 0) {}
    DAQmxStopTask (taskHandle1);
    DAQmxStopTask (taskHandle2);
    DAQmxClearTask (taskHandle1);
    DAQmxClearTask (taskHandle2);
    }

    If (DAQmxFailed (error))
    printf ("DAQmx error: %s\n", errBuff);

    }
    end of loop

    <>
    < "\t="" stopping="" the="" ni="" daqmx="" data="">
    <>

    return 0;

    }

  • Writing to SPI peripheral using the NI PCIe-6363

    I'm writing a labview program to write to a simple SPI device using the DAQmx 6363. I found a library and examples of code and started using the "SPI - internal Clock.vi DAQmx".

    http://www.NI.com/example/31200/en/

    I believe that this is the right place to start, but I keep coming across mistakes that I can't locate.

    200452 error occurred to the property Node DAQmx export Signal (arg 1) in Init IntClk Device.vi-> DAQmx SPI - internal Clock.vi

    Possible reasons:

    The specified property is not supported by the device or is not applicable to the task.

    Property: DataActiveEvent.OutputTerm

    Task name: _unnamedTask<18>

    I found the vi the cause of the problem, but I'm not sure what the problem is yet. Any help is appreciated.

    I believe that this knowledge base article contains the answer to your question. Follow the steps in knowledge base article to determine if the property node that you are using is supported by your card.

Maybe you are looking for