阿尔泰采集卡使用DO源码使用例子

AD_源码分析(仅DIO)

  1. GenerateValues
    1. QT_ContWriteDigChanDigPause

#define ArtDAQErrChk(functionCall) if( ArtDAQFailed(error=(functionCall)) ) goto Error;

int main(void)

{

    int32       error=0;

    TaskHandle  taskHandle=0;

    uInt8       data[1000];

    uInt32      i=0;

    char        errBuff[2048]={'\0'};

    char        strChannelName[100]={'\0'};

    char        strTriggerSource[100]={'\0'};

    /*********************************************/

    // ArtDAQ Configure Code

    /*********************************************/

    printf("Please enter channel number, such as Dev1/port0/line0,Dev1 is the name identified in the DMC:");

    scanf("%s", strChannelName);

    printf("Please enter pause trigger source name, such as /Dev1/PFI0,Dev1 is the name identified in the DMC:");

scanf("%s", strTriggerSource);

// 1. Create a task.

ArtDAQErrChk (ArtDAQ_CreateTask("",&taskHandle));

// 2. Create a Digital Output Channel.

ArtDAQErrChk (ArtDAQ_CreateDOChan(taskHandle,strChannelName,"",ArtDAQ_Val_ChanPerLine));

//3. sets the sample clock rate. Additionally, set the sample mode to Continuous.

ArtDAQErrChk (ArtDAQ_CfgSampClkTiming(taskHandle,"",1000.0,ArtDAQ_Val_Rising,ArtDAQ_Val_ContSamps,1000));

//4. Configure the pause trigger.

    ArtDAQErrChk (ArtDAQ_CfgDigLvlPauseTrig(taskHandle, strTriggerSource, ArtDAQ_Val_High));

    for(;i<1000;i++)

        data[i] = (uInt8)(i%2);

    /*********************************************/

    // ArtDAQ Write Code

/*********************************************/

//5. Write the waveform

    ArtDAQErrChk (ArtDAQ_WriteDigitalLines(taskHandle,1000,0,10.0,ArtDAQ_Val_GroupByChannel,data,NULL,NULL));

    /*********************************************/

    // ArtDAQ Start Code

/*********************************************/

//6. Start the task

    ArtDAQErrChk (ArtDAQ_StartTask(taskHandle));

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

    getchar();

Error:

    if( ArtDAQFailed(error) )

        ArtDAQ_GetExtendedErrorInfo(errBuff,2048);

    if( taskHandle!=0 ) {

        /*********************************************/

        // ArtDAQ Stop Code

        /*********************************************/

        //7. Stop and clear the task

        ArtDAQ_StopTask(taskHandle);

        ArtDAQ_ClearTask(taskHandle);

}

//8. Display an error if any

    if( ArtDAQFailed(error) )

        printf("ArtDAQ_ Error: %s\n",errBuff);

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

    getchar();

    getchar();

    return 0;

}

    1. QT _ContWriteDigPortExtClk

#define ArtDAQErrChk(functionCall) if( ArtDAQFailed(error=(functionCall)) ) goto Error;

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

int main(void)

