int main(void)
{
    I16 card, err;

    setbuf( stdout, NULL );
    printf("This program inputs %ld data from CH-0 to CH-%d of PCI-9812 in %d Hz, and\nstore data to file '%s'.\nPlease press any key to start the operation.\n", read_count, channel, (int)sample_rate, file_name);

    getch();
    if ((card=Register_Card (PCI_9812, 0)) <0 ) {
        printf("Register_Card error=%d\n", card);
        exit(1);
    }
    err = AI_9812_Config(card, P9812_TRGMOD_SOFT, P9812_TRGSRC_CH0, P9812_TRGSLP_POS, P9812_AD2_GT_PCI|P9812_CLKSRC_INT, 0x80, 0);
    if (err!=0) {
       printf("AI_9812_Config error=%d", err);
       exit(1);
    }
    err = AI_AsyncDblBufferMode(card, 0);
    if (err!=0) {
       printf("AI_DblBufferMode error=%d", err);
       exit(1);
    }

    mem_size=read_count * 2;
    ai_buf = (I16*)malloc(mem_size);

    err = AI_ContScanChannels(card, channel, range, ai_buf, read_count, sample_rate, SYNCH_OP);
    if (err!=0) {
       printf("AI_ContReadChannel error=%d", err);
       free( ai_buf );
       Release_Card(card);
       exit(1);
    }

    printf(" %ld data trnasfered !\n", read_count );

    Release_Card(card);

	  if( write_to_file( (U16*)ai_buf, channel+1 ) )
        printf("\n\nThe input data is already stored in file '%s'.\n", file_name);

	  //    show_channel_data( (U16*)ai_buf, channel+1 );
    plot_channel_data();
    free( ai_buf );

    printf("\nPress ENTER to exit the program. "); 
    //getch(); 
    //putchar('\n');
    return 0;
}
Exemplo n.º 2
0
int main(void)
{
    I16 err;

    setbuf( stdout, NULL );
    if ( (card = Register_Card(PCI_9812, 0)) < 0) {
        printf("Register_Card error=%d", card);
        exit(1);
    }

    err = AI_9812_Config(card,P9812_TRGMOD_PRE, P9812_TRGSRC_EXT_DIG, P9812_TRGSLP_POS, P9812_AD2_GT_PCI|P9812_CLKSRC_INT,0,0x1);
    if( err != NoError){
        printf("9812 : AI_Config Error = %d\n", err);
        Release_Card(card);
        exit(1);
    }

    if (( fp = fopen( file_name , "w+b")) == NULL){
        Release_Card(card);
        exit(1);
    }

    mem_size=read_count * 2;
    ai_buf = (I16*)malloc(mem_size);

    err = AI_ContScanChannels (card, channel, range, ai_buf, read_count, sample_rate, ASYNCH_OP);
    if( err != NoError) {
        printf(" 9118 : AI_ContReadPort Error = %d\n", err);
        Release_Card(card);
        free( ai_buf );
        fclose( fp );
        exit(1);
    }

    printf( "ContScanChannels with Pre-Trigger operation \n");
    printf(" About the Data consversion with the External Trigger signal \n" );

    fstop = 0;
    do{
        AI_AsyncCheck(card, &fstop, &count);
    }while (!fstop);
    AI_AsyncClear(card, &count); // stop data aquisition & memory copy

    ProcessData();
    show_channel_data();
    free( ai_buf );
    printf(" the data is saved into %s\n", file_name );
    return 0;
}
Exemplo n.º 3
0
int acquire_data()
{
    I16 card, err;

    setbuf( stdout, NULL );
    //    printf("This program inputs %ld data from CH-0 to CH-%d of PCI-9812 in %d Hz, and\nstore data to file '%s'.\nPlease press any key to start the operation.\n", read_count, channel, (int)sample_rate, file_name);

    //    getch();
    if ((card=Register_Card (PCI_9812, 0)) <0 ) {
        printf("Register_Card error=%d\n", card);
        exit(1);
    }
    err = AI_9812_Config(card, P9812_TRGMOD_SOFT, P9812_TRGSRC_CH0, P9812_TRGSLP_POS, P9812_AD2_GT_PCI|P9812_CLKSRC_INT, 0x80, 0);
    if (err!=0) {
       printf("AI_9812_Config error=%d", err);
       exit(1);
    }
    err = AI_AsyncDblBufferMode(card, 0);
    if (err!=0) {
       printf("AI_DblBufferMode error=%d", err);
       exit(1);
    }

    mem_size=read_count * 2;
    ai_buf = (I16*)malloc(mem_size);

    err = AI_ContScanChannels(card, channel, range, ai_buf, read_count, sample_rate, SYNCH_OP);
    if (err!=0) {
       printf("AI_ContReadChannel error=%d", err);
       free( ai_buf );
       Release_Card(card);
       exit(1);
    }

    printf("%ld data samples transfered.\n", read_count );

    Release_Card(card);
    return 0;
}