Das Open-Control-Projekt - Die Alternative zur C-Control-I


Das Forum zur C-Control-1
Welche C-Control-Varianten existieren?
Übersicht - Suchen - Neueste 50 Beiträge - Neuer Beitrag - Login - Registrieren
INFO - FAQ - CC2-Forum - CCPro-Forum 

 immernoch fehler Kategorie: Programmierung Basic (von Andreas Krieger - 12.11.2005 15:00)
Andreas Krieger nutzt:  CC1-Station V2.0

Hallo Leute,
ich hab noch einen weiteren Fehler der mir mehr zu schaffen macht.
Ich habe die word-definitionen jetzt so geändert,dass die Fehler die ja
immer da waren weg sind.
Aber da ist noch ein scheinbar sporatischer Fehler.
ich lasse durch drücken von der 1 auf der Tastatur eine Variable (timer3) hochzählen.
hierzu muß timer3run bit gesetzt sein. Der Timer läuft auch hoch.
allerdings nach dem er bei 1,91 und 181 das relais k3 einschalten soll passiert es manchmal
daß das relais kurz anzieht dann die station resetet.
ehrlich gesagt,ich glaube nicht an Spannungseinbrüche,das testprog lief ja auch und die HW
hab ich auch schon getauscht. mit gleichem ergebnis.
schaut euch mal die defin anweisungen als erstes an,ich hhab doch alles richtig gemacht,oder?


versuche mal das prog zu posten,wenns reinpaßt.
'--------------------------
'---- SYSTEM MEMORY -------
'--------------------------
define TEMP         word[1]'1+2
define TEMPHI       byte[1]
define TEMPLO       byte[2]
define negbit       bit [1]
define SCONFIG      byte[3]
define DATA         byte[4]
define tmpw         word[3]'5+6
define tmp1         byte[5]
define tmp2         byte[6]
define istzeit      word[4]'7+8
define keycode      byte[9]
define oldsec       byte[10]
define fehler       byte[11]'           Zeitgeber res.
define timer1       byte[12]
define timer2       byte[13]'           Zeitgeber für Heizung
define timer3       byte[14]'           Zeitgeber für Totenglocke
define timer4       word[8]'15+16      Zeitgeber für Geläute
define solltemp     word[9]'17+18
define sollzeit     word[10]'19+20
define reserve      byte[21]
define Bitvari1     byte[22]'belgt durch Bitvariablen
define Bitvari2     byte[23]'belgt durch Bitvariablen
define LEDS         byte[24]'belgt durch Bitvariablen
'port variablen
'--------------------------
'------ I/O PORTS ---------
'--------------------------
define LIGHT         port[16]
define EXTPORT      byteport[4]
define VUGlocke     port[1]
define SDA          port[9]
define SCL          port[10]
define LED1         port[25]
define LED2         port[26]
define LED3         port[27]
define LED4         port[28]

define ADC8           ad[8]
' Bit Variablen
define bitv1              bit[169]
define bitv2              bit[170]
define bitv3              bit[171]
define bitv4              bit[172]
define bitv5              bit[173]
define bitv6              bit[174]
define autoheizen         bit[175]
define timer1run          bit[176]
define timer2run          bit[177]
define timer3run          bit[178]
define Heizperiode        bit[179]
define handheizen         bit[180]
define secflag            bit[181]
define gelaeute           bit[182]
define tagwechselflag     bit[183]
define knopf              bit[184]
define Feiertag_1         bit[185]
define Feiertag_2         bit[186]
define Feiertag_3         bit[187]
define Feiertag_4         bit[188]
define K1                 bit[189]
define K2                 bit[190]
define K3                 bit[191]
define K4                 bit[192]


'--------------------------
define DS1631 158  'IIC ADDRESS $9E
'--------------------------
'--- DS1631 COMMANDS ------
'--------------------------
define CONVERT          &H51
define STOP_CONVERT     &H22
define READ_TEMP        &HAA
define CONFIG           &HAC
define RESET            &H54
'---------------------------


