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 

 Re: PCF8574AP Kategorie: Programmierung Basic (von Willi aus Oelde - 25.05.2006 14:26)
 Als Antwort auf PCF8574AP von Gerd - 23.05.2006 22:21
Willi aus Oelde nutzt:  CC1-Station V2.0
Hallo Gerd,

1) Ich bin aus 59302 Oelde! Wo wohnst Du denn?
    (evtl. deine Mailadresse als Grafik! (wegen Spam) einfügen)

2) Anbei mal ein Programm bei dem ich in Basic die PCF Bausteine anspreche.
   (Ganz schrecklich programmiert, geht aber seit 7 Jahren!) Ich mache Software
   aber nur noch for die C2 :-)

3) Ich kenne Dein Programm nicht, aber wieso sollte ein PCF xxxxAP Byteport 11-18 sein?
    Du liest oder sendest doch auch Adresse (des PCF/ 64 bis 79 ), Daten an/vom PCF.
   Kann natürlich ein besseres Betriebssystem / Basic hergeben, daß Du direkt einen
   PCF ansprechen kannst ....
 
   Beim AP ist nur die Adresslage anders (112 bis 127). Also wenn Du 8 Bausteine
    8574 am laufen hast, sollten die AP Typen "Peanuts" sein.

Schöne Grüße,
Willi aus Oelde



'Programm : Markiesen_Steuerung_Plus_Texte

' Programm zur Ausgabe von Text auf F&P Display
'      (c) 17.7.2000  Willi aus Oelde
'      Steuerung von Markiesen und Rolladen

Define Adresse      Byte [1]  ' für PCF Maschinenprogramm
Define Daten        Byte [2]  ' für PCF    "

Define Relais1      Byte [3]  ' Als Speicher benötigt für die Ausgänge Board 1
'                               1. Klemme ist Phase Lage: PCF oben/Klemmen unten
Define KitchZu      Bit  [17] ' 4.Relais 5.Klemme von links
Define KitchAuf     Bit  [18] ' 3.Relais 4.Klemme von links
Define Wohn1Auf     Bit  [19] ' 1.Relais 2.Klemme von links
Define Wohn1Zu      Bit  [20] ' 2.Relais 3.Klemme von links
Define WohnFZu      Bit  [21] ' 5.Relais 6.Klemme von links
Define WohnFAuf     Bit  [22] ' 6.Relais 7.Klemme von links
Define WTuerAuf     Bit  [23] ' 8.Relais 9.Klemme von links
Define WTuer1Zu     Bit  [24] ' 7.Relais 8.Klemme von links

Define Relais2      Byte [4]  ' Als Speicher benötigt für die Ausgänge Board 2
Define MarkAuf      Bit  [25] ' auf Richtigkeit geprüft !
Define MarkZu       Bit  [26]
Define Kind1Auf     Bit  [28]
Define Kind1Zu      Bit  [27]
Define ElternAuf    Bit  [29]
Define ElternZu     Bit  [30]
Define Kind2Auf     Bit  [31]
Define Kind2Zu      Bit  [32]

Define Relais1S     Byte [5] ' Als Speicher zum zählen benötigt 0 bis 4 !
Define Relais2S     Byte [6] ' Als Speicher zum zählen benötigt 0 bis 4 !
Define HMerker      Byte [7]
Define Merkerim     Byte [8]

Define TasterKüche  BIT  [57] ' Bits des Bytes 8 / Merkerim!
Define TasterWohn1  BIT  [58]
Define TasterWohn3  BIT  [59]
Define TasterWohn2  BIT  [60]
Define TasterMark   BIT  [61]
Define TasterKind1  BIT  [62]
Define TasterKind2  BIT  [63]
Define TasterEltern BIT  [64]

Define Wert         Byte [9]   ' für Zeichenausgabe
Define Zahl         Byte [10]  ' für Zeichenausgabe
Define Modus        Byte [11]  ' für Auswahl Display
Define Auswahl      Byte [12]  ' für Auswahl Display
Define Auscount     Byte [13]  ' für Ausschaltzähler