{

    int32       error=0;

    TaskHandle  taskHandle=0;

    uInt32      data[8]={1,2,4,8,16,32,64,128};

    char        errBuff[2048]={'\0'};

    char        strChannelName[100]={'\0'};

    char        strExternalClock[100]={'\0'};

    /*********************************************/

    // ArtDAQ Configure Code

    /*********************************************/

    printf("Please enter channel number, such as Dev1/port0,Dev1 is the name identified in the DMC:");

    scanf("%s", strChannelName);

    printf("Please enter external clock name, such as /Dev1/PFI0,Dev1 is the name identified in the DMC:");

    scanf("%s", strExternalClock);

// 1. Create a task.

    ArtDAQErrChk (ArtDAQ_CreateTask("",&taskHandle));

//2. Create an Digital Output Channel.

    ArtDAQErrChk (ArtDAQ_CreateDOChan(taskHandle,strChannelName,"",ArtDAQ_Val_ChanForAllLines));

    //3. sets the sample clock rate. Additionally, set the sample mode to continuous

    ArtDAQErrChk (ArtDAQ_CfgSampClkTiming(taskHandle,strExternalClock,1000.0,ArtDAQ_Val_Rising,ArtDAQ_Val_ContSamps,1000));

    ArtDAQErrChk (ArtDAQ_RegisterDoneEvent(taskHandle,0,DoneCallback,NULL));

    /*********************************************/

    // ArtDAQ Write Code

    /*********************************************/

//4. Write the data to the output buffer.

    ArtDAQErrChk (ArtDAQ_WriteDigitalU32(taskHandle,8,0,10.0,ArtDAQ_Val_GroupByChannel,data,NULL,NULL));

    /*********************************************/

    // ArtDAQ Start Code

    /*********************************************/

//5. Call the Start function to start the task.

    ArtDAQErrChk (ArtDAQ_StartTask(taskHandle));

    printf("Generating digital output continuously. Press Enter to interrupt\n");

//6. Wait until the user presses the Stop button.

    getchar();

Error:

    if( ArtDAQFailed(error) )

        ArtDAQ_GetExtendedErrorInfo(errBuff,2048);

    if( taskHandle!=0 ) {

        /*********************************************/

        // ArtDAQ Stop Code

        /*********************************************/

//7. Stop and clear the Task.

        ArtDAQ_StopTask(taskHandle);

        ArtDAQ_ClearTask(taskHandle);

    }

//8. Display an error if any.

    if( ArtDAQFailed(error) )

        printf("ArtDAQ_ Error: %s\n",errBuff);

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

    getchar();

    getchar();

    return 0;

}

int32 ART_CALLBACK DoneCallback(TaskHandle taskHandle, int32 status, void *callbackData)

{

    int32   error=0;

    char    errBuff[2048]={'\0'};

    // Check to see if an error stopped the task.

    ArtDAQErrChk (status);

    printf("Task Done\n");

Error:

    if( ArtDAQFailed(error) ) {

        ArtDAQ_GetExtendedErrorInfo(errBuff,2048);

        ArtDAQ_ClearTask(taskHandle);

        printf("ArtDAQ Error: %s\n",errBuff);

    }

    return 0;

}

    1. QT_WriteDigChan

#define ArtDAQErrChk(functionCall) if( ArtDAQFailed(error=(functionCall)) ) goto Error;

int main(void)

{

    int32       error=0;

    TaskHandle  taskHandle=0;

    uInt8       data[8]={1,0,0,1,1,1,1,1};

    char        errBuff[2048]={'\0'};

    char        strChannelName[100]={'\0'};

    /*********************************************/

    // ArtDAQ Configure Code

    /*********************************************/

    printf("Please enter channal number,such as Dev1/port0/line0:7,Dev1 is the name identified in the DMC:");

    scanf("%s", strChannelName);

//1. Create a task.

    ArtDAQErrChk (ArtDAQ_CreateTask("",&taskHandle));

//2. Create a Digital Output channel. Use one channel for all line.

    ArtDAQErrChk (ArtDAQ_CreateDOChan(taskHandle,strChannelName,"",ArtDAQ_Val_ChanForAllLines));

//3. start the task.

    /*********************************************/

    // ArtDAQ Start Code

    /*********************************************/

    ArtDAQErrChk (ArtDAQ_StartTask(taskHandle));

//4.Write the digital Boolean array data.

    /*********************************************/

    // ArtDAQ Write Code

    /*********************************************/

    ArtDAQErrChk (ArtDAQ_WriteDigitalLines(taskHandle,1,1,10.0,ArtDAQ_Val_GroupByChannel,data,NULL,NULL));

Error:

    if( ArtDAQFailed(error) )

        ArtDAQ_GetExtendedErrorInfo(errBuff,2048);

    if( taskHandle!=0 ) {

        /*********************************************/

        // ArtDAQ Stop Code

        /*********************************************/

             //5. Stop and clear the task.

        ArtDAQ_StopTask(taskHandle);

        ArtDAQ_ClearTask(taskHandle);

    }

//6. Display an error if any.

    if( ArtDAQFailed(error) )

        printf("ArtDAQ_ Error: %s\n",errBuff);

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

    getchar();

    getchar();

    return 0;

}

    1. QT_ WriteDigChanExtClk

#define ArtDAQErrChk(functionCall) if( ArtDAQFailed(error=(functionCall)) ) goto Error;

int main(void)

