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 

 Programm hängt sich beim speichern in voller datei auf Kategorie: Programmierung Basic (von mibr85 - 9.09.2005 11:53)
mibr85 nutzt:  CC1-Unit V1.1
hi
habe mein steuerprogramm fertig mit speicher lcd ausgabe und allem was ich will.
beim probelauf passiert folgendes der counter zählt jeden speicher eintrag, wenn der nun bei 684 ist hängt sich das programm auf und läst sich weder nach reset noch nach aus und einschalten neu starten.
muss das programm erst wieder neu draufspielen.
WORAN liegt das?????????????????

DANKEschon mal für eure hilfe


hier der quellcode:

define Clock Port[1] 'Serial clock input für SHT75
define Data Port[2] 'Serial data für SHT75

define DS Port[3] 'DATA IN für Relaisplatine
define SH Port[4] 'Shift CLK für Relaisplatine
define ST Port[5] 'Stotre CLK für Relaisplatine

define Tür port[6] 'Türschalter auf/zu
define Licht port[7] 'Lichtstatus an/aus
define key port[8] 'Frei

define lcd_rs port[14] 'LCD-Port
define lcd_rw port[13] 'LCD-Port
define lcd_e port[15] 'LCD-Port
define lcd_port byteport[2] 'LCD-Port


'Variablen Sensor
define tempW word[1] 'Überlappung mit Byte 1 & 2 !!!!
define temp  byte[1] 'temporäres Datenbyte
define temp2 byte[2] 'temporäres Datenbyte
define i     byte[3]
define ack   byte[4]
define dataW   word[3]
define dataWhi byte[5]
define dataWlo byte[6]
define Temperatur word[4]
define Feuchte word[5]
define tempW2  word[6]
'Variablen Relaisplatine
define rel byte[13] 'Byte-Puffer für rel1 bis rel8
define rel1 bit[97] 'Relais 1
define rel2 bit[98] 'Relais 2
define rel3 bit[99] 'Relais 3
define rel4 bit[100] 'Relais 4
define rel5 bit[101] 'Relais 5
define rel6 bit[102] 'Relais 6
define rel7 bit[103] 'Relais 7
define rel8 bit[104] 'Relais 8
define rn byte[14] 'Relaisnummer


define aktzeit Word[9]

define count word[8]
define value word[12]

define vrel1 bit[185] 'Relais 1
define vrel2 bit[186] 'Relais 2
define vrel3 bit[187] 'Relais 3
define vrel4 bit[188] 'Relais 4
define vrel5 bit[189] 'Relais 5
define vrel6 bit[190] 'Relais 6
define vrel7 bit[191] 'Relais 7
define vrel8 bit[192] 'Relais 8

define lastmin byte[19]

define lcd_buf byte[20]
define lcd_param byte[21]

'*** ASCII-Codes ***
define LEERZ &H20
define NULL &H30
define DOPPELPUNKT &H3A
define KOMMA &H2C
define GRAD &H27
define C &H43
define PUNKT &H2E
define PROZENT &H25

'_____________________________________PROGRAMM______________________________________________________________

gosub SHTinit
gosub LCD_INIT
count = 0
open# for write 'Datei ruecksetzen
close#
rel=0
lastmin = 0

'____________________________________________TEMPERATURSENSOR________________________________________________________

#messen
 Temperatur = SHTgettemp
 Feuchte = SHTgethyg
 put 12
 print "Temperatur:",
 print Temperatur/100;",";abs((Temperatur/10))mod 10;abs(Temperatur mod 10);"°C"
 print "Feuchte: ",
 if Feuchte>=0 then print Feuchte/10;",";Feuchte mod 10;"%rH" else print "Fehler"
 print minute; ":"; second
 print "count=";
 print count

 pause 50




#Lüfter 'OK
 rel5=off
 rel6=off
 rel7=off
 rel8=off
 if temperatur >2700 then gosub r8
 if temperatur >2600 and temperatur <=2700 then gosub r7
 if temperatur >2500 and temperatur <=2600 then gosub r6
 if temperatur <=2500 then gosub r5



#Heizer 'OK
 if temperatur >= 2200 then gosub r2aus
 if temperatur <= 1700 then gosub r2




#Befeuchter 'OK
 if feuchte >= 800 then gosub r3aus
 if feuchte <= 750 then gosub r3



#LichtTimer 'OK
 rel1=off
 aktzeit = hour *100 + minute
 if  aktzeit >=0300 and aktzeit <2100 then gosub r1

