Sunday, December 22, 2013

A led matrix Mask built on AVR ATmega8

avr_mask1 wish you a Merry Christmas and a Happy New Year!



AVR Mask1 is a led mask built around 74hc595 shift register and 8x8 led matrix.

The "Dylan Dog" comics decoupage, in conjunction with his stands, make it good looking.


It has 4 8x8 led matrix, 2 for the mouth, and 2 for eyes.

When the user get closer to the mask, the IR sensor placed on the back activate the mask.

If activated, it randomly runs eye and mouth patterns.
Patterns can be programmed in code, the patterns are just array of bytes, 1 stands for led on, 0 for led off.
We need 8 bytes to make 1 pattern for 1 led matrix (8x8).

If the user speak a small mic detects his voice, and execute the mouth speaking pattern.


Voice and proximity trigging could be setup using even an external variable resistor.

I've built this mask some years ago, but i've submitted it this year, at the "InverArt 2013" art fair, and kids goes crazy for it :)



This project is developed on Eclipse, built with avr-gcc on Atmega8 @ 8MHz.



Code

Notes
  • read risk disclaimer
  • excuse my bad english

Monday, December 16, 2013

A DS1307 library for AVR Atmega



The DS1307 serial real-time clock (RTC) is a low-power, full binary-coded decimal (BCD) clock/calendar.
This library set and get year, month, day, hour, minute and second from this RTC.


Setup parameters are stored in file ds1307.h

This library was developed on Eclipse, built with avr-gcc on Atmega8 @ 1MHz.


Code


Notes
  • read risk disclaimer
  • excuse my bad english

Tuesday, December 3, 2013

An AVR Atmega based PID magnetic levitator



This is a magnetic levitator implemented using Atmega8 microcontroller.
Magnetic levitation is a method by which an object is suspended with no support other than magnetic fields.


To make a magnet levitate, an hall sensor is attached to a coil. The coil acts as an electromagnet, and the hall sensor measure the distance of the magnet from the coil.
The coil it is driven by PWM impulses, the closer the magnet is from the hall sensor, the bigger is the duty cycle and vice versa.
The coil works only if the magnet is in a certain range, out of this range no current flow through the coil, and the system is in is idle state.
The system has to mantain the equilibrium position of the magnet, the pull force of the coil has to be equal to the gravity force that pull the magnet to ground.

To stay on the budget, a small 12V 50N coil (ZYE1-P25/20) is used, with this coil the system can not lift heavy loads.
The hall sensor used it the Allegro A1302.
Because the heavy loads limitation, i've to put the hall sensor next to the coil, this solution produce a problem, the magnet can be pull even by the ferrite core of the coil, If it gets too close to the coil. To prevent this situation we have to emitting less current to the coil.
A bigger coil and a more sensible hall sensor can lift heavier load, and also the magnet can levitate far away from the coil.

An RGB led, next to the hall sensor, is powered on when the magnet is detected.




To adjust PWM intensity, a PID controller is used.
A proportional-integral-derivative controller (PID controller) is a generic control loop feedback mechanism (controller) that calculates an "error" value as the difference between a measured process variable and a desired setpoint. The controller attempts to minimize the error by adjusting the process control inputs.

The micro runs at 8Mhz, every 1ms the hall sensor it is checked, and the PWM for the coil is adjusted. The PWM period is 1953Hz.


The PID controller parameters, and other configuration options are stored in eeprom and can be edited by a software application connected through the UART connection. The software used for this functionality is avruartconfig.
All the configuration values could be changed through the UART connection for different coil / hall sensor / magnet hardware.


For an art fair next to my town, InverART 2013, a friend of mine, Paolo Crespi, build the sculptures you can see on the image above.



Code


Notes
  • read risk disclaimer
  • excuse my bad english