#INIT
LIGHT=off
'----------- EINSCHALT MELDUNG ------------------------
#datetime
print"#ON_LCD#";
print"#INIT#";
print"#OFF#";

open# for read
input# solltemp
close#
if solltemp<1 or solltemp>60 then solltemp= 38
sollzeit=1439

beep 10,10,5' Test auf reset !!!

DATA=1:gosub DS1631WRITE_STATUS  ' ONE SHOT MODE bei DATA=5 0.25 Auflösung
pause 10
data=0
'-------------------------------------------------------------
'-----           haupt Schleife ---
'-------------------------------------------------------------
#LOOP
if secflag=on then oldsec=second                        'Sekundenflag setzt oldsec
if oldsec=second then secflag=off else secflag=on       'sekundentimer erzeugt secflag
if secflag=off then goto endetimer
if (timer1run=on) and (second=59) then timer1=timer1 + 1'minutentimer
if timer1run=off then timer1=0
if (timer2run=on) and (second=59) then timer2=timer2+1'minutentimer
if timer2run=off then timer2=0
if timer3run=on then timer3=timer3 + 1 else timer3=0' sekundentimer
if Gelaeute=on then timer4=timer4+1 else timer4=0'sekundentimer
#endetimer
istzeit=(hour*60)+minute                                                          'serielle ist-Zeit
if hour=1 then tagwechselflag= off
if hour<23 then goto keintw
if minute<59 then goto keintw
if second<59 then goto keintw
if tagwechselflag=on then goto keintw
Feiertag_1=Feiertag_2
Feiertag_2=Feiertag_3
Feiertag_3=Feiertag_4
Feiertag_4=off
sollzeit=1439
tagwechselflag=on
#keintw
if month<9 and month>4 then Heizperiode=off else Heizperiode=on                'Heizperiode prüfen
gosub KEYDECODE                                                                 'ab hier Tastaturabfrage
if keycode<>255 then goto knopfdruck
knopf=off:goto knopfende
#knopfdruck
if knopf=on then goto knopfende
if keycode<>13 then goto endif01                                                'F2 gerückt
   if (LEDS and &HF)=0 then goto setfeiertag
   Feiertag_4=Feiertag_3
   Feiertag_3=Feiertag_2
   Feiertag_2=Feiertag_1
   Feiertag_1=off
   knopf = on
#endif01
if keycode<>12 then goto endif02                                                'F1 gedrückt
#setfeiertag
   Feiertag_1=on
   knopf=on
#endif02
if keycode<>1 then goto endif03                                                 '1 gedrückt
timer3run=on
#endif03
if keycode<>2 then goto endif04                                                 '2 gedrückt
Gelaeute=on
#endif04
if keycode<>3 then goto endif05                                                 '3 gedrückt
handheizen=on
#endif05
if keycode<>4 then goto endif06                                                 '4 gedrückt
timer3run=off
k3=off
#endif06
if keycode<>5 then goto endif07                                                 '5 gedrückt
Gelaeute=off
#endif07
if keycode<>6 then goto endif08                                                 '6 gedrückt
handheizen=off
#endif08
if keycode<>7 then goto endif09                                                 '7 gedrückt
solltemp=solltemp+1
open# for write
print# solltemp
close#
#endif09
if keycode<>8 then goto endif10                                                 '8 gedrückt
solltemp=solltemp-1
open# for write
print# solltemp
close#
#endif10
if keycode<>9 then goto endif11                                                 '9 gedrückt
#endif11
if keycode<>10 then goto endif12                                                '* gedrückt
autoheizen=off
#endif12
if keycode<>0 then goto endif13                                                 '0 gedrückt
'timer3=0
'minute=3
#endif13
if keycode<>11 then goto endif14                                                'E gedrückt
autoheizen=on
#endif14
#knopfende