{

    int32       error=0;

    TaskHandle  taskHandle=0;

    uInt8       data[1000];

    uInt32      i=0;

    char        errBuff[2048]={'\0'};

    char        strChannelName[100]={'\0'};

    char        strClockSourceName[100]={'\0'};

    /*********************************************/

    // ArtDAQ Configure Code

    /*********************************************/

    printf("Please enter channal number,such as Dev1/port0/line0,Dev1 is the name identified in the DMC:");

    scanf("%s", strChannelName);

    printf("Please enter external clock source name,such as /Dev1/PFI0,Dev1 is the name identified in the DMC:");

scanf("%s", strClockSourceName);

//1. Create a task.

ArtDAQErrChk (ArtDAQ_CreateTask("",&taskHandle));

//2. Create a Digital Output Channel.

ArtDAQErrChk (ArtDAQ_CreateDOChan(taskHandle,strChannelName,"",ArtDAQ_Val_ChanPerLine));

//3. sets the sample clock rate. Additionally, set the sample mode to Finite.

ArtDAQErrChk (ArtDAQ_CfgSampClkTiming(taskHandle,strClockSourceName,1000.0,ArtDAQ_Val_Rising,ArtDAQ_Val_FiniteSamps,1000));

//4. Write the waveform to the output buffer.

    for(;i<1000;i++)

        data[i] = (uInt8)(i%2);

    /*********************************************/

    // DAQmx Write Code

    /*********************************************/

ArtDAQErrChk (ArtDAQ_WriteDigitalLines(taskHandle,1000,0,10.0,ArtDAQ_Val_GroupByChannel,data,NULL,NULL));

//5. Call the Start function to start the task.

    /*********************************************/

    // DAQmx Start Code

    /*********************************************/

    ArtDAQErrChk (ArtDAQ_StartTask(taskHandle));

    /*********************************************/

    // DAQmx Wait Code

    /*********************************************/

    ArtDAQErrChk (ArtDAQ_WaitUntilTaskDone(taskHandle,10.0));

Error:

    if( ArtDAQFailed(error) )

        ArtDAQ_GetExtendedErrorInfo(errBuff,2048);

//6. Stop and clear the Task.

    if( taskHandle!=0 ) {

        /*********************************************/

        // ArtDAQ Stop Code

        /*********************************************/

        ArtDAQ_StopTask(taskHandle);

        ArtDAQ_ClearTask(taskHandle);

}

//7. Display an error if any.

    if( ArtDAQFailed(error) )

        printf("ArtDAQ_ Error: %s\n",errBuff);

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

    getchar();

    getchar();

    return 0;

}

    1. QT_WriteDigPort

#define ArtDAQErrChk(functionCall) if( ArtDAQFailed(error=(functionCall)) ) goto Error;

int main(void)

{

    int         error=0;

    TaskHandle    taskHandle=0;

    uInt32      data=0xffffffff;

    char        errBuff[2048]={'\0'};

    int32              written;

    char        strChannelName[100]={'\0'};

    /*********************************************/

    // ArtDAQ Configure Code

    /*********************************************/

    printf("Please enter channal number,such as Dev1/port0,Dev1 is the name identified in the DMC:");

scanf("%s", strChannelName);

//1. Create a task.

ArtDAQErrChk (ArtDAQ_CreateTask("",&taskHandle));

//2. Create a Digital Output Channel.

    ArtDAQErrChk (ArtDAQ_CreateDOChan(taskHandle,strChannelName,"",ArtDAQ_Val_ChanForAllLines));

//3. start the task

    /*********************************************/

    // ArtDAQ Start Code

    /*********************************************/

    ArtDAQErrChk (ArtDAQ_StartTask(taskHandle));

//4. Write digital port data.

    /*********************************************/

    // ArtDAQ Write Code

    /*********************************************/

    ArtDAQErrChk (ArtDAQ_WriteDigitalU32(taskHandle,1,1,10.0,ArtDAQ_Val_GroupByChannel,&data,&written,NULL));

Error:

    if( ArtDAQFailed(error) )

        ArtDAQ_GetExtendedErrorInfo(errBuff,2048);

//5. Stop and clear the Task.

    if( taskHandle!=0 ) {

        /*********************************************/

        // ArtDAQ Stop Code

        /*********************************************/

        ArtDAQ_StopTask(taskHandle);

        ArtDAQ_ClearTask(taskHandle);

}

//6. Display an error if any.

    if( ArtDAQFailed(error) )

        printf("ArtDAQ_ Error: %s\n",errBuff);

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

    getchar();

    getchar();

    return 0;

}

  1. ReadValue
    1. QT_ContReadDigChanExtClk

