You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.8 KiB
57 lines
1.8 KiB
#include <windows.h>
|
|
#include <stdio.h>
|
|
#include <conio.h>
|
|
#include "dask.h"
|
|
|
|
U16 channel=3; //4 channels
|
|
U16 range=AD_B_5_V;
|
|
char *file_name="9112d";
|
|
U32 read_count=2000;
|
|
F64 sample_rate=2000;
|
|
|
|
main()
|
|
{
|
|
I16 card, err, card_num;
|
|
BOOLEAN halfReady, fStop;
|
|
U32 count=0, count1;
|
|
|
|
printf("This program inputs data from CH-%d to CH-0 of PCI-9112 in %d Hz by\ndouble-buffer mode, and store data to file '%s.dat'. The size of circular\nbuffer is %d. It will not stop until you press a key.\n\nPress any key to start the operation.\n",
|
|
channel, (int)sample_rate, file_name, read_count);
|
|
printf("Please input a card number: ");
|
|
scanf(" %d", &card_num);
|
|
//getch();
|
|
if ((card=Register_Card (PCI_9112, card_num)) <0 ) {
|
|
printf("Register_Card error=%d\n", card);
|
|
exit(1);
|
|
}
|
|
err = AI_9112_Config(card, TRIG_INT_PACER);
|
|
if (err!=0) {
|
|
printf("AI_9112_Config error=%d", err);
|
|
exit(1);
|
|
}
|
|
err = AI_AsyncDblBufferMode(card, 1); //double-buffer mode
|
|
if (err!=0) {
|
|
printf("AI_DblBufferMode error=%d", err);
|
|
exit(1);
|
|
}
|
|
err = AI_ContScanChannelsToFile(card, channel, range, file_name, read_count, sample_rate, ASYNCH_OP);
|
|
if (err!=0) {
|
|
printf("AI_ContReadChannel error=%d", err);
|
|
exit(1);
|
|
}
|
|
printf("\n\nPress any key to stop input operation.");
|
|
printf("\n\nData count : \n");
|
|
do {
|
|
do {
|
|
AI_AsyncDblBufferHalfReady(card, &halfReady, &fStop);
|
|
} while (!halfReady);
|
|
AI_AsyncDblBufferTransfer(card, NULL); //transfer to file
|
|
count += (read_count / 2);
|
|
printf("%d\r", count);
|
|
} while(!kbhit());
|
|
AI_AsyncClear(card, &count1);
|
|
Release_Card(card);
|
|
printf("\n\n%d input data are stored in file '%s.dat'.\n", count, file_name);
|
|
printf("\nPress ENTER to exit the program. "); getch();
|
|
}
|
|
|