Der Nachfolger des WDR-Computerclub mit Wolfgang Back und Wolfgang Rudolph - ...und immer ein Bit übrigbehalten!


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 

 Programmierung Schaltzeiten Kategorie: C-Control I V1.1 (von Andreas - 28.08.2005 18:12)
Andreas nutzt:  CC1-Station V2.0
Hallo Gemeinde,
habe mir für meine C-Conrol I Station 2.0 eine kleine Steuerung zurecht gebaut.
Die Temperaturreglung ist die einzigste die zur Zeit geht.Die Befeuchtung wird auch richtig angesprochen.
Wenn die Zeit ran ist für eine Relaistätigkeit, zieht das Relais kurz an und die Zeit beginnt sich von Null an neu zu stellen!
'-----------------------------------------------------------------------------
'------ I/O PORTS ------------------------------------------------------------
'-----------------------------------------------------------------------------
define ADC8          ad[8]
define LIGHT         port[16]
define SDA           port[9]
define SCL           port[10]
define EXTPORT       byteport[4]
'-----------------------------------------------------------------------------
'---- SYSTEM MEMORY ----------------------------------------------------------
'-----------------------------------------------------------------------------
define TEMP         word              'Variable zur Speicherung der Temperatur        
define STATION_IO   byte[3]
define OLDSEC       byte
define LED1         bit[17]
define LED2         bit[18]
define LED3         bit[19]
define LED4         bit[20]
define REL1         bit[21]           'Heizung
define REL2         bit[22]           'Wärmelampe
define REL3         bit[23]           'UV-Licht
define REL4         bit[24]           'Beregnung
'-----------------------------------------------------------------------------

const DS1631=158                'Adresse Temperatursensor, kein Jumper gesetzt


SDA=on
SCL=on

FUNCTION SHOW_TIME()
if HOUR<10 then LCD.PRINT "0"         'FÜHRENDE NULL SCHREIBEN
LCD.PRINT  HOUR                       'STUNDEN AUSGEBEN
LCD.PRINT ":"                         'TRENNZEICHEN SCHREIBEN
if MINUTE<10 then LCD.PRINT "0"       'FÜHRENDE NULL SCHREIBEN
LCD.PRINT  MINUTE
LCD.PRINT ":"                         'TRENNZEICHEN SCHREIBEN
if SECOND<10 then LCD.PRINT "0"       'FÜHRENDE NULL SCHREIBEN
LCD.PRINT  SECOND
LCD.PRINT "  "
END FUNCTION

'-----------------------------------------------------------------------------
'------------------Initialisierung Display------------------------------------
'-----------------------------------------------------------------------------
LCD.INIT
LIGHT=on
LCD.CLR
'-----------------------------------------------------------------------------
DS1631RESET(DS1631)
DS1631SET_STATUS(DS1631,1)
'-----------------------------------------------------------------------------
'-------- WILLKÜRLICHE VOREINSTELLUNG ----------------------------------------
'-----------------------------------------------------------------------------
FUNCTION PRESET()
hour=23  
minute=59  
second=58
END FUNCTION
'-----------------------------------------------------------------------------
'------- AUF DEN SEKUNDENWECHSEL WARTEN --------------------------------------
'-----------------------------------------------------------------------------
FUNCTION WAITSEC()
do
LOOP UNTIL OLDSEC<>SECOND
OLDSEC=SECOND
END FUNCTION
'-----------------------------------------------------------------------------
'--------------------------
'--- DS1631 COMMANDS ------
'--------------------------
const CONVERT=51h
const STOP_CONVERT=22h
const READ_TEMP=AAh
const CONF=ACh
const RESET=54h

'-----------------------------------------------------
'------------------   DS1631 RESET  ------------------
'-----------------------------------------------------
FUNCTION DS1631RESET(ADDR as byte)
IIC.INIT
IIC.START
IIC.SEND ADDR
IIC.SEND RESET
IIC.STOP
IIC.OFF
END FUNCTION
'-----------------------------------------------------
'------------------   DS1631 CONVERT  ----------------
'-----------------------------------------------------
FUNCTION DS1631CONVERT(ADDR as byte)
IIC.INIT
IIC.START
IIC.SEND ADDR
IIC.SEND CONVERT
IIC.STOP
IIC.OFF
END FUNCTION
'-----------------------------------------------------
'----------------- GET DS1631 STATUS -----------------
'-----------------------------------------------------
FUNCTION DS1631GET_STATUS(ADDR as byte)
define DATA as byte
IIC.INIT
IIC.START
IIC.SEND ADDR
IIC.SEND CONF
IIC.STOP

