Visual C++ (MFC)

It is an example program in Visual C++. The conversion data and error contents are displayed in output window.
Example program by using AioSingleAi

Example program by using AioMultiAi


Example program by using AioSingleAi

//---------------------------
// Variable declaration

//---------------------------

long Ret;              //Return values of functions
short Id;              //ID
char ErrorString[256]; //Array for storing error string
long AiData;           //Conversion data

//---------------------------
// Initialize device
// Devicename : Aio000
//---------------------------

Ret = AioInit( "Aio000" , &Id );
if( Ret != 0 ){
    AioGetErrorString( Ret , ErrorString );
    TRACE( "AioInit : %s\n" , ErrorString );
    exit( 0 );
}

//---------------------------
// Set analog input method
// Input method : Single-end input
//---------------------------

Ret = AioSetAiInputMethod( Id , 0 );
if( Ret != 0 ){
    AioGetErrorString( Ret , ErrorString );
    TRACE( "AioSetAiInputMethod : %s\n" , ErrorString );
    Ret = AioExit( Id );
    exit( 0 );
}

//---------------------------
// Set analog input range
// Range : -10 to 10V
//---------------------------

Ret = AioSetAiRangeAll( Id , PM10 );
if( Ret != 0 ){
    AioGetErrorString( Ret , ErrorString );
    TRACE( "AioSetAiRangeAll : %s\n" , ErrorString );
    Ret = AioExit( Id );
    exit( 0 );
}

//---------------------------
// Analog input to the specified channel only once
// Input channel : 0
//---------------------------

Ret = AioSingleAi( Id , 0 , &AiData );
if( Ret != 0 ){
    AioGetErrorString( Ret , ErrorString );
    TRACE( "AioSingleAi : %s\n" , ErrorString );
    Ret = AioExit( Id );
    exit( 0 );
}
TRACE( "Channel0 : %d\n" , AiData );

//---------------------------
// Device exit
//---------------------------

Ret = AioExit( Id );
if( Ret != 0 ){
    AioGetErrorString( Ret , ErrorString );
    TRACE( "AioExit : %s\n" , ErrorString );
    exit( 0 );
}


Example program by using AioMultiAi

//---------------------------
// Variable declaration

//---------------------------

long Ret;              //Return values of functions
short Id;              //ID
char ErrorString[256]; //Array for storing error string
long AiData[8];        //Conversion data
short i;

//---------------------------
// Initialize device
// Devicename : Aio000
//---------------------------

Ret = AioInit( "Aio000" , &Id );
if( Ret != 0 ){
    AioGetErrorString( Ret , ErrorString );
    TRACE( "AioInit : %s\n" , ErrorString );
    exit( 0 );
}

//---------------------------
// Set analog input method
// Input method : Single-end input
//---------------------------

Ret = AioSetAiInputMethod( Id , 0 );
if( Ret != 0 ){
    AioGetErrorString( Ret , ErrorString );
    TRACE( "AioSetAiInputMethod : %s\n" , ErrorString );
    Ret = AioExit( Id );
    exit( 0 );
}

//---------------------------
// Set analog input range
// Range : -10 to 10V
//---------------------------

Ret = AioSetAiRangeAll( Id , PM10 );
if( Ret != 0 ){
    AioGetErrorString( Ret , ErrorString );
    TRACE( "AioSetAiRangeAll : %s\n" , ErrorString );
    Ret = AioExit( Id );
    exit( 0 );
}

//---------------------------
// Analog input to multiple channels only once
// Number of input channels : 8
//---------------------------

Ret = AioMultiAi( Id , 8 , &AiData[0] );
if( Ret != 0 ){
    AioGetErrorString( Ret , ErrorString );
    TRACE( "AioMultiAi : %s\n" , ErrorString );
    Ret = AioExit( Id );
    exit( 0 );
}

for( i = 0 ; i < 8 ; i++ ){
    TRACE( "Channel%d : %d\n" , i, AiData[i] );
}

//---------------------------
// Device exit
//---------------------------

Ret = AioExit( Id );
if( Ret != 0 ){
    AioGetErrorString( Ret , ErrorString );
    TRACE( "AioExit : %s\n" , ErrorString );
    exit( 0 );
}