#include <QCoreApplication>

#include "conio.h"

#include "Art_DAQ.h"

#define ArtDAQErrChk(functionCall) if( ArtDAQFailed(error=(functionCall)) ) goto Error;

int main(void)

{

    int32              error=0;

    TaskHandle    taskHandle=0;

    uInt32            data[1000];

    int32              sampsRead,totalRead=0;

    char        errBuff[2048]={'\0'};

    char        strChannelName[100]={'\0'};

    char        strClockSourceName[100]={'\0'};

    /*********************************************/

    // ArtDAQ Configure Code

    /*********************************************/

    printf("Please enter channal number,such as Dev1/port0/line0,Dev1 is the name identified in the DMC:");

    scanf("%s", strChannelName);

    printf("Please enter external clock source name,such as /Dev1/PFI0,Dev1 is the name identified in the DMC:");

scanf("%s", strClockSourceName);

//1. Create a task.

ArtDAQErrChk (ArtDAQ_CreateTask("",&taskHandle));

//2. Create a Digital Input channel.

ArtDAQErrChk (ArtDAQ_CreateDIChan(taskHandle,strChannelName,"",ArtDAQ_Val_ChanPerLine));

//3. Define External Clock Source.Additionally, set the sample mode to be continuous.

ArtDAQErrChk (ArtDAQ_CfgSampClkTiming(taskHandle,strClockSourceName,10000.0,ArtDAQ_Val_Rising,ArtDAQ_Val_ContSamps,1000));

//4. Call the Start function to start the acquisition.

    /*********************************************/

    // ArtDAQ Start Code

    /*********************************************/

ArtDAQErrChk (ArtDAQ_StartTask(taskHandle));

//5. Read data continuously until the user hits the stop button or an error occurs.

    printf("Acquiring samples continuously. Press Ctrl+C to interrupt\n");

    while( 1 ) {

        /*********************************************/

        // DAQmx Read Code

        /*********************************************/

        ArtDAQErrChk (ArtDAQ_ReadDigitalU32(taskHandle,1000,10.0,ArtDAQ_Val_GroupByChannel,data,1000,&sampsRead,NULL));

        if( sampsRead>0 ) {

            totalRead += sampsRead;

            printf("Acquired %d samples. Total %d\r",(int)sampsRead,(int)totalRead);

            fflush(stdout);

        }

    }

    printf("\nAcquired %d total samples.\n",(int)totalRead);

Error:

    if( ArtDAQFailed(error) )

        ArtDAQ_GetExtendedErrorInfo(errBuff,2048);

//6. Stop and clear the Task.

    if( taskHandle!=0 ) {

        /*********************************************/

        // ArtDAQ Stop Code

        /*********************************************/

        ArtDAQ_StopTask(taskHandle);

        ArtDAQ_ClearTask(taskHandle);

}

//7. Display an error if any.

    if( ArtDAQFailed(error) )

        printf("ArtDAQ_ Error: %s\n",errBuff);

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

    getchar();

    getchar();

    return 0;

}

    1. QT_ReadDigChan

#include <QCoreApplication>

#include "conio.h"

#include "Art_DAQ.h"

#define ArtDAQErrChk(functionCall) if( ArtDAQFailed(error=(functionCall)) ) goto Error;

int main(void)

{

    int32              error=0;

    TaskHandle    taskHandle=0;

    uInt8              data[100];

    char        errBuff[2048]={'\0'};

    int32              i;

    int32              read,bytesPerSamp;

    char        strChannelName[100]={'\0'};

    /*********************************************/

    // ArtDAQ Configure Code

    /*********************************************/

    printf("Please enter channal number,such as Dev1/port0/line0:7,Dev1 is the name identified in the DMC:");

scanf("%s", strChannelName);

//1. Create a task.

ArtDAQErrChk (ArtDAQ_CreateTask("",&taskHandle));

//2. Create a Digital Input channel. Use one channel for all lines

    ArtDAQErrChk (ArtDAQ_CreateDIChan(taskHandle,strChannelName,"",ArtDAQ_Val_ChanForAllLines));

    /*********************************************/

    // ArtDAQ Start Code

/*********************************************/

//3. Call the Start function to start the task.

    ArtDAQErrChk (ArtDAQ_StartTask(taskHandle));

    /*********************************************/

    // ArtDAQ Read Code

/*********************************************/

//4. Read the digital data.

    ArtDAQErrChk (ArtDAQ_ReadDigitalLines(taskHandle,1,10.0,ArtDAQ_Val_GroupByChannel,data,100,&read,&bytesPerSamp,NULL));

    // assuming 8 channels acquired

    for(i=0;i<8;++i)

        printf("Data acquired, channel %d: 0x%X\n",(int)i,data[i]);

Error:

    if( ArtDAQFailed(error) )

        ArtDAQ_GetExtendedErrorInfo(errBuff,2048);

//5. Stop and clear the Task.

    if( taskHandle!=0 ) {

        /*********************************************/

        // ArtDAQ Stop Code

        /*********************************************/

        ArtDAQ_StopTask(taskHandle);

        ArtDAQ_ClearTask(taskHandle);

}

//6. Display an error if any.

    if( ArtDAQFailed(error) )

        printf("ArtDAQ_ Error: %s\n",errBuff);

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

    getchar();

    getchar();

    return 0;

}

    1. QT_ReadDigChanIntClkDigStart

