LED clock on atmega8 microcontroller. Clock propeller on Atmega8

  • 10 alarms for each day of the week.
  • The delay of the signal, if the alarm is not turned off, works after about 5 minutes.
  • 8 alarm clocks on a separate leg of mk, on / off load.
  • Two DS18B20 temperature sensors (indoor and outdoor).
  • Timer 99 hours.
  • The brightness of the indicator is adjustable for day and night.
  • The variable parameter smoothly changes the brightness, as in caller ID.
  • With the loss of 220 volts, the consumption from the batteries is 40 microamps.
  • The alarm clock works in any power mode.
  • The watch can sequentially show up to 4 modes.

The watch has the ability to sequentially show 4 modes, for which one of ten display formats and the time of its display is selected.

display formats.
0
1

Hours-minutes-seconds.

2

Hours-minutes.

3

Hours-minutes, Day of the week.

4

Day_month_day of the week.

5
6
7
8
9
A

b

Temperature 1 sensor, Temperature 2 sensor.

Button F - exit from the mode. Choice of 3 main modes.
SET button - enter the selected mode. Then go to the next parameter (flashing field).
PLUS button - plus / on. Scroll through the main menus in SETUP mode.
MINUS button - minus / __ (off). Scroll through the main menus in SETUP mode.

All modes, except zero and timer mode, have timed completion. If there were no pressings for more than 30 seconds, the zero mode is set.

CALL mode

on/__-alarm clock on/off
Days of the week on which the alarm will go off (here on the 6th and 7th day the alarm is off).
Alarms A B C D E F G H on/off conclusion call a_h mk. The alarm clock is useful for load management. With it, the output call a_h can be set to any number of minutes.
___-off, SET-leg bud. A-H set to 1, CLS set to 0.
n-will work once, o-on. always.

SETUP mode.
To write values ​​to EEPROM, all values ​​in the submode must be confirmed by pressing SET.
Example: LIGHT ->SET-> L.ooooo ->SET->HO4L L.2 ->SET->LIGHT.

PORT mode.

Clock mode.

SEE Set Mode.

display formats.
0

Number, Day of the week, Hour-minutes.

1

Hours-minutes-seconds.

2

Hours-minutes.

3

Hours-minutes, Day of the week.

4

Day_month_day of the week.

5

Temperature 1 sensor, Temperature 2 sensor.

6

Temperature 1 sensor (house sensor).

7

Temperature 2 sensor (outside sensor).

8

Temperature 1 sensor, hours-minutes.

9

Temperature 2 sensor, hours-minutes.

A

Temperature 1 sensor, Temperature 2 sensor.

b

Temperature 1 sensor, Temperature 2 sensor.

In modes where tenths of a degree are not indicated, the point defines more than 0.5 degrees.


Mode USt Bud. Alarm settings.

Bip alarm signal - PWM.
Pin alarm signal - mouth in 1 output bud.
Oba Shim and output.
Signal delay.
When off snooze, the alarm is turned off by pressing any key.
When turned on snooze alarm off button F, when you press the SET PLUS MINUS buttons, the signal is turned off, but it will work again after about 5 minutes, if the alarm is not turned off, then after 8 times it will turn off. automatically.
When the signal delay is active, in zero mode, the point of the last digit flashes.
Delay off (when no signal). In mode 0, pressing SET is on. this mode. The presence of an active backoff induces the symbol about on 4 acquaintances. Pressing PLUS MINUS turns off the delay.

DS18B20 mode.

DEFAULT mode.

Other modes (SETUP).
LIGHTL ooooo - daytime brightness of the indicator.
NIGHT L2 - brightness from 23:00 to 06:00.
SIGNAL after entering the mode, use the plus / minus buttons to select:
budil. S or button. S
respectively, the PWM frequency for the alarm clock and buttons.
When entering these submodes on the indicator:
H004.L000.
The frequency is generated in fast PWM mode (CTC mode). The upper threshold is set by the OCR1A1 register. H004 high byte L000 low byte.
To disable the signal from pressing the buttons - set H000 L000.
If the PIN option is selected in the Alarm Set mode, no PWM signal will be output for the alarm.

