TINY WATCH TIME
Here is my design for a clock based on minimalist ATtiny 85 using 12 LEDs, arranged as a clock dial, to display the analog time style:
The clock of time based ATtiny85; It is four and five.
To display the time of pressing the button on the face of the watch, and then shows the time for four seconds. A LED will light up to show the time and flashes another LED to show the minutes to the next five minutes, as the hour and the minutes on a clock. If there is only one LED lights you know that both hands are pointing at the same time of game.
The clock uses tiny ATtiny85 early time oscillator built-in, tune to get it as accurate as possible, and my watch keeps time within a couple of minutes over 24 hours. You can adjust the time by pressing the button for more than four seconds.
It is powered by a CR2032 button cell, and I used several techniques to reduce power consumption, so the battery should last more than one month. The total cost of components, excluding PCB, is around £5 / $5, and is easy to build.
You have inspired me to design this watch after reading about empollon Watch from Sam De Rose, which takes the minimalism a step further. It seems fortuitous that you can drive 12 LEDs of four lines of E / S using Charlie plexing, exactly the number needed to show a clock face, taking advantage of the fact that you can drive two LEDs in each pair different from the lines of E / S. You need one extra line of E / S to detect press button, carefully using the five lines of E / S available on the ATtiny85.
ATtiny85-based time clock circuit.
I built the clock on a small printed circuit board, the use of SMD-components with the components apart from the battery holder welded to one side of the Board. I have used an ATtiny85 SOIC and 0805 resistors and LEDs, so they are relatively easy to hand soldering. I managed the LEDs to avoid roads that run in the provision that explains the order of all random, but this is easily accommodated in the software. The following table shows which LED lights when taking a line of E / S high and the other line of E / S low:
The button is a button miniature SMD available from Spark fun button  , available in Proto-PIC in the United Kingdom  , and the battery holder is a support type SMD 20 mm also available from Spark fun button  , or proto-PIC in the United Kingdom  .
LEDs are size 0805, and I chose white LEDs, since they tend to be the most brilliant. I got mine from shiny components in the United Kingdom, selling them for less than £1 for each ten . LEDs should be welded with the same orientation, with the negative sides facing the center of the Board.
I designed the Board in Eagle and as an experiment sent both Seeed Fusion and the SST Park  for the manufacture.
There is a link to the archives of the Eagle at the end of the article, if you want to create a table. On the other hand, since the track design avoids changes of face can be a single face plate, milled using a milling machine as the Other mill; you could then paste the bracket of the battery to the other side, and connect through two holes to the main circuit.
I used a heat gun You yue 858 d + 250 ° c for soldering SMD components on the front of the Board, and, finally, welded to the battery holder on the back of the plate using a conventional soldering iron. If you don’t have a heat gun that must be able to weld with a little care SMD components using a soldering iron tip fine.
This section explains the different sections of the program tiny time clock.
The 12 LEDs are powered by four e / S lines PB0, PB1, PB3 and PB4. PB2 is used for the push button, because it assigns to the INT0 interrupt, which makes detection easier button.
The first row of the array specifies what LEDs have their cathodes connected to PB0: LED at 10 o’clock its anode grounded PB1, LED to 2 has its anode attached to PB3, and those aimed at 12 ‘ clock has its anode connected to PB4.The values of the array corresponding to PB2 are set to –
I used to timer / Counter0 running at 250 Hz so much to count the number of seconds, and multiplex screen.
First seconds, Secs, each 250 calls counter is increased.
Then, if the display is lit, called Display Next Row () to show the next row of LEDs.
Finally, the variable is counted back wait time of to blank the screen automatically after four seconds the button has been pressed.
If the button is held down for more than four seconds, the time begins to move forward 5 minutes every half-second, that allow you to set the correct time, until you release the button.
Up to two LEDs can be lit at the same time. Specified by the variable hours LED is used to display the hours, and is displayed continuously. LED specified by the Five mins variable is used to the minutes, and flashes every 32 times the routine is called.
The bottom two bits of the variable cycle of to determine which row is being displayed. For a given row the matrix buttonsis checked to see if any of the LEDs on the row needs to be displayed, or plywood. If so, the appropriate bits are set in the variable of bit of . This is then written in the port.
The push button is connected to the input INT0 interrupt, which generates an interrupt to display the time. It was created in setup () in the following way:
I decided that since the clock displays only the time to within five minutes, is round weather for the next five minute mark, so are the first instead of evening appointments! The correction in the calculation of Five mins 299 accomplishes this.
My first version of the monitoring program shows the number of hours as an illuminated light continuously and the mark of five minute, as a flashing light, but for times after half hour after giving a confusing display. For example, clock 02:50 would turn on the 2 and 10 LEDs, but one’s instinct is to read it as one and fifty; i.e., 1:50. Therefore, the current version shows times later than half past the hour for the following number of hours lighting, which gives a more familiar screen. This is implemented with the correction of 1799 in the calculation of the hours .
The Reduction of the Current Consumption
I wanted to make the last watch the as long as possible with a single battery. Due to the internal oscillator is used to keep the moment it is not possible to save energy by putting the processor to sleep, and the watchdog timer is not sufficiently precise for the normal time. Therefore, I have investigated other forms of energy-saving.
The 5V power consumption while none of these energy-saving was 1.68 Ma. These are the techniques used, with consequent energy saving in parentheses after each one:
If by mistake to reduce the system clock below 500 kHz that won’t be able to reprogram the chip using ISP (In-System Programming), since the processor is not working fast enough to carry out the instructions to erase the flash memory. I have therefore included a delay of 5 seconds before reducing the clock speed; If ISP fails, reset the processor and try again within 5 seconds, and then it should work.
Final energy consumption is approximately 0. 36mA to 5V, falling to 0. 23mA 3V. A typical CR2032 battery has a capacity of 225mAH, so it should last more than one month.
The Compilation of the Program
I have compiled the program using Spence Konde new and excellent underlying ATtiny, which is now compatible with all ATtiny processors and replaces several previous ATtiny nuclei  . Select the series ATtinyx5 option under the heading universal ATtiny on the together in menu. Select the 1 CPU clock timer , BOD persons with reduced mobility ,ATtiny85 , 1 MHz (internal) of the following menus. This is the new ATtiny85s configuration fuse by default; otherwise select Burn Boot loader to set the fuse properly.
I have loaded the program using a clip that attaches to the top of the SMD ATtiny85  , using AVR programmer Spark fun Pocket  . The advantage of this over the Tiny Board AVR programmer that I usually use is that it allows you to set a circuit while it is powered by its own supply, by not having to remove the tiny watch button battery time.
The Internal Oscillator Calibration
To avoid the need for a glass, and two pins E / extra S that would be necessary, the clock uses the internal oscillator ATtiny85 by its timing. The internal oscillator is not as accurate as a Crystal, but it includes the ability to set, to get the clock as accurate as possible.
I decided to calibrate the clock by adjusting the timer / Counter0 party comparison value, OCR0A, instead of using the OSCCAL register for calibration. OCR0A value allows us to adjust the calibration of approximately 0.25%, while OSCCAL calibration is approximately 1%. In addition, the calibration OCR0A is linear, so after measuring the error you can calculate what should be the value. I have used the following procedure:
- Promote a CR2032 battery clock, as the oscillator is affected by the supply voltage.
- Run the following program to generate a frequency pin PB0.
- Measure the frequency with a frequency meter, and recompile with different values of OCR0A testing program.
- Adjust the value until you get as closely as possible the frequency to 1000 Hz.
- Copy the OCR0A value to routine in the program settings () Tiny monitoring time.
- I found it took me only a few minutes to get the frequency inside better than 1 Hz 1000 Hz.
- If you don’t have a frequency meter that could run the clock for a couple of hours, and then from the time error of calculating the adjustment you need to take.
- Here is the entire Tiny clock time program:case of weather monitoring program .
- On the other hand, get that on Git Hub here along with the Eagle for the PCB files:tiny time on Git Hub watch .