#include <QCoreApplication>

#include "conio.h"

#include "Art_DAQ.h"

#define ArtDAQErrChk(functionCall) if( ArtDAQFailed(error=(functionCall)) ) goto Error;

int main(void)

{

    int32       error=0;

    TaskHandle  taskHandle=0;

    int32       numRead;

    uInt8       data[8000];

    char        errBuff[2048]={'\0'};

    char        strChannelName[100]={'\0'};

    char        strStartTriggerSource[100]={'\0'};

    /*********************************************/

    // ArtDAQ Configure Code

    /*********************************************/

    printf("Please enter channal number,such as Dev1/port0/line0:7,Dev1 is the name identified in the DMC:");

    scanf("%s", strChannelName);

    printf("Please enter external clock source name,such as /Dev1/PFI0,Dev1 is the name identified in the DMC:");

scanf("%s", strStartTriggerSource);

//1. Create a task.

ArtDAQErrChk (ArtDAQ_CreateTask("",&taskHandle));

//2. Create a digital input channel.

ArtDAQErrChk (ArtDAQ_CreateDIChan(taskHandle,strChannelName,"",ArtDAQ_Val_ChanPerLine));

//3. Define Internal Clock Source. Additionally, define the sample mode to be Finite.

ArtDAQErrChk (ArtDAQ_CfgSampClkTiming(taskHandle,"",10000.0,ArtDAQ_Val_Rising,ArtDAQ_Val_FiniteSamps,1000));

//4. Define the parameters for a Digital Edge Start Trigger.

    ArtDAQErrChk (ArtDAQ_CfgDigEdgeStartTrig(taskHandle,strStartTriggerSource,ArtDAQ_Val_Rising));

//5. Call the Start function to begin the acquisition.

    /*********************************************/

    // ArtDAQ Start Code

    /*********************************************/

    ArtDAQErrChk (ArtDAQ_StartTask(taskHandle));

//6. Use the Read function to retrieve the waveform.

    /*********************************************/

    // ArtDAQ Read Code

    /*********************************************/

    ArtDAQErrChk (ArtDAQ_ReadDigitalLines(taskHandle,1000,10.0,ArtDAQ_Val_GroupByChannel,data,8000,&numRead,NULL,NULL));

    printf("Acquired %d samples\n",(int)numRead);

Error:

    if( ArtDAQFailed(error) )

        ArtDAQ_GetExtendedErrorInfo(errBuff,2048);

//7. Stop and clear the task.

    if( taskHandle!=0 ) {

        /*********************************************/

        // ArtDAQ Stop Code

        /*********************************************/

        ArtDAQ_StopTask(taskHandle);

        ArtDAQ_ClearTask(taskHandle);

}

//8. Display an error if any.

    if( ArtDAQFailed(error) )

        printf("ArtDAQ_ Error: %s\n",errBuff);

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

    getchar();

    getchar();

    return 0;

}

    1. QT_ReadDigPort

#include <QCoreApplication>

#include "conio.h"

#include "Art_DAQ.h"

#define ArtDAQErrChk(functionCall) if( ArtDAQFailed(error=(functionCall)) ) goto Error;

int main(void)