#WasserTimer 'OK
 rel4=off
 aktzeit = hour *100 + minute
 if  (aktzeit >=0800 and second > 20) and (aktzeit <0801 and second < 30) then gosub r4
 if  (aktzeit >=1800 and second > 20) and (aktzeit <1801 and second < 30) then gosub r4

goto next


 #r1
  rel1=on
 return
 #r2
  rel2=on
 return
 #r2aus
  rel2=off
 return
 #r3
  rel3=on
 return
 #r3aus
  rel3=off
 return
 #r4
  rel4=on
 return
 #r5
  rel5=on
 return
 #r6
  rel6=on
 return
 #r7
  rel7=on
 return
 #r8
  rel8=on
 return

#next
 gosub shift
 pulse ST
 gosub WRITETIME
 gosub speichern
goto messen










#shift 'Routine zum seriellen Senden der Daten zur Scheiberegistererweiterung
 for rn=7 to 0 step -1
  DS=(rel shr rn) and 1
  pulse SH
 next
return



#speichern
 #zeitprüfung
 if minute <> lastmin then gosub speicher 'minute mod 2 = 0 and  wenn Minute voll und in dieser Sekunde nicht schon geschrieben
 lastmin = minute
#auslesen
  if not key then gosub dump  'wenn Taste gedrueckt, dann ausgeben
goto end

#speicher 'messen und speichern
  open# for append
  if filefree then goto printer else goto filefull
  #printer
   print#  day
   print#  hour
   print#  minute
   print#  Temperatur
   print#  Feuchte
   print#  rel
  close#
  count = count + 1
return

#filefull
  close#
  goto end


#dump' Messwerte ausgeben
  count = 0
  print "Uhrzeit", " Temperatur", "Feuchte ";"LHBP5678"
  open# for read

#dumpnext
  if eof then goto löschen

  input# value
  if value>9 then print value;" "; else print "0";value;" ";
  input# value
  if value>9 then print value;":"; else print "0";value;":";
  input# value
  if value>9 then print value;" "; else print "0";value;" ";
  input# value
  print value/100;",";abs((value/10))mod 10;abs(value mod 10);"°C",
  input# value
  print value/10;",";value mod 10;"%rH",
  input# value
  print ABS(vrel1);ABS(vrel2);ABS(vrel3);ABS(vrel4);ABS(vrel5);ABS(vrel6);ABS(vrel7);ABS(vrel8)
goto dumpnext

#löschen
 open# for write 'Datei ruecksetzen
 close#

#end
return

#WRITETIME
 lcd_param = 1 : gosub LCD_GOTOLINE
 lcd_param = NULL+Temperatur/1000 : gosub LCD_WRITECHAR
 lcd_param = NULL+(Temperatur mod 1000)/100 : gosub LCD_WRITECHAR
 lcd_param = KOMMA : gosub LCD_WRITECHAR
 lcd_param = NULL+(Temperatur mod 100)/10: gosub LCD_WRITECHAR
 lcd_param = NULL+Temperatur mod 10 : gosub LCD_WRITECHAR
 lcd_param = GRAD : gosub LCD_WRITECHAR
 lcd_param = C : gosub LCD_WRITECHAR
 lcd_param = LEERZ : gosub LCD_WRITECHAR

 lcd_param = NULL+Feuchte/100 : gosub LCD_WRITECHAR
 lcd_param = NULL+(Feuchte mod 100)/10 : gosub LCD_WRITECHAR
 lcd_param = KOMMA : gosub LCD_WRITECHAR
 lcd_param = NULL+Feuchte mod 10: gosub LCD_WRITECHAR
 lcd_param = PROZENT : gosub LCD_WRITECHAR

 lcd_param = 2 : gosub LCD_GOTOLINE
 lcd_param = NULL + hour / 10 : gosub LCD_WRITECHAR
 lcd_param = NULL + hour mod 10 : gosub LCD_WRITECHAR
 lcd_param = DOPPELPUNKT : gosub LCD_WRITECHAR
 lcd_param = NULL + minute / 10 : gosub LCD_WRITECHAR
 lcd_param = NULL + minute mod 10 : gosub LCD_WRITECHAR
 lcd_param = LEERZ : gosub LCD_WRITECHAR

 lcd_param = NULL + day / 10 : gosub LCD_WRITECHAR
 lcd_param = NULL + day mod 10 : gosub LCD_WRITECHAR
 lcd_param = PUNKT : gosub LCD_WRITECHAR
 lcd_param = NULL + month / 10 : gosub LCD_WRITECHAR
 lcd_param = NULL + month mod 10 : gosub LCD_WRITECHAR
 lcd_param = PUNKT : gosub LCD_WRITECHAR
 lcd_param = LEERZ : gosub LCD_WRITECHAR

 lcd_param = NULL+count/100 : gosub LCD_WRITECHAR
 lcd_param = NULL+(count mod 100)/10: gosub LCD_WRITECHAR
 lcd_param = NULL+count mod 10 : gosub LCD_WRITECHAR