Zero action.

F - mode selection.
SET - signal delay cancellation mode
PLUS - Set SEE mode.
MINUS - setting alarms.

If the alarm clock is set to turn on the output, then you can use a chip from a musical card.

The program is written in C in WinAvr.
Download source, HEX and EEP files. clock_t.rar (18 Kb)

When flashing micro, set bits CKSEL3..0 to 0011 (internal RC generator 4 Meg). Program the CKOPT bit (connection of internal capacitors). Then flash the EEPROM, or reset the main variables in the program in this way - SETUP -> DEFAULT -> SET.

Clock on ATmega8.

  • 10 alarms for each day of the week.
  • The delay of the signal, if the alarm is not turned off, works after about 5 minutes.
  • Two alarm clocks on a separate leg of mk, on / off load.
  • Two DS18B20 temperature sensors (indoor and outdoor).
  • Temperature display selection (non-significant zero blanking).
  • Timer 99 hours.
  • The brightness of the indicator is adjustable for day and night.
  • The changeable parameter smoothly changes the brightness.
  • When 220 volts is lost, the consumption from the batteries is less than 40 microamps.
  • The alarm clock works in any power mode.
  • The watch can show up to 8 modes.
  • In the circuit, you can use indicators with a common anode or cathode.

The clock can show up to 8 modes, for which one of fifteen display formats is selected, the time it is displayed and the number of times it will be skipped.

display formats.
0

Number, Day of the week, Hour-minutes.

1

Hours-minutes-seconds.

2

Hours-minutes.

3

Hours-minutes, Day of the week.

4

Day_month_day of the week.

5

Day month Year.

6

Day month year day of the week.

7
8

Temperature 1 sensor (house sensor).

9

Temperature 2 sensor (outside sensor).

A

Temperature 1 sensor, hours-minutes.

b

Temperature 2 sensor, hours-minutes.

C

Temperature 1 sensor, Temperature 2 sensor.

d

Temperature 1 sensor, Temperature 2 sensor.

E

Day of the week day month year.

F

Day month Year.

In modes where tenths of a degree are not indicated, the point defines more than 0.5 degrees.

Button F - exit from the mode. Choice of 3 main modes.
SET button - enter the selected mode. Then go to the next parameter (flashing field).
PLUS button - plus / on. Scroll through the main menus in SETUP mode.
MINUS button - minus / __ (off). Scroll through the main menus in SETUP mode.

All modes, except zero and timer mode, have timed completion. If there were no pressings for more than 30 seconds, the zero mode is set.

CALL mode

SETUP mode.
To write values ​​to EEPROM, all values ​​in the submode must be confirmed by pressing SET.
Example: LIGHT ->SET-> L.ooooo ->SET->HO4L L.2 ->SET->LIGHT .

PORT mode.

Clock mode.

Seconds adjustment. Pressing MINUS resets the seconds to zero. If there were more than 31 seconds, then the minutes are incremented.
The next step is to set the minutes and hours.
Installed:
day, month, year and day of the week.
Clock correction. This value is added or subtracted every hour. Step 0.008 seconds. (50 values), maximum value 0.391. Calculation example: with a correction equal to zero, the clock drift is measured, for example, in 5 days the clock ran by 3 seconds, then the correction is equal to 3/(5*24)=0.025.

SEE Set Mode.

In the zero mode, the clock shows alternately up to 8 modes, for which one of ten display formats and the time of its display is selected (upper table).
1 mode selection.
r 5 selection of one of fifteen display formats.
with 03 the time in seconds that the selected mode will be visible.
n 0 how many times to skip (do not show) mode. Example:
1 r0 c03n0
2 r5 c03n0
3 r4 c02n1
r0; r5; r4; r0; r5; r4; r0; r5; r4; r0; r5; r4; ..
r4; - visible, r4; - skipped.
At time equal to 00 the mode is disabled.

