
/*  DB-889D Demo program                        */
/*  use A-822PGL Multi-function card            */
/*      Base Address : 0x220                    */
/*      Single-end Analog input channel #0      */
/*      Gain=1 Bipolar mode                     */


#include <stdio.h>
#include <conio.h>
#include "A822.h"

void main(void)
{
 int ad_data;
 float ad_vol;

  /*===================  init. A-822 & DB-889D ===========*/

 A822_Initialize(0,0x220,-1,-1);   /* A-822 Base address 0x220*/
 A822_AD_SetChGainMode(0,0,1);     /* Channel =0 , Gain=1, Polling trigger*/
 A822_DO(0x0000);                  /* Set DB-889D Gain=0.5 , Channel = 0  */


  /*==================== Reading DATA =======================*/

 ad_data=A822_AD_PollingVar();     /* Reading data */

 ad_vol=(float)((ad_data-2048)*10/2048);  /* Conversion data to Voltage */
					  /* DB-889D gain=0.5           */
					  /*      input range=-10 ~ +10V*/

 printf(" Voltage = %6.4f V\n",ad_vol );

 }

