Fibonacci Clock V2

Usermanual

09:39 o'clock

> 09:39:55 (less than 5 seconds before 09:40:00)

09:40 o'clock

Note: the greenish yellow on the top left square

(value of 2) is a deviation to the other pixels

Introduction

When I saw the description of the Fibonacci Clock at Instructables by Philippe Chrétien I had to order and build one myself.

http://www.instructables.com/id/The-Fibonacci-Clock/?ALLSTEPS

https://github.com/pchretien

What a great idea to design a clock like this! Fantastic!

Philippe has published every detail and encourages to hack the clock to your own requirements. And that is what I did. The result is the following description of my clock. I added a new Fritzing schematics without taking care of how it looks like on the breadboard page because the schematics sheet is the base I work with.

Sorry for the vague pictures on the front page but I hope you get the idea.

Modifications

Accurate clock

Because I hate clocks that are not running on time I wanted to be able to synchronize the clock with my DCF77 clock up to the full minute. While setting the time this requires a display not only of the hours but also of the minutes (5 minutes increment) as well as the four minutes in between.

Because my RTC is loosing 6 seconds a day I think am going to replace the DS1307 by a DS3231. The DS3231 is far more accurate. Still to be implemented.

Hourly chime

A nice feature is an hourly chime using a piezo buzzer. So for the last five seconds before the full hour a beep will sound every second and on the hour a longer beep with a higher pitch. To controll the volume of the buzzer I included a potentiometer in the buzzer circuit. The chime can be shut off automatically during the night.

Automatic brightness controll

To controll the brightness I added an LDR so the ambient lightlevel is measured and the brightness of the display is set accordingly: high brightness level in a very bright environment and a low level in the dark.

Minute display LEDs

Because I would like to see something happening on the clock every minute I also wanted to see the four minutes (0 – 4) between the 5 minute resolution of the original clock. I came up with 5 extra 3mm clear leds that are mounted at the right side of the 5 value square of the clock.

There are 4 green leds and at the top there is an orange led with two possible functions. So for every minute in the range of 0 – 4 there are an increasing number of leds lit.

The orange led can be set as AM/PM indicator but as an alternative it can be set to be lit for the last five seconds as an indicator that that a new 5 minute count is imminent.

Brightness controll for the 5 LEDs

To be able to controll the brightness of the 5 leds as well I added a transistor in the common cathode lead of all leds. This transistor is controlled via a PWM port of the Arduino so all leds are controlled by just one output port.

Setting the parameters

The five LEDs are also used during the setup of the clock showing the value of a parameter as a binary value. Five LEDs can show values between 0 – 31.

Loading/Saving the parameters to EEPROM

I have used the EEPROMex library written by Thijs Elenbaas. This enables one to keep all parameters in a struct and load/save it in one go from/to EEPROM.

When the settings are not loaded correctly (maybe not in EEPROM yet) the default settings are used. See the serial monitor for relevant messages. You can save the settings by selecting parameter number 22 during setup mode (see below).

Alarm

I have implemented an alarm as well. The hardware is available for it: we will use the buzzer. It is just a matter of adding some code in the sketch.

MP3 player to play the chimes

I have ordered some MP3 player boards which can be triggered to play an MP3 file by pulling a pin low (to GND). It even comes with a small spreaker.

To be implemented yet.

For details see Brett Olivers description at

http://home.btconnect.com/brettoliver1/Regulator_Clock/Regulator_Clock.htm#code

or Google for: JQ6500-28P or JQ6500-16P

Hardware modifications

For all this to work a few modifications and extra components are required on the original PWA. Another option is to build a new PWA with all mods and connectors.

I used/modified the original board because I did not want to put it aside and have it gather dust for ever.

So here is a list of the modifications on the original PWA.

For the five leds: add five resistors and a universal transistor with a resitor in the base lead, plus a female connector for all wires to the leds.

For the buzzer and LDR assy: add a resistor for the transistor at the buzzer and a connector.