Define Schmier      Byte [14]  ' für Bits
Define AutoZu       BIT  [105] ' Bits vom Schmiermerker
Define AutoAuf      BIT  [106]

Define I            Byte [15]  ' für Laufvariable ( zB. Unterprog. Warten )

Define Eingang      Byteport[1]

Define TKüche       Port    [1] ' Hier die Einzelbits
Define TWohn1       Port    [2]
Define TWohn3       Port    [3]
Define TWohn2       Port    [4]
Define TMark        Port    [5]
Define TKind1       Port    [6]
Define TKind2       Port    [7]
Define TEltern      Port    [8]
Define SDA          Port    [9]
Define SCL          Port   [10]
Define Frei         Port   [11]  ' Freier Port ######
Define SerIn        Port   [12]
Define SerClk       Port   [13]
Define XPLoad       Port   [14]
Define SerOut       Port   [15]
Define Enable       Port   [16]

'Hour   = 21 : Minute = 59 : Second = 30

SDA = ON : SCL = ON


' Alle Ports bzw. Relais ausschalten, da keine Pullup - Widerstände !
Relais1=0:Gosub Senden1:Gosub Senden2

Hmerker = 255

Enable  = 0   ' für Fischer und Porter Display !
XPLoad  = 0
SerClk  = 0
SerIn   = 0
DEACT SerOut

Wert= &H38 : Gosub KommandoOut ' Initialisierung mit 2 Zeilen
Wert= &H0E : Gosub KommandoOut ' ok Display an
Wert= &H01 : Gosub KommandoOut ' ok Display weiter schieben
Wert= &H02 : Gosub KommandoOut ' Cursor home

'__________________ HAUPTPROGRAMM _________________________________
#Schleife
Pause 1
Goto Jump1

   Wert = &H02   : Gosub Command  ' Internal Cursor Home
   Zahl = Day    : Gosub Ausg_Zahl2 : Wert=46 : Gosub ZeichenOut ' "."
   Zahl = Month  : Gosub Ausg_Zahl2 : Wert=32 : Gosub ZeichenOut ' Space
   ' Zahl = Year   : Gosub Ausg_Zahl2
   '--- Uhrzeit schreiben
   Zahl = Hour   : Gosub Ausg_Zahl2 : Wert=58 : Gosub ZeichenOut ' ":"
   Zahl = Minute : Gosub Ausg_Zahl2 : Wert=58 : Gosub ZeichenOut ' ":"

   Wert = 142    : Gosub Command    ' ab xx. Stelle 1. Zeile schreiben 128+18 !
   Zahl = Second : Gosub Ausg_Zahl2

   Gosub Test
   Wert = 168    : Gosub Command    ' ab xx. Stelle 2. Zeile schreiben 128+40 !
   Zahl = Auswahl : Gosub Ausg_Zahl2 : Wert=58 : Gosub ZeichenOut ' ":"

#Jump1

'----- Auto "zu" setzen
If ((Hour=20)and(Minute=55)and(Second<3)) then AutoZu=1 Else Goto EndeZu ' _____ Ausschaltzeit

If TKüche then goto Zu1    'Küchentaster 0 = Automatik
Relais1S = (Relais1S and 252)or 2  ' Beim nächsten Schalten hoch
KitchAuf=0:KitchZu=1:Gosub Senden1:Wert=18:Gosub Warten:KitchZu=0:Gosub Senden1

#Zu1
If TWohn1 then goto Zu2    'Wohnzimmertaster1 0 = Automatik
Relais1S = (Relais1S and 247) or 8
Wohn1Auf=0:Wohn1Zu=1:Gosub Senden1:Wert=18:Gosub Warten:Wohn1Zu=0:Gosub Senden1

