rp-rs-radio-clock

Crates.iorp-rs-radio-clock
lib.rsrp-rs-radio-clock
version1.0.1
sourcesrc
created_at2022-06-27 20:57:30.927543
updated_at2024-11-03 18:21:15.780018
descriptionDCF77 and MSF receiver on a Raspberry Pi Pico
homepage
repositoryhttps://codeberg.org/rene0/rp-rs-radio-clock
max_upload_size
id614320
size57,845
René Ladan (rene0)

documentation

README

DCF77/MSF receiver

This is a receiver for both the German DCF77 and British MSF time transmitters. Wikipedia has detailed information on both stations. Reception of the two stations happens independently from each other. If reception allows, the clock displays the current dates and times as broadcast by the two transmitters after a few minutes.

Refer to the schematic for the various components. The KY040 (both the push button and rotary encoder) are currently unused, but they might be used in the future.

License

This work is licensed under MIT OR Apache 2.0 Copyright 2022-2024 René Ladan rene0+codeberg@freedom.nl

Building and installing

To build the program, you will need a recent version of Rust (the current code is developed on Rust 1.79) with the thumbv6m-none-eabi target installed as this is the what the Raspberry Pico runs. After compilation, load the compiled program on your Raspberry Pico, after which the program should start.

LEDs

The group of three LEDs (connected to pins 12-14 is used by DCF77:

  • LED 12 indicates a new second (200 ms on) or a new minute (600 ms on)
  • LED 13 is on if the currently transmitted bit has the value 1
  • LED 14 is on if the current bit could not be decoded

The group of four LEDs (connected to pins 2-5) is used by MSF:

  • LED 2 indicates a new second (200 ms on) or a new minute (600 ms on)
  • LED 3 is on if the currently transmitted bit A has the value 1
  • LED 4 is on if the currently transmitted bit B has the value 1
  • LED 5 is on if the current bits could not be decoded

When powering on the clock, LEDs 12 and 14 are on until the first pulse of DCF77 is received, and LEDs 2 and 5 are on until the first pulse of MSF is received.


Display

The display is divided in two parts, with DCF77 using the top two lines and MSF using the bottom two lines:

DCF77 cbaymdwhmt =MS
YYMMDD WW HHmmSS TCL
MSF  dcbaymdwhmt = !
YYMMDD WW HHmmSS Tdd

The station names are displayed on the top lines. Normally the first letter of the station name is in uppercase, but it switches to lowercase if the current minute was overflowing and next minute was predicted by the software itself instead of being decoded from the transmitter. After the station name, various characters can show up in case the software detected an anomaly.

The first three ('cba' for DCF77) or four ('dcba' for MSF) letters appear in case of a parity error. These letters are in lowercase if the parity could not be calculated and in uppercase if the calculation succeeded but mismatched the expected value.

  • For DCF77:
    • 'c' indicates a bad date parity (day-of-week, day-of-month, month, year)
    • 'b' indicates a bad hour parity
    • 'a' indicates a bad minute parity
  • For MSF:
    • 'd' indicates a bad time parity (hour, minute)
    • 'c' indicates a bad day-of-week parity
    • 'b' indicated a bad date parity (day-of-month, month)
    • 'a' indicates a bad year parity

The next seven characters (same for DCF77 and MSF) appear if a value (e.g. month) jumped unexpectedly:

  • 'y' for year
  • 'm' (first one) for month
  • 'd' for day-of-month
  • 'w' for day-of-week
  • 'h' for hour
  • 'm' (second one) for minute
  • 't' for daylight saving time

The last three characters on the lines with the station name indicate miscellaneous things:

  • '=' indicates if the number of received seconds (or bits) mismatched the expected number (usually 60, unless a leap second occurs), being '<' for a too short minute, '>' for a too long minute, or blank if the minute length is OK
  • For DCF77:
    • 'M' shows up as 'M' if bit 0 has the value 1, 'm' if it could not be decoded, or as a blank if it is OK (value 0).
    • 'S' shows up as 'S' if bit 20 has the value 0, 's' if it could not be decoded, or as a blank if it is OK (value 1).
  • For MSF:
    • '!' is reserved for future use

DCF77 cbaymdwhmt =MS
YYMMDD WW HHmmSS TCL
MSF  dcbaymdwhmt = !
YYMMDD WW HHmmSS Tdd

The second and fourth line show the current date and time. All numerical values are two digits long and optionally preceded by a '0', and show up as '**' if they could not be decoded.

  • YY shows the current year (00-99)
  • MM shows the current month (01-12)
  • DD shows the current day-of-month (01-31)
  • WW shows the current day-of-week (Mo, Tu, We, Th, Fr, Sa, Su)
  • HH shows the current hour (00-23)
  • mm shows the current minute (00-59)
  • SS shows the current second (00-59, or 60 if a leap second occurs)

The last three characters show miscellaneous aspects:

  • T shows the current daylight saving state:
    • 's' for daylight saving time ('summer')
    • 'w' for normal time ('winter')
    • 'S' when switching or just switched to daylight saving time
    • 'W' when switching or just switched to normal time
    • '*' if the state could not be decoded
  • For DCF77:
    • 'C' indicates if the 'call bit' (bit 15) is active, or 'c' if it could not be decoded
    • 'L' indicates various things about leap seconds:
      • 'l' means a leap second is announced,
      • 'L' means a leap second just happened,
      • '1' means a leap second just happened and its value is 1 (should be 0)
      • 'm' means a leap second was announced but was missing
      • '*' means the state could not be decoded
  • For MSF:
    • dd shows the value of DUT1, which indicates the difference between UT1 and UTC in tenths of seconds. Positive values indicate that UT1 is ahead of UTC, negative values indicate that UT1 is behind UTC.

Known issues

  • sometimes the clock hangs when powered on (at least with my hardware), re-powering it will eventually fix this.
  • sometimes the time is not properly incremented upon bad reception.
Commit count: 0

cargo fmt