'feiertagsregeln
if dow=7 and hour=0 then Feiertag_1=on                                          'wenn Sonntag ist
if month=1 and day=1 then Feiertag_1=off                                        'Sonntag gilt nicht für Neujahr!!
if month=12 and day=24 then Feiertag_1=off                                      'Sonntag gilt nicht für hl.Abend
if month=1 and day=6 and hour = 0 then Feiertag_1=on                            'hl.drei Könige
if month=12 and (day=25 or day=26)and hour=0 then Feiertag_1 = on               'Weihnachten
if month=12 and day=31 and hour=23 and minute=59 and second=59 then Gelaeute=on 'Sylvester


'Tagesregeln
if hour=11  and minute=0 then k1=on                                             'tägliches Läuten
if hour=19 and minute=0 then k1=on                                              'tägliches Läuten
if hour=11 and minute=3 then k1=off
if hour=19 and minute=3 then k1=off

if dow<>6 or hour<>14 then goto keinsamstag
if minute=0 then k3=on                                                          'Samstagsläuten
if minute=5 then k3=off
if minute=0 and second=6 then k2=on                                            'Samstagsläuten
if minute=5 then k2=off
#keinsamstag
if Feiertag_1=off then goto keinfeiertag
if hour=8 and minute=30 then k1=on                                              'Sonn und Feiertagsläuten
if hour=8 and minute=33 then k1=off
if hour=9 and minute=0 then k1=on
if hour=9 and minute=3 then k1=off
if hour=9 and minute=25  then Gelaeute= on
if Heizperiode=off then goto keinfeiertag
'looktab Heiztabelle,min(tmp1,solltemp),tmpw
'if istzeit=470 and autoheizen=off then sollzeit=570-tmpw
#keinfeiertag
if month<>1 or day<>1 then goto keinneujahr                                     'Neujahrsläuten
if hour=9 and minute=30 then k1=on
if hour=9 and minute=33 then k1=off
if hour=10 and minute=0 then k1=on
if hour=10 and minute=3 then k1=off
if hour=10 and minute=25  then Gelaeute= on
'looktab Heiztabelle,min(tmp1,solltemp),tmpw
'if istzeit=530 and autoheizen= off then sollzeit=630-tmpw
#keinneujahr
if month<>12 or day<>24 then goto keinhlabend                                   'Tag des Hl.Abend
if hour=15 and minute=0 then k1=on
if hour=15 and minute=3 then k1=off
if hour=15 and minute=25 then Gelaeute=on
if hour=16 and minute=55 then Gelaeute=on
if hour=22 and minute=25 then Gelaeute=on
'looktab Heiztabelle,min(tmp1,solltemp),tmpw
'if istzeit>830 and istzeit<931 and autoheizen=off then sollzeit=930-tmpw
'if istzeit>930 and istzeit<1030 and autoheizen=off then sollzeit=1020-tmpw
'if istzeit>1080 and istzeit<1351 and autoheizen=off then sollzeit=1350-tmpw
#keinhlabend
if month<>12 or day<>31 then goto keinsylvester                                 'Sylvester
if hour=14 and minute=0 then k3=on
if hour=14 and minute=5 then k3=off
if hour=14 and minute=0 and second=6 then k2=on
if hour=14 and minute=5 then k2=off
if hour=17 and minute=30 then k1=on
if hour=17 and minute=33 then k1=off
if hour=17 and minute=55 then Gelaeute=on
'if istzeit=950 and autoheizen=off then sollzeit=1050-tmpw
#keinsylvester

'Geläute...
if Gelaeute=on then k3= on                                                      'Glocke1 ein
if timer4>5 and Gelaeute=on then k2= on                                         'Glocke2 ein
if timer4>11 and Gelaeute=on then k1= on                                         'Glocke3 ein
if timer4>300 then Gelaeute=off
if Gelaeute=off and timer4>0 then LEDS=LEDS and &B10001111                      'dann alle aus