#Zu2
If TWohn2 then goto Zu3    'Wohnzimmertaster2 0 = Automatik
Relais1S=(Relais1 and 207) or 32
WTuerAuf=0:WTuer1Zu=1:Gosub Senden1:Wert=18:Gosub Warten:WTuer1Zu=0:Gosub Senden1

#Zu3
If TWohn3 then goto Zu4   'Wohnzimmertaster3 0 = Automatik
Relais1S=(Relais1S and 63) or 128
WohnFAuf=0:WohnFZu=1:Gosub Senden1:Wert=28:Gosub Warten:WohnFZu=0:Gosub Senden1

#Zu4
If TKind1 then goto Zu5
Relais2S=Relais2S and 252 ' ??
Kind1Zu=1:Kind1Auf=0:Gosub Senden2:Wert=25:Gosub Warten:Kind1Zu=0:Gosub Senden2

#Zu5
If TKind2 then goto Zu6
Relais2S=Relais2S and 243 ' nicht getestet
Kind2Zu=1:Kind2Auf=0:Gosub Senden2:Wert=20:Gosub Warten:Kind2Zu=0:Gosub Senden2

#Zu6
If TEltern then goto EndeZu
Relais2S=Relais2S and 207 ' nicht getestet
ElternZu=1:ElternAuf=0:Gosub Senden2:Wert=20:Gosub Warten:ElternZu=0:Gosub Senden2

#EndeZu
AutoZu = 0

If ((Hour=10) and (Minute=30)and (Second<3)) then AutoAuf=1 else Goto xx ' _____ Einschaltzeit ___

'Küchentaster abfragen auf geschlossen = Automatik
If TKüche then goto zz
Relais1S = Relais1S and 252
KitchZu=0:KitchAuf=1:Gosub Senden1:Wert=5:Gosub Warten  ' Fahrzeit Auf
KitchAuf=0:Gosub Senden1

#zz
If TWohn1 then goto xx
   Relais1S = Relais1S and 243 ' Beim nächsten Schalten runter !
   Wohn1Zu=0:Wohn1Auf=1:Gosub Senden1:Wert =5:Gosub Warten:Wohn1Auf=0:Gosub Senden1

#xx
'----- Automatik "auf" setzen
If ((Hour=8) and (Minute=30)and (Second<3)) then AutoAuf=1 else Goto EndeAuf ' _____ Einschaltzeit ___

'Küchentaster abfragen auf geschlossen = Automatik
If TKüche then goto Auf
Relais1S = Relais1S and 252
KitchZu=0:KitchAuf=1:Gosub Senden1:Wert=5:Gosub Warten:KitchAuf=0:Gosub Senden1

#Auf
'Wohnzimmertaster abfragen auf geschlossen = Automatik
If TWohn1 then goto Auf1
   Relais1S = Relais1S and 243 ' Beim nächsten Schalten runter !
   Wohn1Zu=0:Wohn1Auf=1:Gosub Senden1:Wert =5:Gosub Warten:Wohn1Auf=0:Gosub Senden1
#Auf1
If TWohn2 then goto Auf2
   Relais1S = Relais1S and 207 ' Beim nächsten Schalten runter !
   WTuer1Zu=0:WTuerAuf=1:Gosub Senden1:Wert=10:Gosub Warten:WTuerAuf=0:Gosub Senden1
#Auf2
If TWohn3 then goto Auf3
   Relais1S = Relais1S and 63 ' Beim nächsten Schalten runter !
   WohnFZu=0:WohnFAuf=1:Gosub Senden1:Wert=30:Gosub Warten:WohnFAuf=0:Gosub Senden1
#Auf3
If TKind1 then goto Auf4
   Relais2S= (254 and Relais2S) or 2 ' Nur Bit 2 setzen Bit1 ausmaskieren
   Kind1Zu=0:Kind1Auf=1:Gosub Senden2:Wert=15:Gosub Warten:Kind1Auf=0:Gosub Senden2