{

    int32              error=0;

    TaskHandle    taskHandle=0;

    uInt32            data;

    char        errBuff[2048]={'\0'};

    int32              read;

    char        strChannelName[100]={'\0'};

    /*********************************************/

    // ArtDAQ Configure Code

    /*********************************************/

    printf("Please enter channal number,such as Dev1/port0,Dev1 is the name identified in the DMC:");

scanf("%s", strChannelName);

//1. Create a task.

ArtDAQErrChk (ArtDAQ_CreateTask("",&taskHandle));

//2. Create a Digital Input channel.

    ArtDAQErrChk (ArtDAQ_CreateDIChan(taskHandle,strChannelName,"",ArtDAQ_Val_ChanForAllLines));

//3. Call the Start function to start the task.

    /*********************************************/

    // ArtDAQ Start Code

    /*********************************************/

    ArtDAQErrChk (ArtDAQ_StartTask(taskHandle));

    /*********************************************/

// ArtDAQ Read Code

//4. Read the digital data.

    /*********************************************/

    ArtDAQErrChk (ArtDAQ_ReadDigitalU32(taskHandle,1,10.0,ArtDAQ_Val_GroupByChannel,&data,1,&read,NULL));

    printf("Data acquired: 0x%X\n",(unsigned)data);

Error:

    if( ArtDAQFailed(error) )

        ArtDAQ_GetExtendedErrorInfo(errBuff,2048);

//5. Stop and clear the Task.

    if( taskHandle!=0 ) {

        /*********************************************/

        // ArtDAQ Stop Code

        /*********************************************/

        ArtDAQ_StopTask(taskHandle);

        ArtDAQ_ClearTask(taskHandle);

}

//6. Display an error if any.

    if( ArtDAQFailed(error) )

        printf("ArtDAQ_ Error: %s\n",errBuff);

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

    getchar();

    getchar();

    return 0;

}

    1. QT_ReadDigPortExtClk

#include <QCoreApplication>

#include "conio.h"

#include "Art_DAQ.h"

#define ArtDAQErrChk(functionCall) if( ArtDAQFailed(error=(functionCall)) ) goto Error;

int main(void)

{

    int32              error=0;

    TaskHandle    taskHandle=0;

    uInt32            data[1000];

    int32              sampsRead;

    char        errBuff[2048]={'\0'};

    char        strChannelName[100]={'\0'};

    char        strClockSourceName[100]={'\0'};

    /*********************************************/

    // ArtDAQ Configure Code

    /*********************************************/

    printf("Please enter channal number,such as Dev1/port0,Dev1 is the name identified in the DMC:");

    scanf("%s", strChannelName);

    printf("Please enter external clock source name,such as /Dev1/PFI0,Dev1 is the name identified in the DMC:");

scanf("%s", strClockSourceName);

//1. Create a task.

ArtDAQErrChk (ArtDAQ_CreateTask("",&taskHandle));

//2. Create a Digital Input channel.

ArtDAQErrChk (ArtDAQ_CreateDIChan(taskHandle,strChannelName,"",ArtDAQ_Val_ChanForAllLines));

//3. Define External Clock Source. Additionally, set the sample mode to be finite.

    ArtDAQErrChk (ArtDAQ_CfgSampClkTiming(taskHandle,strClockSourceName,10000.0,ArtDAQ_Val_Rising,ArtDAQ_Val_FiniteSamps,1000));

//4. Call the Start function to begin the acquisition.

    /*********************************************/

    // DAQmx Start Code

    /*********************************************/

    ArtDAQErrChk (ArtDAQ_StartTask(taskHandle));

//5. Read the digital pattern.

    /*********************************************/

    // DAQmx Read Code

    /*********************************************/

    ArtDAQErrChk (ArtDAQ_ReadDigitalU32(taskHandle,-1,10.0,ArtDAQ_Val_GroupByChannel,data,1000,&sampsRead,NULL));

    printf("Acquired %d samples\n",(int)sampsRead);

Error:

    if( ArtDAQFailed(error) )

        ArtDAQ_GetExtendedErrorInfo(errBuff,2048);

//6. Stop and clear the Task.

    if( taskHandle!=0 ) {

        /*********************************************/

        // ArtDAQ Stop Code

        /*********************************************/

        ArtDAQ_StopTask(taskHandle);

        ArtDAQ_ClearTask(taskHandle);

}

//7. Display an error if any.

    if( ArtDAQFailed(error) )

        printf("ArtDAQ_ Error: %s\n",errBuff);

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

    getchar();

    getchar();

    return 0;

}


版权声明:本文为zkmrobot原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。