kair.us/ projects/ seven segment wall clocks/ kello version 4

Kello version 4

DIY accurate 7 segment clock

Being slightly annoyed that NXP obsoleted the SAA1064 chips used in clock version 3, I decided to design fourth, and maybe final version. I wanted to to retain all good features of version 3 and add some new. I also targeted to lower the cost of parts, as the Maxim DS3231 is very expensive and the SAA display drivers were not too cheap either. So the LED drivers are replaced with TLC5925, and RTC is changed to PCF2129. On circuit design the swap of these parts was quick, but on FW side a little slower, as I had to write the drivers.

Meanwhile the cost of factory made PCB from China has dropped also for bigger boards, so there wasn't need for single sided design anymore, as used in my previous version clocks.

Features

Hardware

The version 4 uses same 58 mm (2.3") displays as version 3. There are compatible displays available from several manufacturers. The displays must be common anode type. Suitable displays are e.g. Sharlight CM1-2302 series, Kingbright SA23-11 series, Wenrun LSD230B series and also most of the 2.3" displays from eBay.

The best matching flat top LED for the cheap eBay displays that I've found is Kingbright WP483SRSGW (or older code Kingbright L-483SRSGW). This is actually bi-color LED but when mounted as in assembly drawing, it lights red. When mounted the other way round, it will light green. The green is a good match for Wenrun LSD230BAG-101-01 green display which is available from TME at a very affordable price. The picture on top of this page shows the green Wenrun display. I've also used shrink tube around the LEDs to prevent light leakage from side.

Previous clock used the internal temperature sensor of the DS3231 RTC to show temperature. This wasn't however giving accurate readings since the power dissipated by displays and drivers was heating the RTC. Version 4 has connectors to fit two external NTC thermistors to measure inside and outside temperatures. Suitable thermistors are available from eBay. They have 10 kohm resistance beta value of 3950. The thermistors have an XH connector at one end, which is a Chinese copy of JST XH series connector. You can use either the genuine JST or the Chinese replica on the PCB. According to my measurements these thermistors follow very closely to this chart on Adafruit website. I measured one thermistor in ice water 31.87 kohm and in boiling water 652 ohm. The firmware has an array based on the Adafruit table and in practice the displayed temperature value seems to follow very closely to a commercial digital thermometer.

The remote control support is improved. The firmware supports Nec, Nec42, Samsung, SIRC, Kaseikyo, Matsushita, JVC and RC-5 protocols. It also has a learn function which can be used to teach it to work with any remote which uses one of the supported protocols. You can use e.g. an old TV or DVD remote control to control the clock. The IR receiver should be chosen based on the carrier frequency used by the protocol. SIRC uses 40 kHz, RC-5 uses 36 kHz and the rest use 38 kHz. However, the 38 kHz works quite well also for SIRC and RC-5. An example of suitable 38 kHz receiver is Vishay TSOP53438. It is cheap, sensitive and has good noise rejection.

Time base of the clock is derived from PCF2129AT. It also provides battery back-up. The power consumption of the RTC is 2.15 µA when in backup mode. A CR2032 battery has a typical capacity of 190 mA so it should last for over 10 years. Of course when clock is getting power, the battery is not drained. The PCF2129AT is temperature stabilized and the accuracy is very similar to DS3231 for only fraction of price.

A piezoelectric buzzer can be used to give audible alerts. Currently there is possibility to configure it to hourly beep and/or wake-up alarm. The buzzer needs a higher voltage to give loud enough sound. The direct drive from PIC pin shown on 3.0 schematics is not enough, it needs to be driven from the input supply voltage. I will update the design at some phase. There is also an IR emitter LED which is used in master / slave setup to transmit time and date from master clock to slaves. It could also be used for alarm, so the clock would e.g. turn on TV when the alarm activates, but this is not currently supported.

There is also a footprint for U-blox (former Fastrax) UC530M GPS / Glonass module. The firmware has automatic recognition for GPS module and PCF2129 RTC. It works with eiher one, or both. The firmware only uses the time and date from GPS, derived from GPRMC message.

Schematics

The schematics are pretty straight forward. The PIC16F1788 firmware makes most job.

Input voltage is fed to connector X1. It should be high enough to be able to drive the chain of 4 LEDs in each segment. For red displays this is typically around 7.5 V. Then the output stage of TLC5925 needs an additional 1.0 V to maintain regulation. A 12 V power supply is OK for most display types. To save some power, 9 V supply is usually also OK. Voltages up to 17 V can be used (or up to 16 V if using MCP1703-3302E/DB as regulator IC6), but this causes just more power wasted and heat generated in the display drivers. Diode D1 protects from incorrect supply polarity, but for over voltage there is no protection.

The displays are driven by three TLC5925 constant current LED drivers. They are controlled via SPI bus from PIC. The LED current is set with a resistor in R-EXT pin on the TLC5925. Current at each output is 18 times the R-EXT pin current. Now a little trick is used to allow global brightness control of all segments. The integrated DAC and integrated op-amp of PIC is used to control the low sides of R-EXT resistors. This allows easy brightness control without using PWM and without all the disadvantages associated with PWM.

The PCF2129AT RTC has possibility to use either SPI or I²C. Here the I²C is used. The PCF2129AT is configured to output 1 Hz output clock to PIC. This generates interrupts to update the time. The I²C bus is also available at option connector X4.

On the schematics the IR receiver is marked as TSOP4838. I have used a newer and cheaper model TSOP53438. Either one should work, and also many other types. IR decoding is done in firmware. The IR emitter LED has drive current of 150 mA. This is too high for continuous operation, so the LED must be pulsed with a duty cycle of 1/3 to 1/4.

Joystick switch readout uses internal pull-up of PIC so it can be connected directly. Thermistors are connected to connectors X2 and X3. They form voltage divider with resistors R6 and R7, and the divided voltage is measured with PIC ADC. As stated earlier, the buzzer needs higher voltage drive to generate loud enough sound.

GPS / Glonass module UC530M is configured to use it's internal antenna, so the only external component it needs is a bypass capacitor. It is connected to the PIC via UART. Main purpose of the module on this clock is to provide automatic and accurate time setting.

kello_v40.sch.pdf     26.3.2017 Circuit diagram v4.0.

Board

The PCB for the clock is again designed using Cadsoft Eagle version 5.12. The design is double sided, and design rules are quite relaxed. Most of the components are SMD and on bottom side of board. Only the parts which need to be visible or are too high for bottom side are on top. This minimizes board area since the displays fill up the top side of board almost completely. Segment order for display drivers is same as in previous version. It allows simple routing of all segment signals in one layer. This causes some more work in display driver source code, since the segment order is different for the two displays controlled by one chip.

I have produced the boards at seeed studio. They have the best price for this size of board. The quality of boards was flawless. Also a very nice addition was that they sent a photo of the ready boards to email when they were shipped. The boards have black solder mask which makes the clock look very sleek if you use smoke tinted plexiglass over it. You can order these boards from Seeed from here.

A Digi-Key shared cart which has all the parts except GPS module and joystick switch, click here. The Alps SKQUCAA010 joystick switch is available from RS (P/N 516-316) and Farnell (P/N 1435775). A directly compatible substitute is available from eBay.

The Eagle design files, Gerbers and assembly drawing can be downloaded below:

kello_hw_v40.zip
               26.3.2017 Schematic and board file, designed with Eagle 5.12.
kello_v40_assy_dwg.pdf    29.12.2017 Assembly drawing including bill of materials
kello_v40_gerber.zip          26.3.2017 Gerber and drill file package. Generated with Seeed_Gerber_Generater_2-layer.cam

Firmware

The firmware for the clock is written with CCS PIC-C Compiler. The source files package including compiled .HEX file are available for download below.

The IR receiver code was originally based on San Bergmans's NEC reveiver code and RC-5 receiver code. I have thus simplified them a bit and converted to C. Also the RC-5 code is improved such that it syncs the receiver on each received bit. This makes it much more tolerable to different remotes which may have slightly different timings. The JVC, Samsung, SIRC, Kaseikyo and Matsushita receiver codes are written by me but basically they work with same operating principle (timer interrupt driven state machine). I have also added auto recognition, so the IR decoder state machine identifies the code it receives and processes accordingly.

The GPS receiver code is based on code from CCS customer forums code library posted by PICoHolic.

The code for Bosch BME280 temperature, atmospheric pressure and relative humidity module comes with the CCS compiler. For PIC16 series of chips, the compiled code can be too big to fit in memory segments if all code is inline. This can be solved by adding a #separate directive before int32 _bme280_compensate_H_int32 function. This forces the compiler to realize this function as separate, not inline, and allows the code to fit in the memory segments. I also noticed that there was one incorrect register address in the CCS provided driver, which was causing oversampling settings not properly set. I have reported this to CCS so it will probably get fixed in future. The fw v0.91 package below includes a .diff file which can be used to patch the bme280.c file to fix this bug and add the #separate directives.

All the rest of the code, including drivers for TLC5925 and PCF2129 chips is developed by me. You can freely use and modify them for your own use, but use of them for commercial purposes is prohibited without written permission from me. You can find contact info at beginning of the source files or at bottom of this web page.

kello_v40_fw_v06.zip    26.12.2017 Source files for HW v4.0, FW v0.6. Contains .HEX compiled with CCS version 5.054.
kello_v40_fw_v09.zip    3.2.2018 Source files for HW v4.0, FW v0.9. Contains .HEX compiled with CCS version 5.076. This version adds support for GPS module, time zones, daylight savings time, BME280 barometer / humidity module and lots of small optimizations.
kello_v40_fw_v091.zip   7.9.2018 Source files for HW v4.0, FW v0.91. Contains .HEX compiled with CCS version 5.080. This version adds support for master/slave function, alarm, dew point calculation, Kaseikyo and Matsushita IR protocols, date / time / temperature formatting and day of week display

page created 25.12.2017
last updated 7.9.2018 webmaster@kair.us

kair.us/ projects/ seven segment wall clocks/ kello version 4