IIC.START
IIC.SEND (ADDR+1)
IIC.GET DATA
IIC.STOP
IIC.OFF
RETURN DATA
END FUNCTION
'-------------------------------------------------------
'----------------- SET DS1631 STATUS -----------------
'-------------------------------------------------------
FUNCTION DS1631SET_STATUS(ADDR as byte,DATA as byte)
IIC.INIT
IIC.START
IIC.SEND ADDR
IIC.SEND CONF
IIC.SEND DATA
IIC.STOP
END FUNCTION
'-------------------------------------------------------
'----------------- WAIT DS1631 READY   -----------------
'-------------------------------------------------------
FUNCTION DS1631WAIT_READY(ADDR as byte)
#WT
if (DS1631GET_STATUS(ADDR)) and 80h = 0 then goto WT
END FUNCTION
'-----------------------------------------------------
'----------------- GET DS1631 TEMP -----------------
'-----------------------------------------------------
FUNCTION DS1631GET_TEMP(ADDR as byte)
define TEMP as word
define DATA as byte

IIC.INIT
IIC.START
IIC.SEND ADDR
IIC.SEND READ_TEMP
IIC.STOP

IIC.START
IIC.SEND (ADDR+1)
IIC.GET DATA
TEMP=DATA*256
IIC.GET DATA
TEMP=TEMP+DATA
IIC.STOP
IIC.OFF
RETURN TEMP
END FUNCTION

'--------------Alle Ports OFF-------------------------------------------------
STATION_IO=OFF                                       'STANDARD, alle Ports OFF  
EXTPORT=STATION_IO                      'zusätzlich, externen Port beschreiben
'-----------------------------------------------------------------------------


'-----------------------------------------------------------------------------
'----------------------Programmstart------------------------------------------
'-----------------------------------------------------------------------------
#LOOP


'-----------------------------------------------------------------------------
'----------------------Temperaturerfassung------------------------------------
'-----------------------------------------------------------------------------
DS1631CONVERT(DS1631)
DS1631WAIT_READY(DS1631)
TEMP=DS1631GET_TEMP(DS1631)
LCD.INIT switchonly
LCD.POS 2,3                                                'Anzeige Temperatur
TEMP=TEMP SHR 7
if (TEMP and 0100h) = 0100h then TEMP=(TEMP or FE00h)
LCD.PRINT "TEMP: " & TEMP/2 & "." & (TEMP and 1)*5 & " C        "
LCD.POS 1,3
SHOW_TIME()
LCD.OFF
'-----------------------------------------------------------------------------
'---------------------Temperaturreglung---------------------------------------
'-----------------------------------------------------------------------------
if TEMP <= 45 then REL1=on                      'Heizung ein bei unter 23 Grad
EXTPORT=STATION_IO
if TEMP >= 47 then REL1=off                   'Abschaltung Heizung bei 25 Grad                  
EXTPORT=STATION_IO
'-----------------------------------------------------------------------------
'--------------Relais mit Zeitfunktion schalten-------------------------------
'-----------------------------------------------------------------------------
if (hour=18) and (minute=05) then REL3 = on                 'UV-Licht 18:05 an
EXTPORT=STATION_IO
if (hour=22) and (minute=05) then REL3 = off               'UV-Licht 22:05 aus
EXTPORT=STATION_IO
if (hour=11) and (minute=00) then REL2 = on
EXTPORT=STATION_IO
if (hour=13) and (minute=30) then REL2 = off
EXTPORT=STATION_IO

if (hour=08) and (minute=55) then goto BLINK           'Beregnung 08:55 an/aus
if (hour=19) and (minute=30) then goto BLINK           'Beregnung 18:30 an/aus

'-----------------------------------------------------------------------------
'-----------------------------------------------------------------------------
goto LOOP
'-----------------------------------------------------------------------------
#BLINK
REL4 = on              
EXTPORT=STATION_IO
PAUSE 40
REL4 = off
EXTPORT=STATION_IO
PAUSE 105
goto LOOP
'-----------------------------------------------------------------------------

Danke für Eure Hilfe!


 Antwort schreiben

Bisherige Antworten:

Re: Programmierung Schaltzeiten (von Topmail - 29.08.2005 19:31)
Re: Programmierung Schaltzeiten (von Stefan Tappertzhofen - 28.08.2005 18:41)