'Totenglocke
If timer3run=on and timer3=1 then k3=on                                        'Glocke3 60 sek an
If timer3run=on and timer3=61 then k3=off                         'Glocke3 30 sek aus
If timer3run=on and timer3=91 then k3=on                         'Glocke3 60 sek an
If timer3run=on and timer3=151 then k3=off                       'Glocke3 30 sek aus
If timer3run=on and timer3=181 then k3=on                        'Glocke3 60 sek an
If timer3run=on and timer3>240 then k3=off                                      'Glocke3 aus
If timer3run=on and timer3>240 then timer3run=off                               'Timer stoppen

'Nachfolgend die Heizungsregelung
if istzeit>sollzeit then autoheizen=on
'if istzeit>(sollzeit+tmpw) then timer2run=on
if autoheizen=on then sollzeit=1439
if VUGlocke=off and k1=off then pause 5
if VUGlocke=off and k1=off then timer1run=on '  <-- hier die vaterunserglocke abfragen und nachlaufzeit starten
if timer1>10 then autoheizen=off             '       Abfragen der Nachlaufzeit
if autoheizen=off then timer1run=off         'nach Ablauf timerrunbit zurücksetzen
if timer2>90 then autoheizen=off             'maximale Heizzeit für autobetrieb(ohne Vorheizen)
if timer2>180 then handheizen=off            'maximale Heizzeit für Handbetrieb
'
if (handheizen=off) and (autoheizen=off) then goto nichtheizen 'or tmpw if TEMP if TEMP>solltemp then k4=off
goto endeheizregler
#nichtheizen
k4=off
timer2run=off
timer1run=off
#endeheizregler

EXTPORT=LEDS
gosub DS1631CONVERT
#WAIT_READY
Gosub DS1631GET_STATUS
if (DATA and &H80)=0 then goto WAIT_READY
gosub DS1631GET_TEMP


if (TEMP and &H8000) = &H8000 then goto NEGTEMP
TEMP=TEMP shr 7:goto show
#NEGTEMP TEMP=(TEMP shr 7) or &HFE00
#show
print"#ON_LCD#";"#L101#";
on dow gosub error,mo,di,mi,do,fr,sa,so
if dow=0 then goto keindatum
tmp1=day : gosub fprint : print".";
tmp1=month : gosub fprint : print" ";
#keindatum
tmp1=hour : gosub fprint : print":";
tmp1=minute : gosub fprint : print":";
tmp1=second : gosub fprint
'Temperatur anzeigen

print"#L210#";'"Temp:";
gosub tempanzeige
print "#L201#";
'print sollzeit;" ";
'gosub solltempanzeige
if handheizen=on then print"H"; else print" ";
if autoheizen=on then print"A"; else print" ";
print " ";timer2;"  ";
if timer3>0 then print " ";timer3;"  ";
if timer4>0 then print" ";timer4;"  ";
print "#OFF#";
if ((minute and 4)=4)and second=59 then LIGHT=on
goto LOOP
'IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
'Wochentag...
#error
print "warte...";
return
#mo
print "Mo";
return
#di
print "Di";
return
#mi
print "Mi";
return
#do
print "DO";
return
#fr
print "Fr";
return
#sa
print "Sa";
return
#so
print "So";
return


'IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
'IIIIIII  DEMO ZUM BASIC-COMPUTER UNIT M 1.2/2.0 (by DIE HARD)  IIIII
'IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
'--------------------------------------------------------------------
' Beispiel zum BASIC-COMPUTER    mit dem Programmer/Application-Board
'--------------------------------------------------------------------
' ANWENDUNG:         IIC_BUS - TEMPERATURSENSOR (xxxxxx)
'                    TEMPERATUR DS1631 AM IIC-BUS-BUS ABFRAGEN
'
'--------------------------------------------------------------------
' Eine kleine DEMO welchedie TEMPERATUR eines DS1631 am IIC-BUS abfragt