return


#SHTinit
 deact Data
 Clock = 0
 for i=0 to 10 pulse Clock
return

#SHTstart
 Clock =-1
 Data  = 0
 Clock = 0
 Clock =-1
 deact Data
 Clock = 0
return

#SHTwrite
 for i=0 to 7
  if (temp shl i) and &h80 then deact Data else Data = 0
  pulse Clock
 next i
 deact Data
 Clock = -1
 temp=(Data=0)
 Clock =0
return temp

#SHTread
 temp=0
 for i=0 to 7
  Clock =-1
  temp=(temp shl 1) or (Data and 1)
  Clock = 0
 next i
 if ack then Data = 0 else deact Data
 pulse Clock
 deact Data
return temp

#SHTreadint
 tempW = timer
 #SHTwloop
  if timer-tempW>=50 then return &hF000
 if Data then goto SHTwloop
 ack = 1
 dataWhi=SHTread 'High-Byte
 ack = 0
 dataWlo=SHTread 'Low-Byte
return dataW

#SHTgettemp
 gosub SHTstart
 temp = &b00011 : gosub SHTwrite
 dataW = SHTreadint-4000
return dataW

#SHTgethyg
 gosub SHTstart
 temp = &b00101 : gosub SHTwrite
 Feuchte=SHTreadint
 if Feuchte and &h8000 then return -1
 tempW = Feuchte shr 4
 i = Feuchte mod 16
 looktab shtab,tempW,tempW2
 tempW = tempW - 1
 looktab shtab,tempW,tempW
 tempW2 = ((tempW2 - tempW) * i) shr 4
 Feuchte = tempW + tempW2
return Feuchte

table shtab "sht.tab"

'------------------------------LCD----------------------

#LCD_INIT

' alle ports 0
  lcd_port = OFF

' 8-Bit-Modus aktivieren
  lcd_param=&H38 : gosub LCD_WRITECMD

' mit 8-Bit-Command in 4-Bit-Modus umschalten
  lcd_port=&B00000010
  tog lcd_e
  tog lcd_e

' ab jetzt 4-Bit-Modus
  lcd_param = &H28 : gosub LCD_WRITECMD
  lcd_param = &H0C : gosub LCD_WRITECMD

' Display loeschen
#LCD_CLS
  lcd_param = &H02 : gosub LCD_WRITECMD
  lcd_param = &H01 : gosub LCD_WRITECMD
return

' Zeilenwechsel
#LCD_GOTOLINE
  if lcd_param = 1 then lcd_param = &H80
  if lcd_param = 2 then lcd_param = &HC0
  goto LCD_WRITECMD

' LCD-Kommando
#LCD_WRITECMD
  lcd_buf = OFF
  goto LCD_WRITE

' Zeichenausgabe
#LCD_WRITECHAR
  lcd_buf = &B00100000

' Kommando oder Zeichen an Display senden
#LCD_WRITE
  lcd_port = lcd_buf or (lcd_param shr 4) ' Hi-Nibble
  tog lcd_e
  tog lcd_e
  lcd_port = lcd_buf or (lcd_param and &H0F)  ' Lo-Nibble
  tog lcd_e
  tog lcd_e
return


 Antwort schreiben

Bisherige Antworten:

Re: Programm hängt sich beim speichern in voller datei auf (von Achim - 9.09.2005 12:17)
    Re: IF..THEN..ELSE (von Dietmar - 12.09.2005 16:12)
        Re: IF..THEN..ELSE (von Achim - 12.09.2005 17:40)
Re: Programm hängt sich beim speichern in voller datei auf (von Dierk - 9.09.2005 11:58)
    Re: Programm hängt sich beim speichern in voller datei auf (von mibr85 - 9.09.2005 12:18)
        Re: Programm hängt sich beim speichern in voller datei auf (von gerd - 10.09.2005 8:19)
            Re: Programm hängt sich beim speichern in voller datei auf (von mibr85 - 10.09.2005 12:49)
                Re: Programm hängt sich beim speichern in voller datei auf (von Achim - 10.09.2005 13:03)
                    Re: Programm hängt sich beim speichern in voller datei auf (von mibr85 - 10.09.2005 13:38)