#Auf4
If TKind2 then goto Auf5
   Relais2S=(251 and Relais2S) or 8
   Kind2Zu=0:Kind2Auf=1:Gosub Senden2:Wert=10:Gosub Warten:Kind2Auf=0:Gosub Senden2
#Auf5
If TEltern then goto EndeAuf
   Relais2S=(239 and Relais2S) or 32
   ElternAuf=1:Gosub Senden2:Wert=10:Gosub Warten:ElternAuf=0:Gosub Senden2
#EndeAuf
AutoAuf = 0 ' Nur aus Spass

' ---------- Erste Platine ----------
Merkerim = NOT Eingang AND NOT HMerker ' Impuls bilden
HMerker  = NOT Eingang
Merkerim = NOT Merkerim

'--- Relais nach Zeit spannungslos schalten
If ((Relais1>0) or (Relais2>0))  then Auscount=Auscount+1 Else Auscount=0
If Auscount < 255 then goto Weit

If Relais1 and  48 then TasterWohn3 = 0
If Relais1 and 192 then TasterWohn2 = 0
If Relais1 and  12 then TasterWohn1 = 0
If Relais1 and   3 then TasterKüche = 0

If Relais2 and  48 then TasterEltern= 0
If Relais2 and 192 then TasterKind2 = 0
If Relais2 and  12 then TasterKind1 = 0
If Relais2 and   3 then TasterMark  = 0

#Weit

If TasterKüche then goto Weiter
    If (Relais1S and 3) = 3 then Relais1S = Relais1S and 252 else Relais1S = Relais1S+1
    If (Relais1S and 3) = 0 then KitchAuf =0
    If (Relais1S and 3) = 1 then KitchZu=1
    If (Relais1S and 3) = 2 then KitchZu=0
    If (Relais1S and 3) = 3 then KitchAuf =1
#Weiter

If TasterWohn1 then goto Weiter1
    If (Relais1S and 12) = 12 then Relais1S = Relais1S and 243 else Relais1S = Relais1S+4
    If (Relais1S and 12) = 0  then Wohn1Auf =0
    If (Relais1S and 12) = 4  then Wohn1Zu=1
    If (Relais1S and 12) = 8  then Wohn1Zu=0
    If (Relais1S and 12) = 12 then Wohn1Auf =1
#Weiter1

If TasterWohn2 then goto Weiter2
    If (Relais1S and 48) = 48 then Relais1S = Relais1S and 207 else Relais1S = Relais1S+16
    If (Relais1S and 48) = 0  then WTuerAuf =0
    If (Relais1S and 48) = 16 then WTuer1Zu=1
    If (Relais1S and 48) = 32 then WTuer1Zu=0
    If (Relais1S and 48) = 48 then WTuerAuf =1
#Weiter2

If TasterWohn3 then goto Weiter3
    If (Relais1S and 192) = 192 then Relais1S = Relais1S and 63 else Relais1S = Relais1S+64
    If (Relais1S and 192) = 0   then WohnFAuf =0
    If (Relais1S and 192) = 64  then WohnFZu=1
    If (Relais1S and 192) = 128 then WohnFZu=0
    If (Relais1S and 192) = 192 then WohnFAuf =1
#Weiter3
Gosub Senden1
' --------  2. Platine  -----------------
If TasterKind1 then goto Weiter4
    If (Relais2S and 3) = 3 then Relais2S = Relais2S and 252 else Relais2S = Relais2S+1
    If (Relais2S and 3) = 0 then Kind1Zu =0
    If (Relais2S and 3) = 1 then Kind1Auf=1
    If (Relais2S and 3) = 2 then Kind1Auf=0
    If (Relais2S and 3) = 3 then Kind1Zu =1
#Weiter4