Mode USt Bud. Alarm settings.

Bip alarm signal - PWM.
Pin alarm signal - set to 1 output bud.
Oba Shim and output.
Signal delay.
Specifies the number of signal delays.
When off snooze (00) the alarm is turned off by pressing any key.
When turned on snooze alarm off button F, pressing the SET PLUS MINUS buttons turns off the signal, but will work again after about 5 minutes.
When the signal delay is active, in zero mode, the point of the last digit flashes.
Delay off (when no signal). In mode 0, pressing SET is on. this mode. The presence of an active backoff induces the symbol about on 4 acquaintances. Pressing PLUS MINUS turns off the delay.

DS18B20 mode.

Light mode.

Signal mode.

Reset mode.

Zero action.

F - mode selection.
SET - signal delay cancellation mode
PLUS - SEE setting mode.
MINUS - set alarms.

Every hour, for one second, output PB2(16) is set.

To save money, snooze is disabled in battery mode. It also stops the timer.

Source WinAVR-20060421. Firmware anode, cathode and firmware for a circuit with large indicators. With automatic changeover to summer/winter time.
No change to summer/winter time.
Scheme for large indicators. Sent by Alex.


- alarm.
- thermometer.

1. Functions.

- indication. Alternate.

PLUSMINUS

2. Setting.

2.2. Push buttonMENUSET

Group CLOC:

- minutes;

- clock;

PLUS or MINUS);

with".

Group ALAr:

OnOFF" if disabled;

Group diSP:

tc

tt

EF, BUTr

P

Group LiGH:

A", in junior " OnOF

L_ ".

L¯ ".

L".

2.4. Holding buttonsPLUS/ MINUS

3. Notes.

subject .

Video of the program, about t userwolf2000.

– clock with digital accuracy correction.
- alarm.
- thermometer.
– indication on the seven-segment indicator.
– automatic adjustment of the brightness of the indicator.

1. Functions.

– hours, time display format 24-hour, hours:minutes.

– digital accuracy correction. Daily correction ±25 sec. is possible. The set value of 1 hour 0 minutes 30 seconds will be added/subtracted from the current time.

- alarm. At the set time, short double beeps are heard for one minute. You can turn off the sound ahead of time by pressing any of the buttons. When the alarm is enabled, a dot is displayed in the least significant digit when the time is displayed.

- thermometer. The measured temperature range is -55.0 ÷ 125.0 o C. If the temperature is above 99.9 or below -9.9 o C, tenths of a degree are not displayed.

- indication. Alternate.

- Customizable animation of changing readings.

– use of the non-volatile memory of the microcontroller to save the settings when the power is turned off.

– if you press the button in the main modePLUS, then the time is displayed on the indicators, if you click onMINUS- temperature. When the buttons are released, automatic change of readings resumes.

– automatic adjustment of the brightness of the indicator depending on the illumination.

2. Setting.

2.1. When the power is turned on, the clock is in the main mode.

2.2. Push buttonMENUyou enter the settings mode and select a group of parameters to set. Within the group, the selection of the parameter to be set is made by the buttonSET. In turn, available for installation:

Group CLOC:

- minutes;

- clock;

– seconds (reset to zero when you press the buttonsPLUS or MINUS);

– amount of correction. In the most significant digit, the symbol " with".

Group ALAr:

– alarm activation. On the indicatorOn"if the alarm is enabled, "OFF" if disabled;

– minutes of the alarm;

- alarm clock.

Group diSP:

– time of indication of the current time. In high-order digits, the symbols "tc". Setting range 0÷99 sec. If set to 0, the time will not be displayed;

– temperature indication time. In high-order digits, the symbols "tt". Setting range 0÷99 sec. If set to 0, the temperature will not be displayed;

– selection of animation effect. In high-order digits, the symbols "EF". If set to 0, the change of information will be carried out without effects, if automatic mode is selected (symbol " BUT"), the effects will change one by one. If the mode is selectedr, then the effects will change randomly.

– selection of animation speed. In the most significant digit, the symbol "P". The setting range is 0÷99. One unit corresponds to about 2 ms, the higher the value, the slower the animation.

Group LiGH:

– enable automatic control of the indicator brightness. In the highest order, the symbol "A", in junior " On"if automatic regulation is enabled, "OF" if the brightness is set manually;

– minimum brightness threshold for automatic mode. In high-order digits, the symbols "L_ ".

– maximum brightness threshold for automatic mode. In high-order digits, the symbols "L¯ ".

– brightness level in manual mode. In high-order digits, the symbols "L".

2.3. The parameter to be set flashes.

2.4. Holding buttonsPLUS/ MINUSthe parameter is quickly set.

3. Notes.

1. For the minimum and maximum brightness thresholds, the setting range is 0 ÷ 99, but the program introduces restrictions: the minimum cannot be greater than or equal to the maximum and vice versa.

2. When setting the brightness parameters, the information on the indicator is displayed with the selected brightness value.

3. It is necessary to measure the speed of animation and the time of displaying information. If a slow animation and a short display time are selected, then it may turn out that the information does not have time to fully update before the next shift.

A topic has been created to discuss the materials of the article.

Video of the program, about t userwolf2000.

Hi all! I want to bring to your attention a simple propeller clock that I assembled on the Atmega8 controller. They are made from affordable parts and are easy to replicate and make. The only thing is that you need a programmer to flash the clock controller and the control panel.

A conventional 120 mm fan (cooler) was used to base the clock. You can use any fans for this watch, both with clockwise and counterclockwise rotation, because while I was collecting this watch, I redid the program a little and switched the display of characters from the remote control programmatically.
The circuit of the clock itself is quite simple and is assembled on the Atmega8 microcontroller, for the synchronization of which clock quartz with a frequency of 32768 Hz is used.
The clock is powered by a receiving coil, energy to which is transferred from a generator with a transmitting coil. Both of these coils make up an air transformer.

With the scheme and design of the generator, there were no special problems, since a generator from a plasma ball was used.

The generator is assembled on a common TL494 chip and allows you to change the width and frequency of the output pulses over a wide range.
Even with a gap of a centimeter between the coils, the voltage is enough to start the clock. It should only be taken into account that the larger the gap between the coils, the greater the pulse width needs to be made and, accordingly, the current consumption from the source also increases.

When you turn on the generator for the first time, set the pulse width (duty cycle) to a minimum (the regulator knob is in the upper position according to the diagram, that is, the 4th leg through the R7 resistor is pulled to the 14th, 15th, 2nd leg of the TL-494). We twist the frequency of the generator until the squeak disappears, this is approximately 18-20 kHz (by ear), and if there is something to measure the frequency, then we adjust it accordingly within these limits.
On the generator board, a voltage regulator on the LM317 is additionally assembled, designed to adjust the fan speed.
It is not on the diagram, I did not finish it
. Watch a demo video of the watch in action.

Video.

The clock board itself is attached to the base of the fan. I secured it with double sided tape.

Then I redid the clock circuit a little from a photoresistor to an infrared photodiode (figure below).
In the transmitter, instead of a simple LED, I now have infrared.
The resistor instead of 2k put 100k.


Responsible moments in the manufacture of clocks are the manufacture of an air transformer and the alignment (or rather balancing) of the clock board on the base of the fan.

Take these moments seriously.

Air transformer.

I took a regular 120 mm cooler with bronze bushings as the basis. The clock board is glued to the base with double-sided tape.
We bite off the blades from the cooler and grind and level with a file, sandpaper. Coils are made on a frame from a cable channel. I did not come up with such a design, I just took this idea from the Internet. For winding the transformer, a base is made from a cable channel. Every 5 mm, we make an incision on the sides of the channel and carefully fold it into a circle, select the diameter so that it fits snugly on the plastic base of the fan.

Next, on the mandrel from the cable channel, we wind 100 turns of enameled wire, with a diameter of 0.25.
The current consumption of the assembled transformer, I got 200 mA (this is with a rather noticeable gap between the coils).
In general, together with the fan motor, the current consumption is obtained in the region of 0.4-0.5A.
We also make the primary (transmitting) coil, but we try to make the minimum gap between the coils. The transmitting coil also contains 100 turns of wire 0.3 (you can use the same 0.25).
In the diagram, I have slightly different winding data for these coils.

Hours pay.

The bar with LEDs is made on fiberglass. A hole is drilled in it, a piece of tube from a telescopic antenna is inserted into this hole and soldered to the board (the antenna tube must be cleaned from the shiny coating). You can use any suitable tube, or attach the board in another way, for example, using a screw with nuts.
I connected the board with LEDs to the clock board with an ordinary enamelled (winding) wire, it is more rigid compared to the mounting one and does not fray during rotation.

To balance the entire board, on the other side we glue a screw with a diameter of 3-4 mm with hot glue, screwing various nuts onto the screw on the other side - we achieve minimal vibration.
To check the performance of the clock board - we shorten the photoresistor with a screwdriver, tweezers, while the LEDs should blink.
The clock starts working when 5V (logical unit) appears on the 5th leg of the atmega. That is, when the photoresistor is illuminated, there should be 5V on the 5th leg,
When the photoresistor is not illuminated, there should be a logical 0 (about 0V) on the 5th leg of the atmega, for this we select a resistor to the ground from the 5th leg. The diagram is 2 kOhm, I got 2.5 kOhm.
At the bottom, on the base of the fan, we glue the LED so that with each revolution of the fan motor, the photoresistor passes as close as possible to the light source (LED).

Remote Control.

The control panel is designed to control the operation of the clock, switch display modes by indication (change the direction of rotation of the fan), set the clock time.

The remote control circuit is assembled on an ATTINY2313 microcontroller. On the board, the MK itself is installed with a strapping and six buttons designed to control the clock.

I did not assemble the case for the remote control, so only a photo of the board itself.

Information on the purpose of the remote control buttons;
H+ and H- clock setting
M+ and M- minutes setting
R/L direction change (for clockwise and counterclockwise screws)
font font change (thin, bold and inscription website)
when labeling the site with the H + and H buttons - the width of the label is adjusted.

The attached archive contains all the necessary files for assembling the watch;

Archive for article

If you have any questions about the watch design, ask them on the forum, I will try to help and answer your questions as much as possible.

This article describes the design of digital hours on Attmega8 microcontroller, which are equipped with a stopwatch, alarm clock, countdown timer. The watch has the function of displaying the day of the week and date with the possibility of a combined display of date and time. There is automatic switching to summer and winter time, as well as accounting for a leap year.

The display is built on six 7-segment LED indicators with brightness control. The watch is also equipped with battery backup.

Description of the design of the microcontroller clock

As mentioned above, the watch has a six-digit display, consisting of two three-digit displays T-5631BUY-11, operating in multiplex mode. The indicator anodes are grouped by ranks and switched using transistors T1 ... T6.

The cathodes are grouped into segments and are fed directly from the IO1 Attmega8 microcontroller. The multiplexing frequency is 100Hz.

The clock is controlled by a low-frequency quartz resonator X1 with a frequency of 32768 Hz. By activating the CKOPT bit, which allows the use of internal 36pF crystal capacitors, there is no need to use external capacitors.

In case of problems with starting the generator, you can try to connect 2 capacitors of 22pF each. For even greater clock accuracy, you can turn off the internal capacitors altogether (reset the СKOPT bit) and leave only the external ones.

The REP1 piezo emitter emits an alarm signal and signals the end of the timer. During a beep, a log.1 appears at pin 16 (port PB2). This signal can be used to control any load.

The clock is controlled by three buttons - minutes, hours and mode. The buttons are connected through resistors that protect the ports of the Attmega8 microcontroller. The circuit is powered by a 5 volt source (7805). The current consumption mainly depends on the number of active indicators, as well as on the degree of brightness adjustment.

At maximum brightness, the current consumption reaches 60 mA. The clock is equipped with a backup battery. While running on battery power, the watch enters an economy mode where the display is off. Also, in this mode, the buttons are not active, except for the case when it is necessary to turn off the sound signal.

The backup voltage is from 3 to 4.5 V. This can be one 3V battery, three NiMH or NiCd 1.2 V each, or one Li-Pol or Li-Ion battery (from 3.6 to 3.7 V). The current consumption from a 3V battery is only 5…12mA. The battery life of the watch in economy mode from a 3V CR2032 battery with a standard capacity of 200mAh should theoretically be enough for about 2.5 - 3 years.

The software for the microcontroller is at the end of the article. The configuration bits must be set as follows:

Clock management

The clock is controlled by TL1-minute, hour-TL2 and TL3-mode. The hour and minute buttons are used in watch mode to set hours and minutes. In other modes, they have different functions. The mode button switches between different modes, of which there are 8 in total:

Mode 1 - Clock

In this mode, the display shows the current time in the format "HH.MM.SS". The clock button is used to set the clock. Minute button to set minutes. Pressing it resets the seconds.

Mode 2 - Enabling Daylight Saving Time and Year Setting

Here you can turn on and off the automatic changeover between summer and winter time and set the year. Data in the following format "AC 'RR" (AC - automatic time, space, last two digits of the year).

Mode 3 - Countdown Timer

This mode allows you to organize a countdown from the set value to zero. After this time has elapsed, an audible signal will sound and LED1 will light up. The beep can be stopped by pressing the Mode button. Data in the following format "HH.MM.SS". The maximum possible value is 99.59.59 (almost 100 hours).

Mode 4 - Combined output of information

In this mode, alternately displayed:

  1. current time in "HH.MM.SS" format
  2. date in the format "AA.DD.MM."

Each format is displayed for 1 second. In this mode, the Hour and Minute buttons are used to adjust the brightness of the display (Hour-, Minutes+). Brightness changes logarithmically in 6 stages: 1/1, 1/2, 1/4, 1/8, 1/16 and 1/32nd. Default is 1/2

Mode 5 - Setting the day of the week and the alarm mode

In this mode, you can set the day of the week - from Monday to Sunday (displayed as Mon, Tue, Wed, Thu, Fri, Sat, Sun), turn on the alarm and select its operating mode. Data in the following format "AA AL._" (weekday, space, AL., alarm setting).

The clock button sets the day of the week. The minute button is used to turn the alarm sound on/off and select its operation mode: “AL._” = alarm is not active, “AL.1″ = alarm sounds 1 time (then automatically switches to “AL._”), “ AL.5" = alarm on weekdays only (Mon-Fri except Sat-Sun), "AL.7" = alarm sounds every day

Mode 6 - Setting the day of the week and date

The clock button allows you to set the day of the month. The minute button allows you to set the month.

Mode 7 - Stopwatch

Stopwatch allows you to measure time with an accuracy of 0.1 seconds. The maximum measurement time is 9.59.59.9 (almost 10 hours). Data in the following format "H.MM.SS.X". The minute button is used to start and stop the stopwatch. The clock button is used to reset.

Mode 8 - Alarm Clock

This mode is used to display and set the alarm time (ALARM). Data in the following format "HH.MM.AL". The Minute button sets the alarm minute, the Clock button sets the alarm hour.

Below is a diagram of similar watches with a common cathode indicator.

(downloaded: 812)

Loading...Loading...