update README

This commit is contained in:
King Kévin 2016-06-12 23:53:18 +02:00
parent 2d26686233
commit db345fedb5
1 changed files with 43 additions and 25 deletions

View File

@ -3,10 +3,11 @@ The purpose is to have LEDs on the circumference of the clock to show the progre
For that you will need:
- a WS2812b RGB LEDs strip (long enough to go around the clock)
- a development board with a STM32F103 micro-controller and 32.768 kHz oscillator for the Real Time Clock (such as the blue pill)
- a WS2812B RGB LEDs strip (long enough to go around the clock)
- a development board with a STM32F103 micro-controller equipped with a 32.768 kHz oscillator for the Real Time Clock (such as the [blue pill](https://wiki.cuvoodoo.info/doku.php?id=stm32f1xx#blue_pill)), or using a external [Maxim DS1307](https://www.maximintegrated.com/en/products/digital/real-time-clocks/DS1307.html) RTC module
- a coin cell battery to keep the RTC running (optional)
- a GL5528 photo-resistor to adjust the LED brightness (optional)
- a DCF77 module to set and update the time automatically (salvaged from a radio controlled digital clock)
project
=======
@ -14,7 +15,7 @@ project
summary
-------
The time will be shown as arc progress bars, in addition to the hands of the clock pointing at the current time.
The time will be shown as arc progress bars, in addition to the original hands of the clock pointing at the current time.
The hours passed since the beginning of the midday are shown using blue LEDs.
The minutes passed sine the beginning of the hour are shown using green LEDs.
Whichever progress is higher will be shown on top of the other.
@ -27,40 +28,39 @@ The (gamma corrected) brightness of the last LED shows how much of the hour, min
technology
----------
The LEDs are controlled using a [STM32 F1 series micro-controller](http://www.st.com/web/en/catalog/mmc/FM141/SC1169/SS1031) (based on an ARM Cortex-M3 32-bit processor).
The board needs to include a 32.768 kHz oscillator for the Real-Time-Clock (RTC).
Preferably use a [blue pill](https://wiki.cuvoodoo.info/doku.php?id=stm32f1xx#blue_pill) board.
The board needs to be powered by an external 5 V power supply (e.g. through the USB port).
To set the time connect using serial over the USB port (providing the CDC ACM profile) or USART1 port (TX and RX are on pin PA9 and PA10) and enter "time HH:MM:SS".
Optionally connect a 3 V coin battery on the VBAT pin for the RTC to keep the correct time in case the main power supply gets disconnected.
To know the charge of the coin cell connect its positive terminal to ADC channel 1 on pin PA1.
The level of the battery will be shown on the LEDs just after a restart, and the voltage will be shown over serial.
To avoid the micro-controller to drain the battery trough the GPIO when un-powered use an NPN transistor, with the collector on the battery, the emitter on the pin, and the base on Vcc.
If you don't want to use this feature connect PA1 to ground.
The brain of this add-on is a [STM32 F1 series micro-controller](http://www.st.com/web/en/catalog/mmc/FM141/SC1169/SS1031) (based on an ARM Cortex-M3 32-bit processor).
For the LEDs use a 1 meter LED strip with 60 red-green-blue WS2812b LEDs.
To keep track of the time a Real Time Clock (RTC) is used.
If the board includes a 32.768 kHz oscillator (such as a [blue pill](https://wiki.cuvoodoo.info/doku.php?id=stm32f1xx#blue_pill)) the micro-controller will use the internal RTC.
Otherwise connect an external [Maxim DS1307](https://www.maximintegrated.com/en/products/digital/real-time-clocks/DS1307.html) RTC module to the I2C port and set `EXTERNAL_RTC` in `main.c` to `true`.
Also connect the external RTC square wave output in order to have a sub-second time precision.
Connect a DCF77 module (e.g. salvaged from a radio controlled clock) to the micro-controller.
This will allow to automatically get precise time (at least in Europe) when booting.
Since the RTC is drifting, the time will get updated using DCF77 every hour to keep <0.5 s time precision.
Alternatively set the time using serial over the USB port (providing the CDC ACM profile) or USART port and enter "time HH:MM:SS".
Power the board using an external 5 V power supply (e.g. through the USB port).
This will power the micro-controller, and the LEDs (a single LED consumes more energy than the micro-controller).
To keep the correct time in case the main power supply gets disconnected optionally connect a 3 V coin battery on the VBAT pin for the internal RTC, or in the module for the external RTC.
For the LEDs use a 1 meter LED strip with 60 red-green-blue WS2812B LEDs.
Tape the LED strip along the border/edge of the clock.
Ideally the wall clock has a diameter of 32 cm for the 1 m LED strip to completely fit.
Ideally the wall clock has a diameter of 32 cm for a 1 m LED strip to completely fit.
Otherwise change the number of actually used LEDs in the source files.
Connect the 5 V power rail of the LED strip to the 5 V pin of the board.
Connect the DIN signal line of the LED strip to the MISO pin of the micro-controller on PA6.
SPI is used to efficiently shift out the LED colour values to the WS2812b LEDs.
SPI is used to efficiently shift out the LED colour values to the WS2812B LEDs.
A custom clock is provided for this operation using channel 3 of timer 3 on pin PB0.
Simply connect this clock to the SPI CLK input on pin PA5.
The brightness of the LEDs is dependant on the ambient luminance.
To measure the ambient luminance a GL5528 photo-resistor is used.
Connect one leg of the photo-resistor to ADC channel 0 on pin PA0 and the other to ground.
Connect one leg of a 1 kOhm resistor to ADC channel 0 on pin PA0 and the other to a 3.3 V pin.
Connect one leg of the photo-resistor to ADC channel 1 and the other to ground.
Connect one leg of a 1 kOhm resistor to ADC channel 1 and the other to a 3.3 V pin.
This voltage divider allows to measure the photo-sensor's resistance and determine the luminance.
If you don't want to use this feature, connect PA1 to ground for the highest brightness or Vcc for the lowest brightness.
The blue pill has a 32.768 kHz oscillator for the internal RTC, but don't use the LED next to it as it disturbs the oscillator and the time won't stay right.
In case the time is lagging because RTC oscillation has been skipped, add a button between Vcc and PB8 and each press will increment the time by one second.
If the board does not provide a 32.768 kHz oscillator for the internal RTC it is also possible to use an external RTC such as the Maxim DS1307.
The time is then read over I2C and incremented using the square wave output.
A working example code is under the `DS1307_4096Hz_timer` tag, but needs to be integrated in the latest code state.
board
=====
@ -78,6 +78,24 @@ This is required:
- for the linker script to know the memory layout (flash and RAM)
- map the user LED and button provided on the board
connections
===========
Connect the peripherals the following way (STM32F10X signal; STM32F10X pin; peripheral pin; peripheral signal; comment):
- USART1_TX; PA9; RX; UART RX; optional, same as over USB ACM
- USART1_RX; PA10; TX; UART TX; optional, same as over USB ACM
- I2C1_SDA; PB7; DS1307 SDA; SDA; optional, when using external RTC
- I2C1_SCL; PB6; DS1307 SCL; SCL; optional, when using external RTC
- TIM2_CH1_ETR; PA0; DS1307 SQ; square wave output; optional, when using external RTC
- ADC12_IN1; PA1; GL5528; photo-resistor + 1 kOhm to 3.3 V; without GL5528 photo-resistor connect to ground for highest brightness or Vcc for lowest brightness
- TIM3_CH3; PB0; PA5; SPI1_SCK; generated clock for WS2812B transmission
- SPI1_MISO; PA6; WS2812B DIN; DIN; WS2812B LED strip data stream
- GPIO; PA2; DCF77 PO; \#EN; DCF77 enable on low
- GPIO; PA3; DCF77 TN; DCF77; DCF77 high bit pulses
All pins are configured using `define`s in the corresponding source code.
code
====
@ -103,7 +121,7 @@ flash
The firmware will be flashed using SWD (Serial Wire Debug).
For that you need an SWD adapter.
The `Makefile` uses a ST-Link V2, along with the OpenOCD software.
The `Makefile` uses a ST-Link V2 along OpenOCD software (per default), or a Black Magic Probe.
To flash using SWD run `make flash`.
debug