If TasterKind2 then goto Weiter5
    If (Relais2S and 12) = 12 then Relais2S = Relais2S and 243 else Relais2S = Relais2S+4
    If (Relais2S and 12) = 0  then Kind2Zu =0
    If (Relais2S and 12) = 4  then Kind2Auf=1
    If (Relais2S and 12) = 8  then Kind2Auf=0
    If (Relais2S and 12) = 12 then Kind2Zu =1
#Weiter5

If TasterEltern then goto Weiter6
    If (Relais2S and 48) = 48 then Relais2S = Relais2S and 207 else Relais2S = Relais2S+16
    If (Relais2S and 48) = 0  then ElternZu =0
    If (Relais2S and 48) = 16 then ElternAuf=1
    If (Relais2S and 48) = 32 then ElternAuf=0
    If (Relais2S and 48) = 48 then ElternZu =1
#Weiter6

If TasterMark then goto Weiter7
    If (Relais2S and 192) = 192 then Relais2S = Relais2S and 63 else Relais2S = Relais2S+64
    If (Relais2S and 192) = 0   then MarkZu =0
    If (Relais2S and 192) = 64  then MarkAuf=1
    If (Relais2S and 192) = 128 then MarkAuf=0
    If (Relais2S and 192) = 192 then MarkZu =1
#Weiter7
Gosub  Senden2

Goto Schleife

' -------- Kommando out -----------
#KommandoOut
#Command
   XPLoad = 1         ' XPLoad High = Instruction / Nur bei F&P !
   Gosub ZeichenOut
   XPLoad = 0         ' XPLoad Low  = Daten
   Pulse SerClk       '
Return

#Ausg_Zahl2
  Wert=Zahl/10+48 : Gosub Zeichenout
  Wert=Zahl Mod 10+48 ' geht von allein ins return !

' --- Zeichen ins Schieberegister --
#ZeichenOut
       Serin = Wert and 128: Pulse SerClk
       Serin = Wert and 64 : Pulse SerClk
       Serin = Wert and 32 : Pulse SerClk
       Serin = Wert and 16 : Pulse SerClk
       Serin = Wert and 8  : Pulse SerClk
       Serin = Wert and 4  : Pulse SerClk
       Serin = Wert and 2  : Pulse SerClk
       Serin = Wert and 1  : Pulse SerClk
       Pulse Enable      ' Muss zum Übernehmen
       SerIn  = 0        ' SerIn  Low Muss  !!!!
       Pulse Serclk      ' Muss aus irgend welchen Gründen unbedingt sein !
Return

#Test
       If SerOut = 0 then Auswahl = Auswahl+1' Mittlerer Taster
       XPLoad = 1
       Pulse SerClk
       If SerOut = 0 then Modus   =  Modus+1 ' Rechter Taster
       Pulse SerClk
       If SerOut = 0 then Auswahl = Auswahl-1' Linker Taster
       XPLoad = 0
Return

#Warten
  For I=1 to Wert
    Pause 50
  Next I
Return

'#Senden
' Adresse=64:Daten=Relais1:sys &H0101 ' Für I²C-Bus
'Return

#Senden1
  Daten = Relais1
  SDA=OFF   :SCL=OFF
  Wert=64   :gosub IC_Write 'Adresse PCF
  Wert=Daten:gosub IC_Write
  SDA=OFF   :SCL=ON:SDA=ON
return

#Senden2
  Daten = Relais2
  SDA=OFF   :SCL=OFF
  Wert=66   :gosub IC_Write 'Adresse PCF
  Wert=Daten:gosub IC_Write
  SDA=OFF   :SCL=ON:SDA=ON
return

#IC_WRITE
  for I = 1 to 8
    SDA= OFF
    if (Wert AND 128) = 128 then SDA = ON
    pulse SCL
    Wert = Wert shl 1 '1 Bit nach links
  next
  pulse SCL             ' 9. Impuls
return

 Antwort schreiben

Bisherige Antworten:

Re: (von Gerd - 25.05.2006 17:27)
    PCF 8574 A Ansteuerung (von Willi aus Oelde - 26.05.2006 14:17)