' Beschreibung:
' Der DS1631 wird angesprochen indem zunächst die START-Bedingung und
' danach die ADRESSE zusammen mit dem READ/WRITE-Bit gesendet wird.
' Die Adresse besteht aus einem festen, nicht veränderbaren Anteil und
' einem vom Benutzer wählbaren Teil (drei Jumper). Das letzte Bit
' legt fest ob eine READ (Eingabe) oder WRITE (Ausgabe) über den PCF 8574
' erfolgt
' Es ist nur die Schreibadresse als Konstante definiert, die Leseadresse
' berechnet der Treiber zu Schreibadresse+1
' In diesem Beispiel hat der DS1631 die Adresse 7 (alle Bits auf HI)
' d.h. alle Jumper müssen abgezogen sein.
' Damit ergibt sich für eine READ-Operation folgender Wert:
'
' 1 0 0 1 1 1 1 1       READ-Operation ADR 159
' I------I-----I-I
' FIX ADR  ADR  R/W
'
' Für eine WRITE-Operation ist das letzte Bit LO und es ergibt sich
' folgender Wert:
'
' 1 0 0 1 1 1 1 0       WRITE-Operation ADR 158
' I------I-----I-I
' FIX ADR  ADR  R/W
'-----------------------------------------------------------------------
'Programm:
'Das Unterprogramm DS1631GET_TEMP liefert in TEMP einen 9 Bit-Wert,
'der allerdings linksbündig verschoben ist. Für eine richtige Anzeige
'ist eine entsprechende Korrektur notwendig. Diese 9 Bit liefern eine
'Auflösung von 0.5 Grad.
'Das Programm liset den DS 1631 im "ONE SHOT" Modus, d.h. der Sensor ist
'nur während der Temperaturwandlung/Übertragung Strom (1mA). Sonst beträgt
'die Stromaufnahme des Sensor selbst < 1uA
'Die Demo ist im neg. Temperaturbereich nicht getestet.
'------------------------------------------------------------------------
'IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
'IIIII             DS1631  DRIVER                 III
'IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII

'------------------   DS1631 RESET  ------------------
#DS1631RESET
print"#ON_IIC#";"#START#";:put DS1631:put RESET:print"#STOP#";"#OFF#";
goto IIC_STATUS
'------------------   DS1631 CONVERT ------------------
#DS1631CONVERT
print"#ON_IIC#";"#START#";:put DS1631:put CONVERT:print"#STOP#";"#OFF#";
goto IIC_STATUS
'----------------- GET DS1631 STATUS -----------------
#DS1631GET_STATUS
print"#ON_IIC#";"#START#";:put DS1631:put CONFIG:print"#STOP#";"#OFF#";
print"#ON_IIC#";"#START#";:put DS1631+1:get DATA:print"#STOP#";"#OFF#";
goto IIC_STATUS
'----------------- WRITE DS1631 STATUS -----------------
#DS1631WRITE_STATUS
print"#ON_IIC#";"#START#";:put DS1631:put CONFIG:put DATA:print"#STOP#";"#OFF#";
goto IIC_STATUS
'----------------- GET DS1631 TEMPERATURE -----------------
#DS1631GET_TEMP
print"#ON_IIC#";"#START#";:put DS1631:put READ_TEMP:print"#STOP#";"#OFF#";
print"#ON_IIC#";"#START#";:put DS1631+1:get TEMPHI:get TEMPLO:print"#STOP#";"#OFF#";
goto IIC_STATUS
'-----------------------------------------------------
'----- CONFIG REGISTER ABFRAGE UND ERROR CLEAR -------
'-----------------------------------------------------
#IIC_STATUS
print"#ON_CONFIG#";        'UMLEITUNG ZUM CONFIG MODULE
get SCONFIG                 'CONFIG REGISTER LESEN
put (SCONFIG and &B10111111)'IIC ERROR FLAG IN CONFIG LÖSCHEN
print"#OFF#";
if (SCONFIG and &B01000000)>0 then LIGHT=on
return


