Tuesday, April 30, 2013

A CD4017 library for AVR Atmega as PWM output expander, to run up to 36 servos or 9 servos at high accurancy

The CD4017 is a 5-stage divide-by-10 Johnson counter with 10 decoded outputs and a carry out bit.
This library implements a PWM output expander for AVR Atmega micro using CD4017.

With this library we can write a module to move servos using PWM.
A servo expansion module is already implemented as example, with this module you can run up to 36 servos @ 2.25degree precision per step or 9 servos @ 0.18 degrees of precision.
"High accurancy" is 1.0us of precision per step @16Mhz, normal accurancy is 12.5us precision per step @16Mhz.
The default frequency for servos is 50Hz.

If you run this sample at a different frequency you must update the countdown parameter of this library, and also you should test it to prove that the resource are enough to output the pulse to CD4017 at the desired frequency.
I've test it using some servos and scope for the remaining outputs.

This library was developed on Eclipse, built with avr-gcc on Atmega168 @ 16MHz.


  • read risk disclaimer
  • excuse my bad english

Monday, April 22, 2013

A simple 8x8 led matrix library for AVR Atmega

This library implements a simple 8x8 led matrix for AVR Atmega.
It uses 16 output ports for the full 8x8 led matrix, but it can be reduced to a smaller matrix, using less ports.
This library was developed on Eclipse, built with avr-gcc on Atmega8 @ 1MHz.


  • read risk disclaimer
  • excuse my bad english

Monday, April 8, 2013

AVR Atmega dehumidifier controller board

You can find an update for this project here: http://davidegironi.blogspot.it/2013/09/avr-atmega-dehumidifier-controller.html

Suddently my dehumidifier stop working, the original humidity switch get broken, it was a mechanical hygrometer, based on a thin transparent strip that react to humidity and engage the main electronic switch. So i decided to build my own dehumidifier board.

AVR dehumidifier is an alternative electronic board for your dehumidifier based upon AVR Atmega8 micro.
When ambient humidity reach the humidify threshold set by the user dehumidifier starts.
A full sensor check the water tank, if it is full the dehumidifier stop running.
An antifrost temperature sensor can shut the compressor down to prevent evaporator frost.
An ambient temperature sensor prevent the dehumidifier to run if temperature is too low or high.

  • set the humidity threshold between >30% to 80% RH< *
  • when ambient humidity reach humidity threshold dehumidifier start running it stop running if ambient humidity goes below humidity threshold minus a constant humidity off range >2% RH< *
Water full sensor:
  • check the water tank status - if the water tank is full dehumidifier stop running
Ambient temperature sensor:
  • check the ambient temperature - the dehumifier only works if ambient temperature is between >5 and 35 celsius degree< *
Humidify temperature sensor:
  • check the ambient humidity
Evaporator temperature sensor:
  • check the evaporator temperature - if it is below >7 celsius degree< * the compressor is shut down until evaporator temperature reach >7+5 celsius degree< *
Power, Full, Running led status:
  • Power led
    • blink: system running
  • Full led
    • off: water tank not full
    • on: water tank full [dehumidifier stop running]
  • Running led
    • off: dehumidifier not running
    • on: dehumidifier running [fan on, compressor on]
    • blink: dehumidifier running [antifrost cycle: fan on, compressor off]
  • Full led and Running led
    • blink: dehumidifier not running [ambient temperature too low]
* setup those parameter at compile time if you want different values, also you can setup different port values if you want different board connections.

Selected humidity sensor is DHT22, but it can also work with a DHT11 sensor. Antifrost sensor is an NTC thermistor.

This library was developed on Eclipse, built with avr-gcc on Atmega8 @ 1MHz.
If you include <math.h> add libm library to linker.


  • 1.0.4: DHT library update
  • 1.0.3: first release


  • read risk disclaimer
  • excuse my bad english