DCF-Empfang und softclock mit einem beliebigen timer realisieren
Diese Seite verwendet Cookies. Durch die Nutzung unserer Seite erklären Sie sich damit einverstanden, dass wir Cookies setzen. Weitere Informationen
Aufgrund technischer Veränderungen ist der Mailverkehr innerhalb des Forums (Private Nachrichten) nur noch eingeschränkt möglich. Die Einschränkung ist notwendig, um zusätzliche Betriebskosten für das Forum zu vermeiden. Näheres zu den Hintergründen im Thread "Aktuelles zum Forum".Wir bitten um Verständnis.
Hinweis kann nach Kenntnisnahme deaktiviert werden!
-
-
Um einige Sachen besser und sparsamer zu schreiben hatte ich vor Kurzem mir die Bascom - DCF77-Lib
Comment = Dcf77 Library
Libversion = 1.04
Date = 27 April 2007
mal auf den Tisch gezogen.
Quellcode
- $regfile = "m328pdef.dat"
- $crystal = 16000000
- $hwstack = 128
- $swstack = 128
- $framesize = 128
- $baud = 19200
- '########################
- Config Dcf77 = Pind.2 , Timer = 1 , Inverted = 1, Timer1sec = 1 , Check = 2 , update = 0 'spaeter update = 2
- Enable Interrupts
- Config Date = Dmy , Separator = .
- Dim I As Integer
- Dim Sec_old As Byte , Dcfsec_old As Byte
- Sec_old = 99
- Dcfsec_old = 99
- '########################
- Config Portd.2 = Input 'dcf77 Empfaenger
- Config Portd.1 = Output 'Display 20 x 1, UART Hardware
- Config Com1 = Dummy , Synchrone = 0 , Parity = Even , Stopbits = 2 , Databits = 8
- Waitms 50
- Config PORTC.3 = Output ' LED
- Dim status_byte_old As Byte
- Dim status_byte_new As Byte
- '########################
- Dim Position As Byte
- Dim Zeichen As Byte
- Dim Text As String * 20
- Dim Text_20 As String * 20
- Dim Textarray(20) As Byte At Text_20 Overlay
- Dim Leertext As String * 20
- Leertext = " "
- Dim A As Byte
- Declare Sub Text_drucken(byval Text As String , Position As Byte )
- Declare Sub _cleardisplay()
- Declare Sub _startdisplay()
- _startdisplay
- _cleardisplay
- Open "com1:" For Binary As #1 'zum Display
- Waitms 20
- ' #######################
- Do
- For I = 1 To 78
- Waitms 10
- If Sec_old <> _sec Then
- Exit For
- End If
- If Dcfsec_old <> Dcf_sec Then
- Exit For
- End If
- Next
- Waitms 100
- Sec_old = _sec
- Dcfsec_old = Dcf_sec
- '-------------------------
- Text = Time$
- Position = 00
- Text_drucken Text , Position
- Text = Date$
- Position = 9
- Text_drucken Text , Position
- Text = " "
- Position = 18
- Text_drucken Text , Position
- '--------------------------
- if dcf_status.7 = 1 then
- else
- end if
- '----------------------------
- status_byte_new = dcf_status.2
- if dcf_status.2 = 0 then
- if status_byte_old <> status_byte_new then
- set PORTC.3 ' kurz blinken
- waitms 50 ' wenn das Telegramm fehlerfrei und plausibel war
- reset PORTC.3 ' und zum Stellen der Uhr genutzt wurde
- end if
- end if
- status_byte_old = status_byte_new
- '-----------------------------
- Loop
- Close #1 'zum Display
- ' #########################################################
- Sub Text_drucken(byval Text As String , Position As Byte )
- Text_20 = Text
- Printbin #1 , &H1B;
- Printbin #1 , &H48;
- Printbin #1 , Position;
- For A = 1 To Len(text_20)
- Zeichen = Textarray(a)
- Printbin #1 , Zeichen;
- Next A
- End Sub
- Sub _startdisplay()
- Printbin #1 , &H1B;
- Printbin #1 , &H4C;
- Printbin #1 , &H19;
- End Sub
- Sub _cleardisplay()
- Printbin #1 , &H00;
- Printbin #1 , &H0E;
- Printbin #1 , &H0C;
- End Sub
- ' #########################################################
Überrascht wie schön und sauber das ging, wollte ich mich schon zurücklehnen.
... aber mit fehlt ja noch etwas.
Wo finde ich den "Wochentag"?
Noch etwas Platz auf dem Display wollte ich noch (Mo, Di, Mi, Do, Fr, Sa oder So) ans Ende hängen.
Ich löse mir die Infos dazu gerne aus irgendeinem Byte.
Dass es funktioniert, hatte ich schon zu Fuß erkundet vor Jahren.
In den Ticks 42-44 werden sie ja mitgesendet.
Danke für sachdienliche Hinweise
gruß
port -
port schrieb:
Wo finde ich den "Wochentag"?
Noch ne Frage zu deinem Code.
Was mach das "Close" in Zeile 115?
Die Code-Abarbeitung kommt ja nie an diese Stelle! -
@Mitch64
Danke Mitch64,
das werde ich versuchen.
Die "close-Zeile" schleppe ich schon ewig mit rum an der gleichen Stelle.
Das gehört zu dem "UART" ( Display) und ich habe das auch des Öfteren zwischen "Loop" und "end" gesehen.
... hat immer so funktioniert - ich habe es schon aufgegeben, dabei eine Logik zu suchen/finden.
Danke!
MfG
port -
IMG_20230504_155636.jpg
@Mitch64
Dein Hinweis hat mich in die Hilfe von MCS geführt.
(AN #181 - demonstrating the DCF77 and I2C)
Dort konnte ich passende Teile dafür finden.
Quellcode
- $regfile = "m328pdef.dat"
- $crystal = 16000000
- $hwstack = 128
- $swstack = 128
- $framesize = 128
- $baud = 19200
- '########################
- Config Dcf77 = Pind.2 , Timer = 1 , Inverted = 1, Timer1sec = 1 , Check = 2 , update = 0 'spaeter update = 2
- Enable Interrupts
- Config Date = Dmy , Separator = .
- Dim I As Integer
- Dim Sec_old As Byte , Dcfsec_old As Byte
- Sec_old = 99
- Dcfsec_old = 99
- '########################
- Config Portd.2 = Input 'dcf77 Empfaenger
- Config Portd.1 = Output 'Display 20 x 1, UART Hardware
- Config Com1 = Dummy , Synchrone = 0 , Parity = Even , Stopbits = 2 , Databits = 8
- Waitms 50
- Config PORTC.3 = Output ' LED
- Dim status_byte_old As Byte
- Dim status_byte_new As Byte
- Dim Strweekday As String * 2
- Dim Bweekday As Byte
- '########################
- Dim Position As Byte
- Dim Zeichen As Byte
- Dim Text As String * 20
- Dim Text_20 As String * 20
- Dim Textarray(20) As Byte At Text_20 Overlay
- Dim Leertext As String * 20
- Leertext = " "
- Dim A As Byte
- Declare Sub Text_drucken(byval Text As String , Position As Byte )
- Declare Sub _cleardisplay()
- Declare Sub _startdisplay()
- _startdisplay
- _cleardisplay
- Open "com1:" For Binary As #1 'zum Display
- Waitms 20
- ' #######################
- Do
- For I = 1 To 78
- Waitms 10
- If Sec_old <> _sec Then
- Exit For
- End If
- If Dcfsec_old <> Dcf_sec Then
- Exit For
- End If
- Next
- Waitms 100
- Sec_old = _sec
- Dcfsec_old = Dcf_sec
- '-------------------------
- Text = Time$
- Position = 00
- Text_drucken Text , Position
- Text = Date$
- Position = 9
- Text_drucken Text , Position
- Bweekday = Dayofweek()
- Strweekday = Lookupstr(bweekday , Weekdays)
- Text = Strweekday
- Position = 18
- Text_drucken Text , Position
- '----------------------------
- status_byte_new = dcf_status.2
- if dcf_status.2 = 0 then
- if status_byte_old <> status_byte_new then
- set PORTC.3 ' kurz blinken
- waitms 50 ' wenn das Telegramm fehlerfrei und plausibel war
- reset PORTC.3 ' und zum Stellen der Uhr genutzt wurde
- end if
- end if
- status_byte_old = status_byte_new
- '-----------------------------
- Loop
- Close #1 'gehoert zu "Open "com1:" For Binary As #1" / mein Display
- End
- ' #########################################################
- Sub Text_drucken(byval Text As String , Position As Byte )
- Text_20 = Text
- Printbin #1 , &H1B;
- Printbin #1 , &H48;
- Printbin #1 , Position;
- For A = 1 To Len(text_20)
- Zeichen = Textarray(a)
- Printbin #1 , Zeichen;
- Next A
- End Sub
- Sub _startdisplay()
- Printbin #1 , &H1B;
- Printbin #1 , &H4C;
- Printbin #1 , &H19;
- End Sub
- Sub _cleardisplay()
- Printbin #1 , &H00;
- Printbin #1 , &H0E;
- Printbin #1 , &H0C;
- End Sub
- ' #########################################################
- Weekdays:
- Data "Mo" , "Di" , "Mi" , "Do" , "Fr" , "Sa" , "So"
- '---
Danke nochmal!
MfG
port -
port schrieb:
Wo finde ich den "Wochentag"?
-
@Pluto25
Danke Pluto25,
ich habe mal die Zeilen testweise ausgetauscht - es scheint auch zu funktionieren.
Dass diese Variante (nach der Synchronisation) so ohne Änderung jetzt "Fr" anzeigt, ist bestimmt ein kleines Ding.
Wahrscheinlich fängt die eine Variante bei "0" und die andere Variante bei "1" an zu zählen oder so.
Quellcode
- '--------------------------------
- Dim Strweekday As String * 2
- Dim Bweekday As Byte
- Bweekday = _weekday 'Variante 1
- 'Bweekday = Dayofweek() 'Variante 2
- Strweekday = Lookupstr(bweekday , Weekdays)
- Text = Strweekday
- Position = 18
- Text_drucken Text , Position
- Weekdays:
- Data "Mo" , "Di" , "Mi" , "Do" , "Fr" , "Sa" , "So"
- '--------------------------------
Aber es würde wohl auch funktionieren!
Danke!
MfG
port