Advantech PCI-1718 Series Carbon Monoxide Alarm User Manual


 
PCI-1718 Series User Manual 42
1. Set the input range for each A/D channel
2. Set the input channel by specifying the MUX scan range
3. Set pacer rate and interrupt service routine (ISR)
4. Enable device to generate interrupts and system to accept interrupts
5. Trigger the A/D conversion by writing “1” to the A/D control
register (BASE+9)
6. Interrupts generate by the device when the A/D conversion is
completed.
7. Read data from the A/D converter by reading the A/D data register
(BASE+0 and BASE+1)
8. Convert the binary A/D data to an integer.
Example Code:
/******This code supports TurboC 3.0 or later versions********/
#include <stdio.h>
#include <DOS.h>
void interrupt isr(void);
#define AD_NO 4096; //Number of Samples
int iflag;
int base_addr;
void main(void)
{
int ad_lb,ad_hb; //Declaration
int i=1;
/****** Access your base address ******/
Add you code here
/*******************************************/
outportb(base_addr+9,0x00); //Set Software Trigger and Disable INT.
outportb(base_addr+2,0x00); //Mux Scan Channel Control
outportb(base_addr+1,0x00); //A/D Range Control