#include #pragma config |= 0b.11.111101.11.00.10 #define LCD_RS 0b.00000001 #define LCD_CS 0b.00001000 #pragma char PORTQ @ PORTB #include "delay20.c" #include "lcd.c" void delay_mks( char mikro) { #asm wdh9 nop nop decfsz mikro,f goto wdh9 #endasm } void ZahlString(uns16 z) { uns16 i, temp, Dez; bit k; k=0; Dez=1000; while (Dez) { if (Dez==1) k=1; i=z/Dez; temp=i*Dez; z=z-temp; if (i||k) { LCDWriteChar((char)i+0x30); k=1; } else { LCDWriteChar(' '); } Dez=Dez/10; } } uns16 ADC(char kanal) { uns16 Antwort; ADCON0 &= 0b.1100.0111; kanal= kanal << 3 ; ADCON0 |= kanal; delay_mks(50); GO=1; while(GO); Antwort.low8=ADRESL; Antwort.high8=ADRESH; return Antwort; } //************************************************************************************* void main(void) { uns16 a=1, b=1, c=1, d=1, y=1, Uweite=1, U=0, Tweite=0, T, x=10, temp, tempo; char n; TRISC=0b.1111.1110; PORTB=0x00; TRISB=0b00000000; LCDCls(); T=0-50; temp=1; tempo=1; LCDPos(1,0); ZahlString(T); ADCON1=0; ADON=1; ADCS1=1; ADCS0=0; ADFM=1; bit Wert @ PORTC.0; lcdport=0; Delay1ms(1000); LCDInit(); /*LCDPos(1,0); LCDString("TV:"); LCDPos(1,6); LCDString("°C"); LCDPos(1,12); LCDString("TR:"); LCDPos(1,18); LCDString("°C"); LCDPos(2,0); LCDString("D:"); LCDPos(2,5); LCDString("°C"); LCDPos(2,9); LCDString("H:"); LCDPos(2,14); LCDString(" R:"); */ while(1) { LCDPos(1,8); a=ADC(n); ZahlString(a); a=ADC(n); b=1500/1000; d=b%10; LCDPos(1,6); ZahlString(b); c=b*a; y=c-500; U=y%10; LCDPos(2,0); ZahlString(y); LCDPos(2,4); LCDString(","); ZahlString(U); /* tempo=a*50000; temp=tempo/1024; Tweite=temp/10000; b=temp%10000; */ /*Uweite=a-U; b=Uweite/x; tempo=b*y; Tweite=tempo-T;*/ ZahlString(c); if(Tweite>800) { Wert=1;} else Wert=0; LCDPos(1,0); a=ADC(n); ZahlString(b); if(Tweite>800) { Wert=1;} else Wert=0; Delay1ms(500); //------------------------------------------- } }