Cut a few traces to rewire a few Arduino ports because PWM has impact on a few digital ports. Note: maybe the cutting/rewiring is not necessary anymore because at first I used all PWM outputs of the Arduino to dim the leds; later I implemented the transistor plus resistor and used only one PWM port. I have to check!

External components

LDR/buzzer assy

For the LDR, the buzzer + transistor + potmeter, I cut a small experiment board to solder the parts and the wires with connector on it.

For the LDR drill a hole at the top right back corner of the case 15mm from the right and 15mm from the back. For the buzzer dril a hole in the top left corner of the back panel (as viewed from the back of the clock) 15mm from the left and 12mm from the top of the panel. Push the buzzer in the hole from the back and hot glue the buzzer/ldr assy to the back of the panel.

Minute LEDs

For the five leds you will need 5 clear 3mm leds: 4x green and 1x orange.
I drilled 5 holes of 3mm diameter (and 7 mm at the back so the leds can be pushed a bit more to the front) in the plexiglass. The bottom led is 35mm from the bottom side and 25mm from the right side of the front plate, and led to led spacing is 15mm. The leds are glued to the front plate with clear hobby glue.

Then I wired all the leds: five anode wires and one common cathode wire to a connector. Note: use very thin wires so the light is not blocked or as little as possible.

LED string mod

I had to modify the first led of the led string of the value 5 leds because it was interfering with the PWA. For this I had to cut the plastic just passed the soldering pads on the little pcb in the led. Now I was able to (or I had to) solder new wires. Note that there is an input side (with the arrow on the pcb) and an output side (with the little chip). The input side is connected to the value 3 leds and the output side is connected to the other three value 5 leds.

Firmware/software modifications

Buttons library, Metro library and FSM

To be able to use the four buttons in a more flexible way and to implement a brightness controll I had to remove all blocking code in the original sketch and used the Buttons library written by JChristensen

https://github.com/Jchristensen/Button

and the Metro library by Thomas Fredericks

https://github.com/thomasfredericks/Metro-Arduino-Wiring

For the timers and I implemented a FSM (finite state machine).

FSM means that the clock can be in various states: the RUNNING, TO_SELECT, SELECT (an intermediate state) states, and finally the SETTINGS state.

To get from the RUNNING state into the SETTINGS state the user must press and hold the white button for two seconds (a long press).

In the SELECT state the user has to select a parameter to change by pressing the UP (black) button and the DOWN (green) button and then press the SELECT/DONE (red) button when this is the correct parameter.

In the SETTINGS state the user modifies the value of the parameter by again using the UP/DOWN buttons.

When done the user presses the SELECT/DONE (red) button again to confirm the setting and return to the RUNNING state.

Value display on the LEDs

To be able to see which parameter to change and the value of the parameter the LEDs are used as a binary display. The led at the bottom is the least significant bit (LSB) and the top (orange) led is the most significant bit (MSB). So we can display a value from 0 to 31.

Setting the clock

Setting the time we will use a different method displaying the values.

When setting the hour and the minutes (with 5 minute increments) the value is displayed on the Fibonacci display: red squares when setting the hour and green squares when setting the minutes.

The color pattern for every digit is fixed so the user can get used to the pattern when setting the time.

The orange led at the top is now used as AM/PM indicator.

The 0–4 minutes not shown on the Fibonacci display are shown on the four green leds and can be set as well. The greater the value the more leds are lit (like an analog thermometer) as is shown in clock mode.

Setting the parameters

Setting the parameters starts by a long press of the SETTINGS (white) button. The green leds are starting to flash fast with the last parameter number that was used.

By pressing the UP (black) or DOWN (green) buttons the parameter number can be changed. After pressing the SELECT (red) button you can change the value of the parameter. The leds are now flashing slow.

Parameter listing

Which parameter number to select for a parameter to change its value is shown in the list below.

Hours	The current hour is shown on the Fibonacci display using the red
colour, also the top orange led is used as AM/PM indicator.

