星期二, 十月 25, 2005
C CODE:TEMPERATURETEST FOR TurboC
/*
PC-LabCard 812PG by Advantech Co.Ltd.
TEMPERATURETEST FOR TurboC
Conwerter:HADC574Z
Channel:1
Input Range:+/-10V
Sensor:AD590
Copyright (c) 2003 NEFU. All rights reserved.
*/
#include
#include
void window(void);
void adc(void);
void main(void)
{
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 AD590");
gotoxy(20, 9);printf("TEMPERATURETEST FOR TurboC");
gotoxy(10,13);printf("=========================================================");
gotoxy(20,14);printf("COUNT CODE VOLTAGE TEMPERATURE");
gotoxy(10,16);printf("=========================================================");
}
void adc(void)
{ int ad,i=0;
float adv,temperture;
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);
temperture=(float)(ad-2048)*0.05;
clrscr();window();
gotoxy(20,15);printf(" %4d %4d %5.3fV %4.1fC",i,ad,adv,temperture);
delay(750);
i++;
}
}
PC-LabCard 812PG by Advantech Co.Ltd.
TEMPERATURETEST FOR TurboC
Conwerter:HADC574Z
Channel:1
Input Range:+/-10V
Sensor:AD590
Copyright (c) 2003 NEFU. All rights reserved.
*/
#include
#include
void window(void);
void adc(void);
void main(void)
{
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 AD590");
gotoxy(20, 9);printf("TEMPERATURETEST FOR TurboC");
gotoxy(10,13);printf("=========================================================");
gotoxy(20,14);printf("COUNT CODE VOLTAGE TEMPERATURE");
gotoxy(10,16);printf("=========================================================");
}
void adc(void)
{ int ad,i=0;
float adv,temperture;
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);
temperture=(float)(ad-2048)*0.05;
clrscr();window();
gotoxy(20,15);printf(" %4d %4d %5.3fV %4.1fC",i,ad,adv,temperture);
delay(750);
i++;
}
}