星期二, 十月 25, 2005
C CODE:ADTEST FOR TurboC
/*
PC-LabCard 812PG by Advantech Co.Ltd.
ADTEST FOR TurboC
Conwerter:HADC574Z
Channel:1
Input Range:+/-10V
Copyright (c) 2003 NEFU. All rights reserved.
*/
#include
#include
void window(void);
void adc(void);
void main(void)
{ while(1)
{
adc();
}
}
void window(void)
{ gotoxy(14, 6);printf("-----------------------------------------------");
gotoxy(14, 7);printf("");gotoxy(60,7);printf("");
gotoxy(14, 8);printf("");gotoxy(60,8);printf("");
gotoxy(14, 9);printf("");gotoxy(60,9);printf("");
gotoxy(14,10);printf("-----------------------------------------------");
gotoxy(20, 7);printf("PC-LabCard 812PG by Advantech Co.Ltd.");
gotoxy(20, 8);printf("HADC574Z +/-10V");
gotoxy(20, 9);printf("ADTEST FOR TurboC");
gotoxy(10,13);printf("=========================================================");
gotoxy(25,14);printf("COUNT CODE VOLTAGE ");
gotoxy(10,16);printf("=========================================================");
}
void adc(void)
{ int ad,i=0;
float adv;
outportb(0x22A,0x00); /*AD MUX-channel 0*/
outportb(0x229,0X00); /*AD GAIN-1*/
outportb(0x22B,0x01); /*AD MODE CONTROL-software trigger ang program transfer only*/
while(1)
{outportb(0x22C,0x00); /*AD TRIGGER-causes software trigger*/
while(inportb(0x225)&0x10==0x00);
ad=(inportb(0x224)(inportb(0x225)&0x0f)<<8);
adv=((float)ad*20/4096-10);
clrscr();window();
gotoxy(25,15);printf(" %4d %4d %5.3fV",i,ad,adv);
delay(750);
i++;
}
}
PC-LabCard 812PG by Advantech Co.Ltd.
ADTEST FOR TurboC
Conwerter:HADC574Z
Channel:1
Input Range:+/-10V
Copyright (c) 2003 NEFU. All rights reserved.
*/
#include
#include
void window(void);
void adc(void);
void main(void)
{ while(1)
{
adc();
}
}
void window(void)
{ gotoxy(14, 6);printf("-----------------------------------------------");
gotoxy(14, 7);printf("");gotoxy(60,7);printf("");
gotoxy(14, 8);printf("");gotoxy(60,8);printf("");
gotoxy(14, 9);printf("");gotoxy(60,9);printf("");
gotoxy(14,10);printf("-----------------------------------------------");
gotoxy(20, 7);printf("PC-LabCard 812PG by Advantech Co.Ltd.");
gotoxy(20, 8);printf("HADC574Z +/-10V");
gotoxy(20, 9);printf("ADTEST FOR TurboC");
gotoxy(10,13);printf("=========================================================");
gotoxy(25,14);printf("COUNT CODE VOLTAGE ");
gotoxy(10,16);printf("=========================================================");
}
void adc(void)
{ int ad,i=0;
float adv;
outportb(0x22A,0x00); /*AD MUX-channel 0*/
outportb(0x229,0X00); /*AD GAIN-1*/
outportb(0x22B,0x01); /*AD MODE CONTROL-software trigger ang program transfer only*/
while(1)
{outportb(0x22C,0x00); /*AD TRIGGER-causes software trigger*/
while(inportb(0x225)&0x10==0x00);
ad=(inportb(0x224)(inportb(0x225)&0x0f)<<8);
adv=((float)ad*20/4096-10);
clrscr();window();
gotoxy(25,15);printf(" %4d %4d %5.3fV",i,ad,adv);
delay(750);
i++;
}
}