Minutes	The current minutes (as multiple of 5) is shown on the Fibonacci
display using the green color.

Minutes<5	The 4 minutes in between are shown on the green leds.

Full minute sync	Synchronise the clock with an external clock at the moment the
second hand shows zero seconds. If seconds >= 30 then the
minutes are automatically incremented and the seconds will be reset
to zero. Note: you can also press the DOWN (green) button when
the clock is running. See description below.

Alarm	1=alarm_off, 2=alarm_on
Note: when the alarm sounds you can turn it off by pressing the
UP (black) button.

Alarm hours	Set the hour for the alarm, 0 - 23

Alarm minutes	Set the minutes for the alarm, 0 – 11 (multiples of 5 minutes)

AM/PM	1=the orange led is used as 5th minute indicator for 5 seconds
2=the orange led is used as AM/PM indicator

Mode	Set the mode of the unit: 1=CLOCK, 2=RAINBOW, 3=LAVA

Interval	Set the speed for the color changes in the Rainbow/Lava modes.
Values: 0 –-> 31 (translates to 16 – 512).

Palette	Set the palette used in CLOCK mode. 1 = the default: RED for the
hours, GREEN for the minutes, BLUE for both hours and minutes,
YELLOW for none.

Chime	1=chime_off, 2=chime_on

Chime start	The starting hour the chime is active (0 - 23).

Chime end	The last hour the chime is active (0 – 23).

LDR min	The minimum level measured.
Values: 0 --> 31. (translates to 32 – 1023).

LDR max	The maximum level that is measured.
Values: 0 --> 31 (translates to 32 – 1023).

Display	1=display_off, 2=display_on

Display min	The minimum brightness level for the display.
Values: 0 --> 31 (translates to 8 - 255).

Display max	The maximum brightness level for the display.
Values: 0 --> 31 (translates to 8 - 255).

Minute LEDs min	The minimum brightness level for the minute LEDs (0-31,
translates to 8 - 255).

Minute LEDs max	The maximum brightness level for the minute LEDs (0-31,
translates to 8 - 255).

Save settings	After changing one or more settings you have to save the settings to
EEPROM so after a power up the settings are restored.

Print parameters	Print all parameters on the serial monitor.

Power On Diagnostics

When you press the UP (black) button during the boot sequence - press until the beep sounds - the clock will show several tests:

minute leds show an increasing minute count

low/high brightness of the minute leds

display shows all colors (Red, Green, Blue) plus all combinations of two colors and the white color.

low/high brightness of the displayed

hour (red) count 1-12

minute (green) count 1-12 (or 5, 10, ...60)

both hour and minute count 1-12 will show in blue

Full minute sync

You can use this feature synchronize the clock conveniently when the clock is gaining max 29 seconds or is maximum 30 seconds slow. Otherwise you need to set the time as described above.

When the time is displayed and you want the RTC to synchronize with an external accurate clock you can press/release the DOWN (green) button at the moment the external clock shows a full minute (seconds hand is at 12).

When the seconds count of the RTC is greater or equal than 30 seconds then the minute count is incremented by one and the seconds are reset to zero.

Note

"Setting" parameter number 4 will have the same result: first select parameter number 4 and then press SELECT/DONE at the full minute of the external clcok. You can cancel this procedure by pressing the UP or DOWN button.

Summary of operation

To run diagnostics after a power-off / power-on cycle press and hold the UP (black) button until the buzzer sounds.

When the clock is running you have the following options.

UP (black) button	- Turn off the alarm.

DOWN (green) button	- Full minute synch

Long press SETTINGS (white) button. - Enter the settings mode.

To save the settings to EEPROM you just have changed in step 3 you have to select parameter 22 in step 3 and press SELECT/DONE to save the settings. To cancel the save settings just press the UP or DOWN button.

Settings overview

You can print this page and cut the frame below and glue it on the back panel of the clock.

Hours	Set the hour

Minutes	Set the minutes (multiple of 5)

Minutes<5	Set the 4 minutes in between

