04/13/2019 at 12:50 •
Schematic design and PCB layout can be found on EasyEDA.
The DCF antenna doesn't work well when it's in proximity to EM-noise sources. Possible noise source are the rest of the electronics of the clock or a laptop. The solution is to put the DCF-antenna and the decoder in a separate housing. It might not be necessary to use the separate housing once the clock is properly designed instead of using the breadboard and flying wires.
Steps to follow:
- Using the Hammond 1593NBK.
- Converting the DWG file to DXF using CloudConvert.
- Cleaning up DXF using LibreCAD
- importing in EasyEDA.
- DCF antenna : HKW AFET 77.5 - 10x100/70
- DCF decoder : HKW EM6 DCF 3V
- Output drive capability is only 30µA!
It should be easy for the customer to find a suitable cable assembly to connect the box. The connector should also be small and low profile.
- Stereo audio jack cable :
- flexible, cheap, readily available
- user might be tempted to connect headphones. This must be avoided. At the least, the headphones shouldn't be damaged.
Modular jack cables:
- 4pins, 6pins, 8pins, common use in POTS telephony and ethernet.
- Ethernet cables are not that flexible.
- Big connector. Might not fit inside the housing
The initial idea was to mount a TRRS audio headset socket directly on the PCB, Doing this would make it hard to correctly drill the needed hole in the front panel. Moreover, such a connector, which needs to be placed against the wall of the housing would require a longer PCB than stated in the datasheet of the box.
Two JST XH connectors will be used instead. One connects to a panel mount TRRS audio headset socket. The other connects to a panel mount LED.
Many audio cables are constructed as two pairs of two wires. So the left and right channel each have their ground wire in close proximity. The ground wire is connected to the sleeve. To take advantage of that cable configuration, the GND signal is here also connected to the sleeve.
JST XH Signal Audio jack 2 3V3 Tip 1 OUT Ring 3 GND Sleeve
01/26/2019 at 21:10 •
This setup has the BluePill on the breadboard, connected to a Nucleo debugger (white PCB on the left). The 7segment module on top connects to two GPIOs of the BluePill. The BluePill receives its DCF-pulse info from a DCF-receiver on the breadboard. That DCF-receiver is connected to a DCF-antenna, attached with rubber bands to the breadboard.
DCF-signals are very weak. Making breadboard connections with relatively long wires as done here, makes the BluePill a fairly good RF noise radiator. So with the setup as shown here, it's nearly impossible to get a correct DCF-reading. The picture was actually taken around 9PM. The DCF-library makes a best guess of the data it receives. There's no reliability threshold, so wrong data might be shown in the event of a useless signal. Most of the times, even with a bad signal, the clock recovers and finds the correct time.
I faced the same problems with the BluePill when trying to receive FM-RDS. Using a Nucleo, results were a little bit better, even with the same mess of wires.
Code can be found on Github.
DCF signal quality for the same setup the next day, on Sunday, about the same time of day was much better. No easy explanation about what caused such an interference on Saturday night.
This design has quite a lot of parameters that can be set. It's challenging to find a way to set these all up easily using only a 32x16 display. The display can only show 10 characters at a time.
Menu input would be limited to using a rotary encoder or a few switches.
- Requiring a lot of key presses for setting up parameters
- Difficulty of displaying the menu hierarchy in a way that is simple to grasp. E.g. setting the weekdays for the alarms are four levels deep in the menu. Without a menu overview, it will be hard to keep track of what you're setting up.
Let's take the Google clock app for Android as a reference. This app allows to setup more or less the same parameters as listed below. Using the app, an alarm can be setup in less than 30s. This would be nearly impossible to do with a 32x16 LED array and four buttons.
Parameter setup will be done using physical switches. A combination of DIP switches and rotary switches will be used.
- Each parameter can be set without having to browse through the other parameters, speeding up the parameter setup process
- Parameter status is indicated by the physical state of the switch. This doesn't require power and doesn't cause undesirable light output at night.
- Depending on the target audience, the switch functionality can be implemented using DIP-switches and rotary switches or with panel mount toggle switches and rotary switches that allow for older people to control the device.
- Adds cost, because it requires a lot of extra hardware
- No other means for setup of parameters (e.g. through bluetooth) because the switches would no longer reflect the current settings. A way to circumvent this, would be to replace the rotary switches by rotary encoders & 7segment displays and replacing the dip switches by momentary switches and LEDs.
The input panel will be implemented on a separate PCB, allow for upgrade, changes in a future stage.
- Alarm 1 (Alarm 2 has the same menu structure). The menu item is dynamic. An icon shows if the alarm is enabled or not, followed by the alarm time
- minutes can only be set in 5min. steps. It allows to set up time faster. Nobody wants to get up at three minutes past seven anyway.
- M, T, W, T, F, S, S
- SND + LIGHT
- SOUND ONLY
- LIGHT ONLY
- Sound (only when sound is enabled)
- Volume (only when sound is enabled)
- 0 to 100>#/li###
- Light (only when light is enabled)
- 0 to 100>#/li###
The Nokia 3310 features an elegant way of navigating the menu. Three buttons are involved:
- A two-way switch for scrolling through the menu.
- A "select" button to accept a certain choice
- A "back" button to cancel.
The STM32F103 on the BluePill has a built-in RTC. Luckily, there's already a library for it, so it should be a breeze to implement it. Or not...
Using code as is
To check the accuracy of the RTC, I wrote an application that can receive UTC epoch time from the serial port. The application also reports the difference with a newly sent UTC epoch time. Sending UTC time to the BluePill as follows:
echo -ne $(date +%s) > /dev/ttyACM0
Serial output from the BluePill:
PC epoch - RTC epoch = -553 Number of seconds RTC is running: 1910
PC epoch should be equal to RTC epoch, which it clearly isn't.
Checking up on the 32K crystal with an oscilloscope showed me that it isn't running. I measure 50Hz. Another BluePill from a different batch has the same problem.
Either the crystal is not properly setup in software, or it's a hardware malfunction.
By default, the example code of the library doesn't use the external 32K crystal (LSE), but the internal low frequency oscillator (LSI).
The LSE must be used as RTC clock source.
The code was first run on a Nucleo64 F103. The RTC should work properly on that official hardware:
PC epoch - RTC epoch = 0 Number of seconds RTC is running: 607
Running the code on a BluePill made me happy:
PC epoch - RTC epoch = 0 Number of seconds RTC is running: 30838
Time keeping in software
MCU keeps track of UTC, not local time
The MCU will keep time in UTC, not in local time. Yes, it involves a conversion each time the current time is shown to the user, but it least it's unambiguous. In western Europe, daylight savings time is still used. This means that at the last Sunday of October 3AM, we turn the clock back for one hour.
Suppose only local time is used and an event happens at 2.30AM that last Sunday morning of October, it can't be determined unambiguously when it happened. Was it at 2.30AM Summer Time or 2.30AM Winter Time? You can't tell because that day counts 25 hours and 2.30AM occurs twice.
Jack Christensen's TimeZone library converts UTC to local time.
The alarms in the clock are treated as events in a calendar. It's possible to set up three types of events according to the frequency of occurrence : once only, weekly or daily. Pat Deegan's Chronos library offers functionality for that.
The calendar is only some kind of database that pins events to time. The calendar has no knowledge of the current time.
The calendar can return the soonest event that will occur after a given time stamp. The time of this calendar event is then programmed into the RTC. As such, the application could go to sleep and only wake up when the time of the event is reached.
Alarm IO panel
The MCP23017 is used for charlieplexing 15 LEDs. Using the Chaplex library and replacing pinMode and digitalWrite functions by their MCP23017 counterparts is simply too slow. The LEDs are visibly flashing.
The solution was to adapt the Adafruit MCP23017 library and the Chaplex library. The MCP23017 library now opens up some internal functionality, such as setting pin direction for eight pins at once. The Chaplex library now prepares two registers for the the MCP23017 : pin direction and pin value. When these are ready, they can be sent over the (slow) I²C bus to the MCP23017. This dramatically reduces the number of I²C bus operations. There's no longer visible LED flashing.
The reading of the switches is done using the common matrix technique. Each "row" is sequentially pulled low while pullups are connected to the "columns". The delay caused by the I²C commands is beneficial here, as it removes the need for switch debouncing measures.
Rotary encoder reading
A common technique to read rotary encoders uses pin change interrupts. When a falling edge occurs in the green signal in the picture, then the level of the blue signal is read. If the blue signal is low, then rotation is clockwise. If the blue signal is high at the falling edge of the green signal, then rotation is counterclockwise (or vice versa). When directly connected to an MCU, implementing this is quite straightforward. In this design, the MCP23017 creates a delay, which might be a challenge. The blue signal only keeps its state for about 7ms after the falling edge.
After some time debugging my code for MCP23017 interrupts, I found out that the MCP23017 only supports three interrupt types : pin change, pin high and pin low. There's no support for making distinction between falling edge and rising edge pin interrupts.
If you configure the MCP23017 for interrupt on pin high (DEVALx=0, INTCONx=1, GPINTENx=1), the MCP23017 will generate interrupts as long as the pin is high. This is a level triggered interrupt, not an edge triggered interrupt. The datasheet is quite misleading in this regard.
The firmware uses MCP23017 pin change interrupts. Interrupts are generated on falling and rising edges on one of the two switch contacts. The STM32 is setup to generate interrupts at the falling edges of the IRQ line from the MCP23017. The interrupt routine on the STM32 reads the state of the two rotary encoder contacts. Rotating clockwise yields: 00,11,00,11,... Rotating counterclockwise yields 01,10,01,10,...
This describes how the internal parameters of the clock will be shown to the user using the three output devices on the clock io panel : LED matrix panel, seven segment display and LEDs inside the switches.
Fields are display elements that can show a value. The value can be changed in predefined steps between lower and upper limits. For the LED matrix panel, a bar graph drawing element is used. For implementation on the seven segment display, two fields, each consisting of two digits can be shown.
"Select" is a display element that allows to select one out of many. It's only implemented on the LED matrix panel. A moving dot corresponds to the currently selected item
"Toggle" is a display element that shows the status of a boolean. Only two states here: on or off. This is implemented for the switches alongside the edges of the clock io panel.
01/20/2019 at 11:50 •
Because of the sunrise simulation, the housing, or a least a major part of it must be translucent or transparent. Translucent materials are preferred as the diffusion of the light will make the housing light up as a whole. It's an option to use transparent materials for the housing and stick a translucent film onto it.
- Acrylic : can be laser cut
There's a chance that the electronics of the generate too much EM-noise, so that the antenna and receiver need to be placed in a separate housing.
A suitable housing is the Hammond 1593NBK (Farnell €2.75).
If you want to build a really cheap enclosure for your antenna with hot glue and some scrap piping, have a look here.
01/11/2019 at 21:04 •
First layout idea
IO panel with two times two concentric LED rings
Nothing to be really happy with. This design is too large. There are three rotary encoders with an internal switch. The high switch actuation force of these switches prevents the panel from being used in a vertical position. You would top over the clock when you push the switch of a rotary encoder.
The three rotary encoders will each be replaced by a push button switch. There will be one encoder for general change of values. You push the switch to select that functionality. Using the rotary encoder you can then change the value at will. This kind of user interface is used on the R&S RTO200O series oscilloscopes.
The double rings of WS2812B LEDs are also eating up too much space. Let's replace these by LED bar graphs.
Second layout idea
The space consuming LED rings have been replaced by LED bar graphs. Each one needs 10 inputs, so it will take some effort to get these routed properly.
The button for setting the brightness of the LED array and the light sensor are not related to alarm settings, so they have been removed from this module. Functionality for setting LED array brightness should be physically located near the LED array, not on a separate IO panel.
So what's left?
- A menu button to cycle through the alarm settings (top left).
- top right: a button to set alarm hour & minutes
- seven buttons to enable the alarm for certain weekdays
- a button to set the brightness of the sun rise simulation with the corresponding LED bar graph.
- a button to choose the song to wake you + LED bar graph
- a button to set the music volume, with LED bar graph
- a single rotary encoder to change the value of a setting once the setting has been selected by a push on its button.
It all doesn't look to well: all those bar graphs... The rotary encoder is out of place.
Let's work out another idea...
Third layout idea
Why not incorporate the LED bar graph functionality in the LED array? We have plenty of pixels already there. Both sides of the LED array can be flanked with buttons. Alarm settings on the left, LED array settings on the right. The pixel row next to the button can be used as a virtual LED bar graph.
The LED array "PCB" and the clock-io-panel have been merged into a single PCB. This reduces cost and it will mechanical assembly easier.
Functionality overview at a glance, counter clockwise, starting at top left:
- setting brightness of sunrise simulation
- setting volume of alarm / music
- select alarm tone /song
- menu button for selecting the settings of alarm1 or alarm2
- seven buttons to enable/disable the selected alarm on a day of the week
- setting the alarm time
- setting LED array night brightness
- select at what ambient light brightness the day/night switch should occur.
- setting LED array daylight brightness
Alarm + LED array functionality merged into one IO panel. Connectors & ICs not yet shown
In the middle you can find :
- the LED array to show time & settings
- the ambient light sensor
- the rotary encoder to change the settings. The switch on the rotary encoder will not be used.
- seven segment display to show alarm time. It will only show the alarm time if an alarm is scheduled in the next 24 hours.
This clock-io-panel is bigger than the previous one, but 196x122mm will still fit on pretty much any night table.
Layout for PCB Revision 0Some improvements with regard to the previous version:
- Switches moved to the edge of the PCB. On the previous version, there was no room between the switches and the LED array, which makes it harder to add a sturdy front panel later on.
- Grouping icons in groups of related functionality to improve intuitivity
- Changing some icons to make them more intuitive.
- Swapping led 7-segment with FFC & light sensor for ease of routing.
- Reference designators have been moved from topSilk to topAssembly layer. I don't want them to be visible on the PCB.
- Adding EMC filtering for the FFC.
Substantial effort went into the placement of the switches and LEDs so that as much as possible routing could be done on top layer. As such, the bottom layer is able to serve as low impedance ground plane.
Five pieces of this PCB cost me €14.32 + €9.03 shipping. Four of the PCBs will never be used. PCB costs dramatically increase when your design doesn't fit a 100mm square as in this case. If they had, the PCB would only cost me €1.79 for five pieces.
Layout for PCB Revision 1
Revision 0 was all well and good, but the big clock IO panel PCB is relatively costly and won't find any usage in other projects. It serves mainly as a carrier for functionality that is already on modules (displays, light sensor). The fifteen LED/switch combinations might be split up in four identical sections of four switches each. There would be one module carrying only three switches. It would add cost in wiring and connectors, but this switch module could easier find usage in other projects. I would be able to use four of the five prototypes sent to me. These switch modules would also fit the 100mm square template of the PCB manufacturer. The different modules could then be mounted on a laser cut panel. A separate module would be needed for the rotary encoder. Buy them, not make.
- 4 switches
- 4 High Efficiency red 3mm LEDs
- 4 mounting holes 3.2mm
- 3pin JST XH (for LEDs) and 5pin JST XH (for switches). 8pin JST XH is uncommon on AliExpress.
- Add diode for switch control, as below. Diode might be replaced by 0ohm resistor for use with SX1509 or other keypad scanning engines.
The clock-io-panel currently uses the standard matrix keyboard scanning technique. It requires 8 IO lines for 15 switches.
It's only added here as a reference, because it's a clever circuit: If not enough IO lines had been available, there would be an alternative approach:
This technique would require only 5 IO lines for 15 switches (max. 20 switches). The downside is that 5 diodes need to be added. This probably won't work with an SX1509 or similar which has a built in keypad scanning engine.
User input control
Having only a 32x16 LED array to show data poses some limitations on the user interface.
The Nokia 3310 interface could be used as an example. There are three functions in three buttons:
- C : Cancel = go back
- Middle : Select or Menu (which is actually also select)
- Up/Down arrow to choose items
To help with navigation, on the top right, the path in the tree is shown. On the right, a line marker indicates the index of the menu item.
All in all that's very nice, but it forces you into a lot of key strokes. Instead of a menu with several levels of hierarchy, the different functionalities will be brought out onto separate switches and rotary encoders.
The problem with a rotary encoder is that there's no way to go back to a higher level in the menu structure. The workaround is to add a "Back" menu-item that points to a higher menu-level.
Filtered component list in Digikey for applicable rotary encoders with switch. These are quite cheap, so they can be readily ordered on Digikey, no need to wait for AliExpress.
Another drawback of the encoder is the high switch actuation force. For the Bourns PEC12R-series, is around 9N worst case. That's about the weight of three soda cans. This makes the rotary encoders unsuitable for horizontal actuation. When you pushed the switch, you would turn over the clock, or it would start sliding over the surface if you wouldn't be holding it with your other hand.
The Bourns PEC12R series has a plastic shaft. Rocking the shaft gently back and forth or left to right causes false contact switching. The shaft also feels a bit flimsy. Adafruit uses the PEC11-4215F-S24, which is now obsolete. The PEC11R-4215F-S0024 is the new part number. Presumably the metal shaft from the PEC11(R) series is more sturdy than the plastic shaft from the PEC12R.
Including the key cap(s), this is more expensive than a joystick if momentary switches are used.
Using keyboard switches, it's another story. There's a wide variety of push forces, key caps.
Because the original Cherry MX switches didn't accomodate for 3mm LEDs on a non-transparent key cap (which was what I had at that time), I opted to use SMD LEDs instead. That wasn't a good option. There's lots of light bleeding away on the sides. Another problem is that only the top half of the key cap is lit. Using 3mm LEDs doesn't solve that issue. 3mm LEDs with a wide opening angle are needed. Preferably the LEDs should also be high efficiency, as with charlieplexing, they might be driven with low duty cycles.
Keyboard switches are bigger than the ubiquitous 6x6mm momentary switch. In this case, it's advantageous as it allows easier control.
A 6.2" or 6.4" touchscreen could be used (156 x 88 mm). This costs $6.24. Does a touchscreen have added value in this application that can justify the added cost? With a clever menu design, it can be very easy to use.
This has all the necessary features:
- a button to select a menu item.
- up/down movement for selecting menu items in a list.
- left movement to go back to the parent level in the menu.
This single component can be used to implement the Nokia interface. It might be strange somehow that the movement to the right has no function.
One handed operation.
The look might be odd with such a joystick pointing out on the front panel.
Navigation switch aka 5 way switch
The cheaper version of the joystick. It uses switches instead of potmeters. So there's no way of measuring how far the button has been pressed.
The key cap must be ordered separately.
1-Axis Thumb wheels
At least two of these would be needed. For intuitive control, these would need to be mounted at 90 degree angles with respect to each other, so at the upper or lower corner of a device.
Even with two devices, these could still be operated by one hand.
They can also be bought from Digikey.
I ordered some of these buttons. They're quite small and sometimes you push the middle button while wanting to move left or right. When two of them need to be used, this no longer fulfills the single handed operation.
No suitable source found on AliExpress. Available on Tindie.
There's more IO needed than the BluePill can handle. We need an IO Expander.
- AliExpress module : €0.76
- Used by Adafruit
- 25mA push/pull
- 2 IRQ pins
- level triggered interrupts, edge triggered interrupts (no distinction between falling and rising edge interrupts)
- 3V3, 5V compatible
- available in SOIC28
- SPI version of the MCP23017
- asummetrical output driver: 1mA source, 25mA sink
The IO expander also controls the 15 LEDs in this setup using charlieplexing. A charlieplexing library for the MCP23017 has been developed, loosely based on the Chaplex library.
An alternative approach would be to use a 16 channel SPI LED driver instead: TLC5925 | STP16CPC26 | CAT4016 | MAX6969: 16 outputs, integrated current source, Digikey €1/pce. This would allow me to get rid of the charlieplexing, which would ease timing a bit.
Ambient light sensor
The clock should monitor the intensity of the ambient light in order to adjust the intensity of the LED array. Especially in the dark it can be quite annoying when the LED array is too bright. Many choices for sensing the ambient light are available.
Important factors that determine the choice are cost and sensitivity in the human eye light spectrum (390 to 700nm).
Contains the poisonous CdS. Not RoHS compliant.
- More expensive than photo transistor.
- Requires signal conditioning to make the sensor level readable to an MCU.
- Most diodes have the highest sensitivity outside of human eye spectrum.
- Available in variants that have sensitivity matching the human eye
- TEMT6000 : AliExpress module
- $0.86/pce with header & mounting hole
- overpriced compared to AP3216 modules which offer more functionality for about the same price
- T-1 through hole package
- €0.59/pce Digikey
- small opening angle : could be pointed by bending the leads in desired direction of the light
- Spectral sensitivity resembles that of human eye
- TEMT6000 : AliExpress module
- More expensive
- More features (proximity sensing)
- ambient light & proximity
- AliExpress : $0.90
- ambient light (22bit dynamic range)
- AliExpress : $1.75
- TI OPT3001
- ambient light (23bit dynamic range)
To be readable in the dark without glasses from about 0.5m distance, the characters should be around 50mm high.
There are a few options here:
- numeric or alpha-numeric LED segment displays, sized 2.24" or 2.3". These are used in the nice Alpha Clock Five. These displays are expensive (Digikey €5/pce) and not very standard.
- LED dot matrix 5x7 5mm, not standard, not cheap
- LED dot matrix 8x8 5mm, about €1.5/pce, 2088AS or 2088BS, common anode or cathode.
- LED matrix 8x8 3mm common anode, €0.60/pce, tests with a 5mm LED dot matrix with 3x5 pixel font (35mm high) showed me that it's readable without glasses from 0.5m distance.
- LED Panel P10 Red, AliExpress $12.68. Definitely the cheapest 32x16 panel, but the size is 320x160mm. It's too big. There are LED modules with smaller LED spacings, but the outside dimensions don't change much.
- LED Panel P3 RGB, AliExpress €18.51. 192x96mm, 64x32 panel
After putting a lot of effort into making my own module for the 8x8 3mm LED matrix (see Tileable 8x8 LED matrix), I discovered that 32x8 LED matrices are on sale for close to no money (€2.93). These modules use the MAX7219, which is controlled by SPI.
Development is ongoing : two 32x8 display units are stuck together with tape. I had some trouble writing data to the MAX7219 modules. It seems that only bit banging SPI works. Maybe that's because the modules are only powered with 3V3, while it should normally by 5V.
The font should be easily readable without glasses. So we want it as big as possible.
The fonts have been recovered from the Xronos clock. That clock contains five different fonts of which four are shown here. The character '8' is chosen, because it's one of the most difficult ones to read. The two fonts on the right are easiest to read. The rightmost font has been chosen because it looks nicer.
Many silly alarm clocks don't show the alarm time by default. You only see a dot indicating there's an alarm active. To view the alarm time, some buttons need to be pressed.
To distinguish it clearly from the clock time, a smaller LCD display will be used. It will allow to verify the alarm time before going to sleep. It doesn't hinder that the alarm time can't be read without eye glasses.
A chinese 7-segment 4 digit module with TM1637 driver is very cheap. Costing €0.51, it's only €0.10 more expensive than a bare 7-segment 4 digit display. There's little to be gained by integrating the driver and the display on the main board instead of using a module.
The annoying thing about this TM1637 is that it doesn't have an I²C slave address. It can't be used with other devices on the same I²C bus, unless you use some kind of I²C multiplexer.
Adafruit's LED backpacks are based on this one. Most of the modules are sold without LED display. If you want one with display, you'll pay €2.83 on AliExpress.
Nokia 5110 module
This module has an SPI interface. It requires 5 IO connections.
Very bright, but small. These cheap modules will also be very susceptible to screen burn-in. This makes them less suitable for this application, where the alarm time will be shown continuously.
07/10/2018 at 15:13 •
Most clocks use sound to wake you up. This clock is no exception.
A little "DFPlayer Mini" module does all of that, also MP3 decoding. It even includes a speaker driver.
Yuexin YX5200-24SS module
Works like a breeze with the platformio. Be careful to connect your module correctly. I've already destroyed one by wrongly connecting it and nearly killed a second one. Strange...the polarity is clearly marked on the module.
- Decoder IC
- AliExpress $1.17
- User experience from Markus Wobisch
- The official library from DFRobot locks up when making too many calls to it.
- DFPlayer Mini Mp3 by Makuna is a better alternative
- Before copying music files, normalize their volumes.
sudo apt install python-rgain replaygain --force *.mp3
I have the impression that it works well on a PC, but that the DFPlayer ignores the normalization. I have also tried to use Audacity using the procedure described here, but also with disappointing results.
- There are two options for audio output: headphones (stereo) and speaker (mono).
- Speaker output is generated by the on-board amplifier. According to the VCC, GND and speaker connections, the amplifier is a PAM8302A (or LM4871, or XPT4871, or YX8002-8S). This one can send 2.5W into a 4ohm speaker. That's certainly loud enough.
- The speaker output of the module certainly needs filtering to reduce EMI.
- The speaker sound lacks low frequency content. The input coupling of the PAM8302A might have a too high corner frequency. Let's see what other designs are using:
- Elektor "PAM8302A Audio Amplifier" (issue June 2018) : 180ohm in series with 220nF
- Adafruit 2130 : 100ohm in series with 1uF
- DFRobot advises to add a 1K resistor in series with the RX-line (pin 2) to reduce noise.
- See also Markus Wobisch schematic to reduce noise.
- EMI precautions : see Elektor "PAM8302A Audio Amplifier" (issue June 2018)
- $1.93 module from AliExpress
- SMD (only components on one side)
- Also used by Sparkfun
- ADPCM, WAV, no MP3
- serial interface : DATA + CLK
GeneralPlus GPD2846A module
This module doesn't seem to allow control by a MCU, except through USB.
GeneralPlus GPD2856A module
This module doesn't seem to allow control by a MCU, except through USB.
It doesn't look like there's already an established solution for the STM32 platform. This will require lots of work.
The cheapest option would be to generate sound using PWM, but it requires some work. The sound files also need special conversion before storing them to flash. An output amplifier is needed for connection to a speaker.
Arduino Wave shield
It uses a MCP4921 DAC and an SD-card. Both are SPI devices, but they're connected to a different bus.
06/28/2018 at 11:41 •
If no sunrise LED is needed, then the electronics could be powered from a 5W USB wall charger. The sunrise LED will probably need about an extra 10W.
The common solution is to use a goldcap as back up power supply. The limitations of goldcaps are:
- limited energy storage capacity
- high internal resistance
- voltage decreases linearly with respect to the current being drawn.
All of this makes that in case of power outage the goldcap can't be used to sound the alarm to wake the user.
An alternative approach will be used here. A cheap alkaline AA-cell will power a MCP1640 boost converter that will step up the voltage to the required 3V3. As long as the normal power is supplied, the MCP1640 can be disconnected from the AA-cell.
DCF-communication is susceptible to noise. Proper filtering is needed to reduce the risk of bad signal reception.
- ANP002: The Protection of USB 2.0 Applications
- AliExpress 32707561851 : USB EMI filter
- USB Hardware Design Guidelines for FTDI ICs
USB-C allows for a maximum power transfer of 20V/5A. This would be more than enough for this project.
The advantage of using a USB-C connector would be that a power adapter with USB-C could be used. These will probably be quite standard in the near future. At the time of writing (2018) these are still expensive.
There are more drawbacks: to get the 20V/5A, the device delivering the power and the device sinking the power must communicate with each other using BMC-coding. This is implemented in the Richtek RT1715 and the TI TUSB32x family. These devices are still rather expensive. The SMD packages are small and hard to solder by hand.
Using this connector would be a typical case of over engineering. There's no real advantage is using USB-C only for powering a device. The exception could be for powering an electric razor. You could use your phone charger to power it. It saves you one power adapter in your luggage.
Cheap, readily available, reliable... The drawback is that there's no guarantee about the voltage level and polarity. The user can connect whatever (s)he likes. It's up to the powered device to cope with this.
06/24/2018 at 16:12 •
A gradually brighter light can mimic the sun rise. It will allow for gentle wake-up in the morning.
Experience with the Philips HF3463 showed me that you shouldn't count on it to get up on time. I sometimes find myself waking up by the alarm sound and facing the alarm clock in full brightness. When you're sleeping on your side and the light is behind you, it won't wake you either.
Needed output power
A Philips HF3463 sunrise clock uses a Philps 100W 1200lm Softone lamp. Replacing the bulb with a 60W 700lm still gives enough light. So our light should also be able to output about 700lm.
Selection of the lighting source
- Lumileds Luxeon 3535L & Lumileds Luxeon 3535L HE Plus
- Devices available at Mouser & Digikey:
- LEDs cost about €0.42/pce
- 300mA max, lowest cost per lumen. Other 180lm/W devices cost about the same but don't allow such high currents.
- If driven at 200mA, then 7 LEDs would yield about 800lm.
- "Could" be soldered to custom Al substrate PCB.
- AllPCB : 120x20mm or 100x30mm is $17 / 5pcs
- How hard is it to solder LEDs on a metal substrate?
- 280x24mm, which is too long for the alarm clock
- 19.5V, 350mA, 1230lm
- Digikey €3.12/pce (not available)
- COB LEDs
- DopDea DPD-36120-0428
- DopDea DPD-9450-0414, ZF-9450-0414
5050 LED panel GU5.3 Base fitting for MR16 lamps
- 12V lamps
- typically 500lm, which is rather limited
- heatsink is part of the lamp
- AliExpress has many on offer, very cheap
- In a local store it was hard to find LED lights with a GU5.3 base. GU10 (230V) is the most common type of lamp. The best GU5.3 base LED lamp suitable for this application:
- 12V AC/DC
- €11.95 (no kidding)
Wayjun Epistar 10W
- available on AliExpress from many vendors
- commonly used in floodlights
- cheap : $0.29/pce (cheap version 900mA), $0.94 (real version 300mA)
- A sample of each has been ordered. I received both but don't know which is which. I asked the seller and they replied that the "heavier" one is the real one. The "real" one is indeed about 4g heavier.
- They were both announced as warm white, but the "real" one is cold white.
- The warm white one has a terrible thermal efficiency. Without heat sink, the current needs to be lower than 100mA, or the LED will run too hot (>70°).
- The light output of the warm white one is disappointing too.
- The cold white LED performs a little better, but it's still disappointing. Too much of the power is lost in heat. These LEDs can't be used.
- AliExpress "specs"
- limited efficiency : 58lm/W (worst case for the cheap version)
- 11V, 1050mA, 675lm
- heat sink needed
- expensive: 100x100mm = €3.84
- limited light output
220V light with dimmer
- requires 220V, which could be dangerous
- consumes a lot of power because of the inefficient lamps
- No need for color changing the light
Controlling the room light
- Standard light with controllable dimmer: You need a dimmer that can be remotely controlled
- Philips Hue White Wireless bulbs : if you have a lot of money to spend
- Inefficient because of the many series resistors in the string
Light source cooling
The above mentioned LED COB sources require that the aluminum substrate is not hotter than 70°C. If we want to maximize light output, we'll have to add a heat sink to get rid of the excessive heat.
There's no reliable info about the thermal resistance of the LEDs. Some tests will need to be done:
- Attach thermo couple to the LED strip
- Measure room temperature T1
- Leave LED panel hanging in free air. Don't lie it flat on a table or other surface.
- Attach current source to the LED and regulate current (I) so that steady state temperature of Al-substrate of LED is 70°C (T2)
- Measure voltage over LED (U)
- Calculate thermal resistance of LED panel = (70-T1)/ (U * I)
- Attach heat sink to LED panel.
- Repeat step 1-5.
A 100x60x10mm : €1.55/pce heat sink will be used.
This is not the cheapest heat sink around. Care should be taken to the thermal resistance of the heat sink. The LEDs can work up to 85°C. Any hotter and their lifetime will decrease rapidly. At a room temperature of max. 40°C, this allows for an extra 45°C temperature rise due to LED heating. The total resistance of the thermal path should be smaller than 45°C / 10W = 4.5°C/W. The thermal resistance of the LED is already 1.4°C/W. This leaves about 3.1°C/W for the heat sink.
AliExpress vendors don't publish the thermal resistances of their heat sinks. We'll have to measure thermal resistance by ourselves.
Another way is to go with some simple rule of my old colleague : "If your heat sink is too hot to touch, then it's too small".
LED driver modules
The plan is to power the clock from a 5V USB power adapter. The LEDs require about 12V/500mA. So we need a boosting LED module, not a buck module.
If we decide to make the module ourselves, we need to select an IC:
- easy to solder : SOT23 is ok, QFN isn't
- over voltage protection (when LED is not connected or broken). Proper solutions directly sense the output voltage using an extra pin. This brings the minimum number of pins for the IC to 6 : gnd, vin, vout, sw, fb, en.
- VIN min < 5V
- VIN max > 5V
- VOUT min > 12V
- IOUT > 1A (we need 500mA)
- low power. Remark that the output LEDs continue to draw current when the LED module is in shutdown. External circuitry is needed to fully shut down the LED module.
- dimming capability (analog & digital dimming are explained in the MP3202 datasheet)
Digikey selection : RT4533GJ6 and others
- Lumileds Luxeon 3535L & Lumileds Luxeon 3535L HE Plus
05/10/2018 at 20:30 •
O-Led Morphing clock
Harifun's Morphing Digital Clock
Nice animation, (too) big LED array, too bright, blue color will keep you awake
Craig Bonsignore's Open Clock Project
Nice clock, but without a manual, you can't properly operate it. Sometimes digits are green and sometimes red.
The idea of the arcade buttons is good, but the menu navigation is quite unusual. The black button cycles through the menu items of the top hierarchy level. The red button is used to go from top hierarchy to the level second level. Then it cycles through the menu items of that second level. The white button finally is used to change user settings. As there are only three buttons, you can only cycle in one direction through the items. For setting the year or the minutes of the hour, that's quite annoying. A fourth button would have made menu navigation a lot more intuitive: up, down, select & back.
See how long it takes and how many key presses are needed to set it all up?
Alpha Clock Five
- Simple housing
- Expensive LED display.
- Acrylic housing (laser cut)
3-Way Display Alarm with 2.2" TFT
- Has a brightness setting for day, night and allows setting brightness level for day/night transition.
- It's personal taste, but :
- I dislike the use of a different color for each digit.
- Why design & 3D-print a RECTANGULAR housing? Choose a COTS-housing, design your electronics to fit that housing, make cutouts in the housing where needed.
03/18/2018 at 12:58 •
There are five options for setting time:
- Long wave time signal
- DCF (EU), MSF (UK), WWVB (US)
- cheap modules only have a few 100km range.
- more future proof than RDS.
- signal easily disturbed by electronics in the vicinity (laptop, SMPS, ...) .
- no user interaction required
- indoor use possible
- EOL in Western Europe
only sent once a minute. When the reception quality is bad, you might have to wait some minutes to get the correct time.
- NTP : requires user to type WPA-key in the alarm clock
- GPS : needs a visible sky
- GSM : needs a registered SIMCard
- Manual : annoying
- Preprogramming time at the production facility : Emerson's patented SmartSet "technology". The user still has to set the time zone offset.
Long wave time signal
Commercially available DCF77 modules
- Conrad (receiver+antenna)
- HKW antenna + HKW receiver (datasheet)
- Grupo Premo antenna
- Reichelt (receiver+antenna)
- Universal Solder (receiver+antenna)
An evaluation of these DCF77 modules has been done by [Udo Klein] and can be found here.
Signal quality tests with HKW antenna & receiver
I hooked up the antenna to the receiver. The receiver was powered by a Protrinket3V, which in turn was powered by a TTL-232R-3V3-WE. The DCF output was monitored using a Smartscope.
At first, there was no useful signal. I pulled out all the mains plugs to find the culprit. I found three of them:
- USBwire lead of the TTL-232R-3V3-WE
- Asus charger for Asus X550L laptop (only when DC-jack is plugged into the laptop)
- Power adapter for Fantasia Xaro Desk light (EAN 5414358095390).
Moving the antenna closer to the window, away from these noise sources solves the problem.
I also discovered that signal quality can vary strongly during the day. During programming the signal went very bad. After a few minutes it turned all of a sudden to a good signal again. Nothing in my house was switched on or off during that instant.
The DCF77 Analyzer/Clock v2.also uses an external antenna and receiver. I also get the best results when the antenna and receiver are on one breadboard and the rest of the electronics are on another breadboard. There needs to be at least 30cm space between them. The antenna should also be kept at least 30cm away from the laptop.
The problem I quickly encountered is bad signal quality from the module. Rotating the antenna helps, but you can't ask from users to do this for you. A solution could be to add a monostable multivibrator to the DCF output that triggers on falling edges. It could have a 500ms timeout. If you connect an LED to it, there would be a visual indication of signal quality. The user should see the LED flashing at a 1Hz rate. If the LED stays on or off then signal quality is bad.
[Udo Klein] put quite a lot of effort in providing an alternative in his Blinkenlight project. Unfortunately this project only works for AVR architectures. I forked the library and added support for the Bluepill. The other big drawback is that it takes at least 5 minutes to sink. With a bad signal, this can increase up to 30mins. The library of [Udo Klein] also requires you to synchronize your clock to the DCF77. If you don't do this, you won't be able to recover the signal from the noise when the signal goes bad.
Scientific papers about DCF77 decoding can be found here:
- Daniel Engeler Performance Analysis and Receiver Architectures of DCF77 Radio-Controlled Clocks (DRAFT) (pdf)
- Filip ZÁPLATA, Miroslav KASAL, Software Defined DCF77 Receiver, RADIOENGINEERING, VOL. 22, NO. 4, DECEMBER 2013 (pdf)
- Martin Wierich "Ein digitaler DCF77-Empfänger mit hoher Empfindlichkeit", Diplomarbeit (pdf)
Capturing data from serial port
minicom -D /dev/ttyACM0 -b 115200 -C minicom.cap
It's quite easy to use Calc/Excel to convert the capture file from minicom to two csv files, each containing one column.
These CSV-files can then be used as PWL input data for voltage sources.
[jafingerhut] has done quite some investigation about finding the right package to show your data.
Online decoded DCF data can be seen here.
After evaluating the RDA5807M and the SI4703, I found out that it's hard to get good quality RDS-reception. I only tested on a breadboard. The airwire connections aren't helping to get good reception quality.
The used development platform has an influence as well. The ProTrinket 3V, powered by the FTDI has a average 5dB better RSSI than the Nucleo STM32F103. On the Nucleo, it wasn't possible to receive four consecutive blocks without error. The SI4703 had to be set to RDS-debug mode to get at least some RDS-info.
- This chip is based on the SI4703. The RDA5807M datasheet even contains statements that have been literally copied from the SI4703 datasheet.
- There's no error checking on the last two of the four RDS blocks. Block 3 and block 4 contain the useful data. The only way to "guarantee" data integrity is only passing on data that has been received twice identically.
- Reception quality is acceptable for audio, but not for RDS. There's only one station that gives me acceptable RDS reception.
- The RDA5807M has more or less the same settings as the SI4703, but these are located at other registers. So they're not firmware compatible.
- Very little info about the RDA5807 : 2 datasheets (in english) and two programming manuals (in chinese)
- Available on module by AliExpress
- Extensive info available on SiLabs website
- Available on module by AliExpress
- If you need RDS, better to choose this IC instead of RDA5807M. The RDS reception quality isn't better, but at least you'll be told what RDS-blocks are valid and which ones contain too many errors.
- RDS only, no audio
- hard to solder QFN package
- Acceptable price : €2.30/pce at Digikey
- Used in the more recent versions of the taiwanese Sangean WR-2.
- Expensive : €13.85/pce at Digikey
- Long wave time signal