#tempanzeige
if (TEMP>=0)and (abs(TEMP)<200) then print" ";'Leerzeichen für rechtsbündige Anordnung
if abs(TEMP)<20 then print" ";                'Leerzeichen für rechtsbündige Anordnung
if TEMP= -1 then print"-";                  ' Bei -0,5C ein Minuszeichen reinpfuschen weil 0 eine positive zahl ist
print TEMP/2;".";(TEMPLO and 1)*5;:put 223:print"C ";  'Tempwert/2 dann . und letztes Bit*5 und ° und C ins LCD
return

#solltempanzeige
if (solltemp>=0)and (abs(solltemp)<200) then print" ";'Leerzeichen für rechtsbündige Anordnung
if abs(solltemp)<20 then print" ";                'Leerzeichen für rechtsbündige Anordnung
if solltemp= -1 then print"-";                  ' Bei -0,5C ein Minuszeichen reinpfuschen weil 0 eine positive zahl ist
print solltemp/2;".";(solltemp and 1)*5;:put 223:print"C";  'Tempwert/2 dann . und letztes Bit*5 und ° und C ins LCD
return


#fprint
if tmp1<10 then print "0";
print tmp1;
return

#KEYDECODE
if ADC8>9 then goto knopfgedrueckt               'wenn adc größer 9 dann ist ein knopf gedrückt
keycode=255:knopf=off                           'ansonsten keycode auf 255 und flag auf 0
return
#knopfgedrueckt
LIGHT=off
if keycode<255 then knopf=on                    'wenn hier schon keycode dann war schon gedrückt gewesen
keycode=0:if abs(17-ADC8)<5 then return
keycode=1:if abs(33-ADC8)<5 then return
keycode=2:if abs(50-ADC8)<5 then return
keycode=3:if abs(66-ADC8)<5 then return
keycode=4:if abs(82-ADC8)<5 then return
keycode=5:if abs(98-ADC8)<5 then return
keycode=6:if abs(114-ADC8)<5 then return
keycode=7:if abs(130-ADC8)<5 then return
keycode=8:if abs(147-ADC8)<5 then return
keycode=9:if abs(164-ADC8)<5 then return
keycode=10:if abs(181-ADC8)<5 then return'CLR
keycode=11:if abs(199-ADC8)<5 then return'ENTER
keycode=12:if abs(218-ADC8)<5 then return'F1
keycode=13:if abs(236-ADC8)<5 then return'F2
keycode=255:return

table Heiztabelle
100 98 96 94 92 90 88 86 84 82 80 78 76 74 72 70 68 66 64 62
60 58 56 54 52 50 48 46 44 42 40 38 36 34 32 30 28 26 24 22
20 18 16 14 12 10 8 6 4 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
tabend

 Antwort schreiben

Bisherige Antworten:

Re: immernoch fehler (von Yazo - 14.11.2005 14:25)
    Re: immernoch fehler (von Andreas Krieger - 14.11.2005 18:51)
        Re: immernoch fehler (von Thomas Wulf - 15.11.2005 12:22)
            Re: immernoch fehler (von Andreas Krieger - 15.11.2005 20:40)
                Re: immernoch fehler (von michi - 16.11.2005 12:09)
                Re: immernoch fehler (von Thomas Wulf - 16.11.2005 8:57)
                    Re: immernoch fehler (von Andreas Krieger - 16.11.2005 19:33)
                       Re: immernoch fehler (von Thomas Wulf - 17.11.2005 9:43)
Re: immernoch fehler (von Topmail - 13.11.2005 13:35)
    Re: immernoch fehler (von Andreas Krieger - 13.11.2005 14:08)
        Re: immernoch fehler (von Andreas Krieger - 13.11.2005 14:23)