#include   <stdio.h>	     /******************************************/
#include   "A822.h"          /*                                        */
			     /* for A822PGH			       */
unsigned int   Buffer[2000]; /* 				       */
int wCardMode;		     /******************************************/
main(void)
{
int  Ch,G,i,j;
float  volt,temp,v0,v1,v2,v3,v4,v5,v6,v7;
unsigned int PollData;
wCardMode=A822_SetCardModel(A822_Mode);
A822_Initialize(0,0x220,-1,-1);

for (;;)
{
Ch=0; G=0;                                /* Channel_0, Gain=1, Bipolar */

/*Warring:A8112 only support Single-End*/
A822_AD_SetChGainMode(Ch,G,POLLING_MODE); /* Polling */
A822_Delay(23*2);			  /* GAIN setting time=23 us */
PollData=A822_AD_PollingVar();
temp=(float)PollData;
volt=(temp-2048)/2048.0*5.0;
v0=volt;

Ch=1; G=1;				  /* Channel_1, Gain=10, Bipolar*/
A822_AD_SetChGainMode(Ch,G,POLLING_MODE); /* Polling */
A822_Delay(28*2);			  /* GAIN setting time=28 us */
PollData=A822_AD_PollingVar();
temp=(float)PollData;
volt=(temp-2048)/2048.0*5.0;
v1=volt/10.0;

Ch=2; G=2;				   /* Channel_2,Gain=100,Bipolar*/
A822_AD_SetChGainMode(Ch,G,POLLING_MODE);  /* Polling */
A822_Delay(140*2);			   /* GAIN setting time=140 us */
PollData=A822_AD_PollingVar();
temp=(float)PollData;
volt=(temp-2048)/2048.0*5.0;
v2=volt/100.0;

Ch=3; G=3;				   /*Channel_3,Gain=1000,Bipolar*/
A822_AD_SetChGainMode(Ch,G,POLLING_MODE);  /* Polling */
A822_Delay(1300*2);			   /* GAIN setting time=1300 us */
PollData=A822_AD_PollingVar();
temp=(float)PollData;
volt=(temp-2048)/2048.0*5.0;
v3=volt/1000.0;

Ch=4; G=4;				  /* Channel_4, Gain=1, Unipolar*/
A822_AD_SetChGainMode(Ch,G,POLLING_MODE); /* Polling */
A822_Delay(23*2);			  /* GAIN setting time=23 us */
PollData=A822_AD_PollingVar();
temp=(float)PollData;
volt=temp/4095.0*10.0;
v4=volt;

Ch=5; G=5;				  /*Channel_5, Gain=10, Unipolar*/
A822_AD_SetChGainMode(Ch,G,POLLING_MODE); /* Polling */
A822_Delay(28*2);			  /* GAIN setting time=28 us */
PollData=A822_AD_PollingVar();
temp=(float)PollData;
volt=temp/4095.0*10.0;
v5=volt/10.0;

Ch=6; G=6;				   /*Channel_6,Gain=100,Unipolar*/
A822_AD_SetChGainMode(Ch,G,POLLING_MODE);  /* Polling */
A822_Delay(140*2);			   /* GAIN setting time=140 us */
PollData=A822_AD_PollingVar();
temp=(float)PollData;
volt=temp/4095.0*10.0;
v6=volt/100.0;

Ch=7; G=7;				   /*Chan_7,Gain=1000,Unipolar*/
A822_AD_SetChGainMode(Ch,G,POLLING_MODE);  /* Polling */
A822_Delay(1300*2);			   /* GAIN setting time=1300 us */
PollData=A822_AD_PollingVar();
temp=(float)PollData;
volt=temp/4095.0*10.0;
v7=volt/1000.0;

printf("\nA822PGH:[0]=%7.5fV,[1]=%7.5fV,[2]=%7.5fV,[3]=%7.5f",v0,v1,v2,v3);
printf("\nA822PGH:[4]=%7.5fV,[5]=%7.5fV,[6]=%7.5fV,[7]=%7.5f",v4,v5,v6,v7);
if (kbhit()!=0) {getch(); return;}
}
}
