![]() |
Forum Index : Microcontroller and PC projects : PicoMite DCF77 Decoder
Author | Message | ||||
PilotPirx![]() Regular Member ![]() Joined: 03/11/2020 Location: GermanyPosts: 99 |
I wrote a little DCF77 decoder to get the exact time without having to type it in every time. DCF77 is a time signal transmitter near Frankfurt Main/Germany. For our Australian and American friends a bit far away, but for the Europeans great to use. I use the Milageto DCF77 Receiving modul DCF-3850M-800 from Amazon which works fine with 3.3V and the Pico at GP1. The program writes the data to the RTC. If someone is interested, i made an 3D STL housing for the receiver. Have fun and always the right time! '******************* '* DCF77 Decoder * '* 01.03.2023 V1.0 * '* P.Doerwald * '******************* Option EXPLICIT Option DEFAULT INTEGER Dim DCF(60) Dim INTEGER year,month,day,dow,hour,min,sec Dim INTEGER summer,DCFOK,DCFSTART,DCFSTEP,DCFNOERROR Const TRUE=1 Const FALSE=0 Const HIGH=1 Const LOW=0 SetPin GP1,INTB,DCFSUB 'Clock signal at GP1 DCFSTEP=0 DCFSTART=FALSE DCFNOERROR=FALSE Timer =0 Print "DCF77 Decoder for MMBasic V1.0 by P.Doerwald" Print "Waiting for sync" Do Do Loop Until DCFOK=TRUE DCFCALC Loop Until DCFNOERROR=TRUE SetPin GP1,OFF Do Loop Until Timer>=2000 RTC SETTIME year,month,day,hour,min,0 RTC GETTIME Print "DCF77 successful" Print "Date: ",Date$ Print "Time: ",Time$ Print "Day of week:";dow Print "Summertime:", If summer=2 Then Print "yes" Else Print "no" End Sub DCFSUB 'Interrupts every edge change If Pin(GP1)=HIGH Then If Timer>1700 Then 'new minute DCFSTART=TRUE DCFSTEP=0 Print "Start" EndIf Timer =0 Else If DCFSTART=TRUE Then If Timer>150 Then DCF(DCFSTEP)=1 Else If Timer>75 Then DCF(DCFSTEP)=0 Else 'Error, pulse too short DCFSTART=FALSE Print "Pulse ERROR" DCFSTEP=0 EndIf EndIf Inc DCFSTEP If DCFSTEP=59 Then DCFOK=TRUE EndIf EndIf End Sub Sub DCFCALC 'calculating bits to time and date Dim x,PM,PH,PD ' No Errors - parity OK? For x=21 To 27 PM=PM+DCF(x) Next x For x=29 To 34 PH=PH+DCF(x) Next x For x=36 To 57 PD=PD+DCF(x) Next x If ((PM And 1)=DCF(28))And((PH And 1)=DCF(35))And((PD And 1)=DCF(58)) Then If DCF(20)=1 Then DCFNOERROR=TRUE 'ALL OK, begin calculations min=(DCF(25)+(DCF(26)*2)+(DCF(27)*4))*10 min=min +DCF(21)+(DCF(22)*2)+(DCF(23)*4)+(DCF(24)*8) hour=(DCF(33)+(DCF(34)*2))*10 hour=hour +DCF(29)+(DCF(30)*2)+(DCF(31)*4)+(DCF(32)*8) day=(DCF(40)+(DCF(41)*2))*10 day=day +DCF(36)+(DCF(37)*2)+(DCF(38)*4)+(DCF(39)*8) dow=DCF(42)+(DCF(43)*2)+(DCF(44)*4) month=DCF(49)*10 month=month +DCF(45)+(DCF(46)*2)+(DCF(47)*4)+(DCF(48)*8) year=(DCF(54)+(DCF(55)*2)+(DCF(56)*4)+(DCF(57)*8))*10 year=year +DCF(50)+(DCF(51)*2)+(DCF(52)*4)+(DCF(53)*8) summer=DCF(18)+(DCF(17)*2) EndIf EndIf End Sub |
||||
homa![]() Guru ![]() Joined: 05/11/2021 Location: GermanyPosts: 471 |
Yes, I am :-) Order for the Milageto DCF77 Receiving modul DCF-3850M-800 from Amazon is already out. |
||||
PilotPirx![]() Regular Member ![]() Joined: 03/11/2020 Location: GermanyPosts: 99 |
Great! I uploaded the files to Thingiverse. You need only VDD (3,3V), GND and Out for connecting. Thingiverse Link |
||||
Plasmamac![]() Guru ![]() Joined: 31/01/2019 Location: GermanyPosts: 580 |
Like 👍 Plasma |
||||
atmega8![]() Guru ![]() Joined: 19/11/2013 Location: GermanyPosts: 724 |
Also ordered one |
||||
DrifterNL![]() Regular Member ![]() Joined: 27/09/2018 Location: NetherlandsPosts: 58 |
Hello PilotPirx, I tried your software but got the following error: [75] Dim x,PM,PH,PD ERROR: x already declared After relocating the Dim x,PM,PH,PD in Sub DCFCALC to the top of your software under the other dims the software seems to work great! The first time it synced the time was off by 10 min but running it again it got the correct time. I am using a 5V DCF77 module through a sparkfun level converter. Floating Point Keeps Sinking Me! Back To Integer So I Don't Get Injured. |
||||
phil99![]() Guru ![]() Joined: 11/02/2018 Location: AustraliaPosts: 2642 |
"After relocating the Dim x,PM,PH,PD in Sub DCFCALC to the top " Another option might instead be to change Dim to Local. |
||||
PilotPirx![]() Regular Member ![]() Joined: 03/11/2020 Location: GermanyPosts: 99 |
It is difficult to verify the time read in. I only check the parity bits for minute, hour and date here. If an odd number of bits is wrong, it is detected, if x*2 bits flip, the error is not detected. Unfortunately, there is no checksum. The worse the signal, the more likely errors can creep in. I have also noticed that the pulse length is different for many receivers. By definition, 100ms is a 0 and 200ms is a 1. Maybe you have an idea how to better check the plausibility of the result. Strange, i got no error. I´ll write them as Local. |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |