AVR based RS232 controlled dimmer

Warning

This circuit is operated with mains voltage and some parts are directly connected to line power. So it is only intended as an example for experienced hobbyists.

Description

With this device you can switch or dim a 230V load (up to 1000W) with serial commands documented here.

foto of the prototype

The circuit uses an Atmel ATTINY2313 controller with well documented firmware written completely in AVR assembler. Beside the dim and switch once functions flexible timers can be used to switch on and off in a cycle, once or repeated. However after power loss all timers are reset and have to be reprogrammed. More details you can find in the serial protocol description.

With the ATTINY2313 builtin analog comparator the zero crossing of the mains AC is detected to fire the Triac at the right time.

The source code is provided under the GNU General Public License (GPL) and can be downloaded here. An already assembled version in hex format is here available.

project goals

  • simple, clear text commands can be invoked from a terminal
  • cheap parts, neither transformer nor RS232 isolation IC used
  • intelligent autonomous cyclic and single switching functions

The schematics is provided under the GNU General Public License (GPL) and can be downloaded here.

ATTiny2313-dimmer.sch_.pdf

 

A verified 2-layer printed circuit board layout is available too.

 

Receive updates directly in your inbox

Loading

 

2 Replies to “AVR based RS232 controlled dimmer”

  1. Hallo Uwe,
    vor einiger Zeit habe ich einen Dimmer mit dem 2313 gebastelt.
    Dieser läuft seit einigen Jahren problemlos und sehr stabil.
    Auf der Suche nach Schaltungen anderer Bastler habe ich deinen Blog gefunden.
    Ich finde dein Projekt sehr interessant.
    Ich selbst nutze den i2c-Bus als Schnittstelle. Inzwischen habe ich mit dem 4313 einen 2. Dimmer zum Testen gebaut. Der hat auch eine Zeitschaltuhr bekommen. http://87.166.240.36/
    Leider sind da noch Macken drin. Um die Schaltzeiten zu setzen, muss erst die Uhrzeit gesendet werden.

    Viele Grüße von der Nordsee
    Carsten

    1. Hallo Carsten,

      Danke für die Rückmeldung. Ich habe mir Deine Hausautomation angesehen, so was könnte ich auch gebrauchen. 🙂
      Der Dimmer mit ATTiny4313 ruft doch nach einer Echtzeituhr, die dann die Zeit speichert. Am einfachsten ist eine DS3231 mit eingebautem Quarz und sehr guter Genauigkeit, die einfach am I2C Bus arbeiten kann. Zusammen mit einem Supercap ist es auch wartungsfrei. Insgesamt hat Deine Schaltung viel mehr Funktionen. Der Unterschied ist PWM für die LEDs im Gegensatz zu Phasenanschnittssteuerung bei Verbrauchern mit Netzspannung.

      Alles Gute und viele tolle Bastelprojekte weiterhin!
      Uwe

Leave a Reply

Your email address will not be published. Required fields are marked *