And "vois la", it was possible to build a small circuit with very view components: An Attiny13 Mikrocontroller, one 3V solar cell, a capacitor and a piezo speaker.
An intersting result of this experiment was that the Mikrocontroller ist spezified for a minimum supply volatag of 1.8V but in reality it is starting up at arround 1.2V. Therefore not much light is needed to operate the circuit. To achieve a minimum power consumption of the microcontroller the internal 128KHz oszillator is used as clock source.
If you want to build a micorontroller solar bird on your own, here is the code:
- Code: Select all
/*************************************************************************
solar bird
attiny 13 slow clock low power experiments
28.9.08 christoph(at)roboterclub-freiburg.de
*************************************************************************/
/*************************************************************************
Hardware
prozessor: ATtin13
clock: 128Khz internal oscillator
PIN1 RESET
PIN2 PORTB3/ADC3
PIN3 PORTB4/ADC2
PIN4 GND
PIN5 PORTB0/OC10 piezo controll speaker
PIN6 PORTB1
PIN7 PORTB2/ADC1
PIN8 VCC
*************************************************************************/
#include <avr/io.h>
#define PIEZOSPEAKER (1<<PINB0)
#define LOADSECONDS 60
#define HZ_1706 2
#define HZ_853 4
#define HZ_586 6
#define HZ_426 8
void init_timer()
{
/* frequency example
TCCR0B=0x02; // internal clock source devided by 8
OCR0A=9; // Compare value
// caldulated frequency at 9.6MHz: 9.6e6/(2*8*(9+1))= 60kHz , Division by 2 due to toogle
//TCCR0A=0x02; // CTC-Mode (clear timer on compare match)
*/
TCCR0A=(1<<COM0A0) | 0x02; //CTC mode and toogle OC0A port on compare match
TCCR0B=(1<<CS00) ; // no prescaling,
OCR0A=255; // in CTC Mode the counter counts up to OCR0A
// CTC-Modefrequency calculation: f=IO_CLC/(2*N*(1+OCR0A)) N:Prescaler
// e.g. IO_CLK=128KHz, N=1; OCR0A=1 ==> 64Khz
// e.g. IO_CLK=128KHz, N=1; OCR0A=10 ==> f=6095Hz
// e.g. IO_CLK=128KHz, N=1; OCR0A=100 ==> f=633Hz
// e.g. IO_CLK=128KHz, N=1; OCR0A=200 ==> f=318Hz
// e.g. IO_CLK=128KHz, N=1; OCR0A=255 ==> f=318Hz
TCCR0B=(1<<CS00) ; // no prescaling,
///FAST PWM mode and set OC0A ( PB0 ) port on compare match
//TCCR0A=(1<<COM0A0) | (1<<COM0A1) | (1<< WGM00 ) | (1<< WGM01 );
// TCCR0B=(1<<CS00) | (1<< WGM02 ); // no prescaling, PWM OCR0A update
//TCCR0B=(1<<CS00) ; // no prescaling,
//TCCR0B=0x02; // internal clock source devided by 8
//OCR0A=9; // Compare value
OCR0A=255; // Counter end
// caldulated frequency at 9.6MHz: 1/9.6e6/(8*(124+1))= 9600 Baud
// bit time = 104,17us
//TCCR0A=0x02; // CTC-Mode (clear timer on compare match)
}
// duration in 1ms
void delay_ms(uint16_t duration)
{
uint16_t d;
uint8_t n;
uint16_t counter;
counter=(3*duration);
// periode duration 586us
for(d=0;d<counter;d++)
{
for(n=0;n<1;n++) PORTB=0;
for(n=0;n<1;n++) PORTB=0;
}
}
#define SPEAKEROFF TCCR0A=(0x02)
#define SPEAKERON TCCR0A=((1<<COM0A0) | 0x02)
int main(void)
{
uint16_t n;
uint8_t counter=100;
uint16_t phase1;
uint16_t phase2;
uint16_t phase3;
uint16_t t1=100;
uint16_t t2=10;
uint16_t t3=1;
// Ports
DDRB=PIEZOSPEAKER; // Pins as output
OCR0A=100;
init_timer();
delay_ms(1000);
while(1)
{
//delay_ms(10);
phase1+=t1;
phase2+=t2;
phase3+=t3;
//t1=phase2;
if((phase2>>8)==1)t1=100;
if((phase2>>8)==100) t1=200;
if((phase3>>8)==1)
{
SPEAKERON;
}
if((phase3>>8)==20)
{
SPEAKEROFF;
}
OCR0A=255-(phase1>>8);
}
return 0;
}
/***************************************************************************
*
* (c) 2008 christoph(at)roboterclub-freiburg.de
*
***************************************************************************
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation version 2 of the License, *
* If you extend the program please maintain the list of authors. *
* If you want to use this software for commercial purposes and you *
* don't want to make it open source, please contact the authors for *
* licensing. *
***************************************************************************/
