Hallo
Ich hab mal wider ein neues Projekt angefangen. Es geht darum eine Anzeige zu erstellen die den aktuellen Status meiner heizung anzeigt. Dazu werden zwei NTCs an dem warmwasserspeicher und dem ofen angebracht. Über ein LCD Display wird der aktuelle Status angezeigt (Wenn der Wasserspeicher warm genug ist -> Alles in Ordnung) ( Wenn der Wasserspeicher kalt ist und der Ofen heiß -> Aufheizvorgang) ( wenn der Ofen kalt ist und der Wasserspeicher auch -> Bitte nachlegen!)
Um die Temperaturen ermitteln zu können soll eine Spannung durch die NTCs geleitet werden und nach einem entsprechendem Spannungsteiler in den ADC eines Mega8 geschikt werden. Der ADC soll dann anhand der Spannung die entsprechnenden Textausgaben steuern.
Das Programm wäre soweit fertig. nur gibz ein kleines Problem mit den ADCs. Den ADC0 zu benutzen ist mir schon bei anderen Projekten gelungen. aber jetzt habe ich zwei verschidene Spannungswerte zu verarbeiten. und ich hab auch nach vielen Googlen keine Beispiele gefunden wie man explizit einzelne ADCs ausliest.
Könnte mir jemand auf die Sprünge helfen?
Gruß
Hier mal der bisherige Quelltext (Die ADCs funktionieren nicht wie sie sollen. die Textausgaben jedoch nach einer ADC Manipulation einwandfrei)
@ Oldmax. Ich bin mir sicher du bekommst wider einen Herzinfakt bei dem Durcheinander. Aber ich versuch immer noch mich zu bessern
Ich hab mal wider ein neues Projekt angefangen. Es geht darum eine Anzeige zu erstellen die den aktuellen Status meiner heizung anzeigt. Dazu werden zwei NTCs an dem warmwasserspeicher und dem ofen angebracht. Über ein LCD Display wird der aktuelle Status angezeigt (Wenn der Wasserspeicher warm genug ist -> Alles in Ordnung) ( Wenn der Wasserspeicher kalt ist und der Ofen heiß -> Aufheizvorgang) ( wenn der Ofen kalt ist und der Wasserspeicher auch -> Bitte nachlegen!)
Um die Temperaturen ermitteln zu können soll eine Spannung durch die NTCs geleitet werden und nach einem entsprechendem Spannungsteiler in den ADC eines Mega8 geschikt werden. Der ADC soll dann anhand der Spannung die entsprechnenden Textausgaben steuern.
Das Programm wäre soweit fertig. nur gibz ein kleines Problem mit den ADCs. Den ADC0 zu benutzen ist mir schon bei anderen Projekten gelungen. aber jetzt habe ich zwei verschidene Spannungswerte zu verarbeiten. und ich hab auch nach vielen Googlen keine Beispiele gefunden wie man explizit einzelne ADCs ausliest.
Könnte mir jemand auf die Sprünge helfen?
Gruß
Hier mal der bisherige Quelltext (Die ADCs funktionieren nicht wie sie sollen. die Textausgaben jedoch nach einer ADC Manipulation einwandfrei)
@ Oldmax. Ich bin mir sicher du bekommst wider einen Herzinfakt bei dem Durcheinander. Aber ich versuch immer noch mich zu bessern
Code:
.include "m8def.inc"
;Alias Namen erstellen
.def temp1 = r16
.def temp2 = r17
.def temp3 = r18
.def temp4 = r19
.def temp5 = r20
.def temp6 = r21
;Stack Initialisieren
ldi temp1, LOW(RAMEND)
out SPL, temp1
ldi temp1, HIGH(RAMEND)
out SPH, temp1
;****************************************************
;Ausgänge definieren
LDI temp1,0b11111111
Out DDRD,temp1
;ADC Initialisieren
LDI temp1,(1<<REFS0) | (1<<ADLAR) ;Kanal 0 Interne Refferenzspannung
out ADMUX, temp1
LDI temp1,(1<<ADEN) | (1<<ADPS2) | (1<<ADPS1) | (1<<ADPS0)
out ADCSRA,temp1
;Display Initialisieren
rcall Display_ini
;Hauptmenü
;****************************************************
Menue:
rcall LCD_löschen
; LDI temp2,0b00000000 ;Zeile festlegen 0b10000000=Zeile 0 , 0b11000000=Zeile 1
; rcall send_Befehl
LDI Temp2, ' '
rcall Print
LDI temp2, 'T'
rcall Print
LDI Temp2, 'H'
rcall Print
LDI temp2, 'E'
rcall Print
LDI Temp2, 'R'
rcall Print
LDI temp2, 'M'
rcall Print
LDI Temp2, 'O'
rcall Print
LDI temp2, ' '
rcall Print
LDI Temp2, 'M'
rcall Print
LDI temp2, 'A'
rcall Print
LDI Temp2, 'N'
rcall Print
LDI temp2, 'A'
rcall Print
LDI temp2, 'G'
rcall Print
LDI temp2, 'E'
rcall Print
LDI temp2, 'R'
rcall Print
LDI temp2, ' '
rcall Print
LDI temp2,0b11000000 ;Zeile festlegen 0b10000000=Zeile 0 , 0b11000000=Zeile 1
rcall send_Befehl
LDI Temp2, ' '
rcall Print
LDI temp2, ' '
rcall Print
LDI Temp2, ' '
rcall Print
LDI temp2, 'W'
rcall Print
LDI Temp2, 'I'
rcall Print
LDI temp2, 'L'
rcall Print
LDI Temp2, 'L'
rcall Print
LDI temp2, 'K'
rcall Print
LDI Temp2, 'O'
rcall Print
LDI temp2, 'M'
rcall Print
LDI Temp2, 'M'
rcall Print
LDI temp2, 'E'
rcall Print
LDI Temp2, 'N'
rcall Print
Loop:
Wait_1000:
LDI r22,20
Wait_1001:
LDI r23,255
Wait_1002:
LDI r24,255
Wait_1003:
dec r24
brne Wait_1003
dec r23
brne Wait_1002
dec r22
brne Wait_1001
Start_ADC0:
ldi temp1,(0<<MUX3) | (0<<MUX2) | (0<<MUX1) | (0<<MUX0) ;ADC0 Wählen
out ADMUX,temp1
sbi ADCSRA,ADSC
Wait_ADC0:
sbic ADCSRA,ADSC
rjmp wait_adc0
;ADC Einlesen
in temp5,ADCL
in temp5,ADCH
Start_ADC1:
ldi temp1,(0<<MUX3) | (0<<MUX2) | (0<<MUX1) | (1<<MUX0) ;ADC1 Wählen
out ADMUX,temp1
sbi ADCSRA,ADSC
Wait_ADC1:
sbic ADCSRA,ADSC
rjmp wait_adc1
;ADC Einlesen
in temp6,ADCL
in temp6,ADCH
Puffer: ;Puffertemperatur abfragen
CPI temp5,10 ;Vergleiche ADC0 Wert mit 100
BRLO Kessel ;Springe zu Kessel wenn Wert unter 100
rjmp Allesio ;Springe zu Allesio wenn Wert über 100
Kessel: ;Kesseltemperatur abfragen
CPI temp6,10 ;Vergleiche ADC1 Wert mit 100
BRLO Nachlegen ;Springe zu Nachlegen wenn Wert unter 100
rjmp Aufheizen ;Springe zu Aufheizen wenn Wert über 100
;****Nachlegen****
Nachlegen:
rcall LCD_löschen
LDI temp2,0b10000000 ;Zeile festlegen 0b10000000=Zeile 0 , 0b11000000=Zeile 1
rcall send_Befehl
LDI Temp2, ' '
rcall Print
LDI temp2, 'T'
rcall Print
LDI Temp2, 'H'
rcall Print
LDI temp2, 'E'
rcall Print
LDI Temp2, 'R'
rcall Print
LDI temp2, 'M'
rcall Print
LDI Temp2, 'O'
rcall Print
LDI temp2, ' '
rcall Print
LDI Temp2, 'M'
rcall Print
LDI temp2, 'A'
rcall Print
LDI Temp2, 'N'
rcall Print
LDI temp2, 'A'
rcall Print
LDI temp2, 'G'
rcall Print
LDI temp2, 'E'
rcall Print
LDI temp2, 'R'
rcall Print
LDI temp2, ' '
rcall Print
LDI temp2,0b11000000 ;Zeile festlegen 0b10000000=Zeile 0 , 0b11000000=Zeile 1
rcall send_Befehl
LDI Temp2, 'B'
rcall Print
LDI temp2, 'I'
rcall Print
LDI Temp2, 'T'
rcall Print
LDI temp2, 'T'
rcall Print
LDI Temp2, 'E'
rcall Print
LDI temp2, ' '
rcall Print
LDI Temp2, 'N'
rcall Print
LDI temp2, 'A'
rcall Print
LDI Temp2, 'C'
rcall Print
LDI temp2, 'H'
rcall Print
LDI Temp2, 'L'
rcall Print
LDI temp2, 'E'
rcall Print
LDI Temp2, 'G'
rcall Print
LDI temp2, 'E'
rcall Print
LDI Temp2, 'N'
rcall Print
LDI temp2, '!'
rcall Print
rjmp Loop
;****Aufheizen****
Aufheizen:
rcall LCD_löschen
LDI temp2,0b10000000 ;Zeile festlegen 0b10000000=Zeile 0 , 0b11000000=Zeile 1
rcall send_Befehl
LDI Temp2, ' '
rcall Print
LDI temp2, 'T'
rcall Print
LDI Temp2, 'H'
rcall Print
LDI temp2, 'E'
rcall Print
LDI Temp2, 'R'
rcall Print
LDI temp2, 'M'
rcall Print
LDI Temp2, 'O'
rcall Print
LDI temp2, ' '
rcall Print
LDI Temp2, 'M'
rcall Print
LDI temp2, 'A'
rcall Print
LDI Temp2, 'N'
rcall Print
LDI temp2, 'A'
rcall Print
LDI temp2, 'G'
rcall Print
LDI temp2, 'E'
rcall Print
LDI temp2, 'R'
rcall Print
LDI temp2,0b11000000 ;Zeile festlegen 0b10000000=Zeile 0 , 0b11000000=Zeile 1
rcall send_Befehl
LDI Temp2, ' '
rcall Print
LDI temp2, ' '
rcall Print
LDI Temp2, ' '
rcall Print
LDI temp2, 'A'
rcall Print
LDI Temp2, 'U'
rcall Print
LDI temp2, 'F'
rcall Print
LDI Temp2, 'H'
rcall Print
LDI temp2, 'E'
rcall Print
LDI Temp2, 'I'
rcall Print
LDI temp2, 'Z'
rcall Print
LDI Temp2, 'E'
rcall Print
LDI temp2, 'N'
rcall Print
rjmp Loop
;****Alles iO***
Allesio:
rcall LCD_löschen
LDI temp2,0b10000000 ;Zeile festlegen 0b10000000=Zeile 0 , 0b11000000=Zeile 1
rcall send_Befehl
LDI Temp2, ' '
rcall Print
LDI temp2, 'T'
rcall Print
LDI Temp2, 'H'
rcall Print
LDI temp2, 'E'
rcall Print
LDI Temp2, 'R'
rcall Print
LDI temp2, 'M'
rcall Print
LDI Temp2, 'O'
rcall Print
LDI temp2, ' '
rcall Print
LDI Temp2, 'M'
rcall Print
LDI temp2, 'A'
rcall Print
LDI Temp2, 'N'
rcall Print
LDI temp2, 'A'
rcall Print
LDI temp2, 'G'
rcall Print
LDI temp2, 'E'
rcall Print
LDI temp2, 'R'
rcall Print
LDI temp2, ' '
rcall Print
LDI temp2,0b11000000 ;Zeile festlegen 0b10000000=Zeile 0 , 0b11000000=Zeile 1
rcall send_Befehl
LDI Temp2, 'A'
rcall Print
LDI temp2, 'L'
rcall Print
LDI Temp2, 'L'
rcall Print
LDI temp2, 'E'
rcall Print
LDI Temp2, 'S'
rcall Print
LDI temp2, ' '
rcall Print
LDI Temp2, 'I'
rcall Print
LDI temp2, 'N'
rcall Print
LDI Temp2, ' '
rcall Print
LDI temp2, 'O'
rcall Print
LDI Temp2, 'R'
rcall Print
LDI temp2, 'D'
rcall Print
LDI Temp2, 'N'
rcall Print
LDI temp2, 'U'
rcall Print
LDI Temp2, 'N'
rcall Print
LDI temp2, 'G'
rcall Print
rjmp Loop
; Unterprogramme
;-----------------------------------------------------------------
; Display Installieren
;**************************************************
Display_ini:
rcall Waitms20
ldi temp3,3
Widerholung:
LDI temp2,0b00000011
Out portd,temp2
rcall send
dec temp3
brne Widerholung
LDI temp2,0b00000010
OUT Portd,temp2
rcall send
LDI temp2,0b00101000
rcall Send_Befehl
LDI temp2,0b00001100
rcall Send_Befehl
LDI temp2,0b00000100
rcall Send_Befehl
ret
;LCD Löschen
;*************************************************
LCD_Löschen:
ldi temp2,0b00000001
rcall Send_Befehl
ret
;Aufs LCD schreiben
;*************************************************
Print:
Mov temp3,temp2
swap temp2
andi temp2,0b00001111
sbr temp2,0b00010000
out PortD,temp2
rcall send
andi temp3,0b00001111
sbr temp3,0b00010000
OUT Portd,temp3
rcall Send
ret
;Instruktionen ans LCD
;*************************************************
Send_Befehl:
Mov temp3,temp2
swap temp2
andi temp2,0b00001111
out PortD,temp2
rcall send
andi temp3,0b00001111
OUT Portd,temp3
rcall Send
ret
;Warteschleifen
;************************************************
Waitms5:
LDI temp1,50
Waitms5_1:
LDI temp2,255
Waitms5_2:
dec temp2
brne waitms5_2
dec temp1
brne Waitms5_1
ret
Waitms20:
LDI temp1,200
Waitms20_1:
LDI temp2,255
Waitms20_2:
dec temp2
brne waitms20_2
dec temp1
brne Waitms20_1
ret
;Sendefreigabe
;************************************************
Send:
SBI portd,5
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
CBI portd,5
rcall waitms5
ret