I scraped some old electronics in hope of finding some useful components for my hobby projects. From the old PVR device I managed to detach 4-digit seven segment display without breaking it.
I decided to build up a nightstand clock which have seven segment display as only visible part and rest of body hidden on the back side of the desk.
My first plan was build the clock around NE555 timer and different CMOS logic chips, but quite soon I realized I need to use micro-controller in this project. Otherwise complexity and size of needed circuit would get out of hands.
After short Google-session I ended up to Arduino as it is relatively cheap and I found more than enough different tutorials and guides written by its active community. In addition Arduino is not only a micro-controller, but the board includes all required external HW components to function properly. It needs only power supply and of course SW to control it.
Smallest Arduino model is Pro Mini so I selected it for this exercise.
Here's picture from the built clock in the "production use"
And backside:
Ancient mobile phone charger is perfect for providing power for the clock as it was retired from active duty already some time ago. Output voltage is ~7V and it provide enough current (~300...400 mA) for this project. However 7V is not suitable for all selected components. Fortunately Arduino has regulator on the board which outputs 5V to VCC pin, if charger is connected to RAW pin.
Even though Arduino has enough GPIO pins to directly control seven segment display I added BCD to seven segment decoder logic between Arduino and the display. It converts 4-bit integer value to control signal for single seven segment digit.
Each digit in seven segment display needs to be driven separately. While segment leds in one digit are powered other 3 digits are off. If active digit changes fast enough (few milliseconds) and all digits are repeatedly powered in sequence, it looks like all digits are active at the same time.
I added also two buttons to manually adjust clock time. There's separate button to increase hours and minutes.
I didn't want to start creating separate circuit board so I placed all components to veroboard. I designed the circuit with TinyCAD and exported netlist to VeeCAD, which is great tool for placing and connecting components in veroboard.
Below is picture of the clock with all components soldered.
Then was time for some mechanical engineering. I cut small piece of sheet metal, bend it to correct shape and finally paint it with black spray. Before attachment to the desk the clock looked like:
Naturally this was so specific project I had to write most of the SW with myself without possibility to use copy-paste engineering. It was also excellent introduction to micro-controller programming. Compared to SW development in PC side Arduino micro-controller (ATmega328) has significantly less space for program as well as very limited amount of RAM. Maximum program size is 32kB and only 2kB RAM is available for the program.
After some time I noticed that lack of real time clock functionality starts to annoy me when each power cut will basically reset the the clock time. Also ATmega328 internal clock is not very accurate and time shift of one or two minutes starts to be visible after a month usage.
I found inexpensive and rather small RTC module from DealExtreme, which would keep the accurate clock time in normal usage and restore correct time after the power cut. The module is based on DS3231 RTC chip. It has small battery for keeping the time when external power is not available and also supports I2C communication. With Arduino I2C library the communication started to work quite easily once the module was connected to Arduino I2C pins.
Now the clock has battery backed up clock time and SW has even support for automatically adjusting time for daylight time savings.
RTC module is located in top right corner of the picture. The module is just glued on top of board and two I2C wires soldered to Arduino and one to ground.





No comments:
Post a Comment