Full minute sync	Synchronize with external clock	UP / ALARM OFF

Alarm	1=alarm_off, 2=alarm_on

Alarm hours	Set the hour for the alarm, 0 - 23

Alarm minutes	Set the minutes for the alarm, 0 – 11

AM/PM	1=the orange led is 5th minute indicator

2=the orange led is AM/PM indicator	SELECT / DONE

Mode	1=CLOCK, 2=RAINBOW, 3=LAVA

Interval	Speed for the color changes

Palette	1 = the default: RED, GREEN, BLUE, YELLOW

Chime	1=chime_off, 2=chime_on

Chime start	Chime starting hour (0 - 23).

Chime end	Chime end hour (0 – 23).	DOWN / SYNC

LDR min	The min level measured (0 --> 31)

LDR max	The max level measured (0 --> 31)

Display	1=display_off, 2=display_on

Display min	The min brightness level display (0 --> 31)

Display max	The max brightness level display (0 --> 31)	SETTINGS

Minute LEDs min	The min brightness level minute LEDs (0-31)

Minute LEDs max	The max brightness level minute LEDs (0-31)

Save settings	Save the settings to EEPROM

Print parameters	Print all parameters on the serial monitor

geekoclock.com

Files

This update to version 2 consists of the following files

FibonacciClockV2Manual.odt	this document in LibreOffice odt format

FibonacciClockV2Manual.pdf	the PDF version of this document

FiboClock2.fzz	Fritzing project containing the schematics page

FiboClock2_schema.pdf	the export to PDF of the schematics page

FibonacciClock.ino	the version 2 sketch

Metro.h and Metro.cpp	Modified (I think) Metro library

The libraries (Adafruit_NeoPixel, RTClib - Adafruit, Button, Metro, EEPROMex) can be downloaded :

https://github.com/adafruit

https://github.com/JChristensen/Button (modified)

http://playground.arduino.cc/Code/EEPROMex

http://playground.arduino.cc/Code/Metro (for reference only)

For reference you can use this ATMega328 pinout page: http://www.pighixxx.com/test/portfolio-items/atmega328/?portfolioID=337

Pictures

To get an idea of all the modifications below a few pictures.

PWA modifications

Modifications on top of the board.

At the bottom left the connector for the LDR and buzzer.

On the right the connector with resistors for the minute LEDs,

below the connector the transistor and resistor for brightness controll of the LEDs.

Modifications at the back of the board.

At the top the connector for the LDR and buzzer,

below that the resistor for the transistor driving the buzzer,

the white wire is for measuring the brightness.

LDR and buzzer assy with potmeter to control the volume and connector

The modification of a LED from the string.

Modification of the first 5-value LED in the string so that the

circuitboard has got more room to be mounted on the backpanel.

The extension wires had to be resoldered to the LED.

Here you can see how much lower the board can be mounted between the other LEDs

The minute LEDs

The connector plus wiring for the minute LEDs

The wiring inside the 5-value square

All put together

All connected and powered up.

The LDR on bottom left slides in the hole in the case

while positioning/closing the back panel.

The settings overview pasted on the back panel.

To Do

What I may change later:

Replace the DS1307 RTC with a DS3231 for more accuracy. The RTC on my board runs for 2 seconds a day and another RTC is even running slow 6 seconds a day.

DS3231 RTC module

I would like to build a clock with an Arduino, display and DCF77 radio receiver or a GPS recever. This can output a minute synchronisation signal so other clocks - like this one - can be synced automatically. In that case a DS1307 would be acceptable.

Modify the RTC library to deal with daylight saving time during the summer.

Add an MP3 player which can be triggered by the Arduino to play a chime every 1/4 (Westminster chime) or every 1/2 hour and a full hour chime.

JQ6500-16P
5 trigger pins, speaker output (mono), audio output (stereo)

To ease reprogramming extend the FTDI connector with wires and male/female connectors and glue the male connector to the back panel.

Fix some minor bugs ...