Showing posts with label attiny13. Show all posts
Showing posts with label attiny13. Show all posts

Wednesday, October 22, 2008

LED fake candle made from ATtiny13


AVR tiny13 with limited IO, small and powerful, so it is really good to make a DIY LED candle.


Link:
http://www.electronics-lab.com/blog/?p=2948

Monday, October 20, 2008

AVR tiny powered by Lemon!!

+

Tiny13V is aimed for running on low power condition! How low is it? It can be powered by the natural battery "Lemon".

Sunday, July 6, 2008

CTC mode on Tiny13

There are two OC0A and OC0B compare outputs in Tiny13. It is useful to generate waveform . In this example, we use OC0A to output a square wave to blink the LED which is very similar to the previous timer interrupt example instead the output is generate inside Tiny13 but not our interrupt routine.

int main (void)
{
b0_output; //OC0A as led output

TCCR0B = 0x03; //select timer clkio/64

TCCR0A = (0x01)<<6 | 0x02; // Toggle OC0A | CTC MODE
TCNT0 = 0x0; //starting couter value

OCR0A = 0x7F; //around frequency @ 2.2HZ

//make the clk cpu slower
CLKPR = 1<<CLKPCE; //tell cpu to update the CLKPR

CLKPR = 0x8; //clkio = clkcpu/256


while(1) {
;; //interrupt do the rest
}
}

We set the output to be toggled every time the counter value match our OCR0A value. Thus, a square wave is generated:



The complete project can be found here: http://labs.bitartist.org/compare_int.tar.gz

Timer interrupt on Tiny13

Sometimes we have to do somethings in certain period, so timer may be useful for you.
AVR tiny13 have one timer and it count until to 0xFF value for each clock. An interrupt will be then generated and call your interrupt routine.

In our example, we have the following interrupt routine:

ISR(TIM0_OVF_vect) {
if (led){
b0_high;
led = 0;
} else {
b0_low;
led = 1;
}
}


This routine is used to toggle the LED On or Off.

The complete project code can be found here: http://labs.bitartist.org/timer_int.tar.gz

Testing external interrupt INT0 on tiny13

Tiny 13 have an external interrupt "INT0" on PB1, We have created a test project on avr-gcc to have a quick testing on the INT0.



#include <avr/io.h>
#include <avr/interrupt.h>
#include "pin_macros.h"

unsigned char led=0;

ISR(INT0_vect) {
if (led){
b0_high;
led = 0;
} else {
b0_low;
led = 1;
}
}

int main (void)
{
b1_input; //switch
b0_output; //led output

MCUCR = 1<<isc01; //set INT0 as falling edge trigger

GIMSK = 1<<INT0; //enable INTO in global interrupt mask


sei(); //enable interrupt

while(1) {
;; //interrupt do the rest
}
}



B1 is connected to a switch, and B0 is connected to a LED.
When B1 is pressed, it would toggle the LED On or Off.

Download the whole project : http://labs.bitartist.org/test_int0.tar.gz

Reference:
http://www.nongnu.org/avr-libc/user-manual/group__avr__interrupts.html

Sunday, June 29, 2008

Gif2led released, and with AVR LED Egg demostration!

We have worked on LED matrix for so many times, but mostly for text scrolling, so how about make some animations on it? But we are too lazy to make the animation patterns to the C header file in an array of bytes. We finally finished one tool may be useful for all led matrix lovers!

The gif2led project is written in Ruby, required Rmagick library for gif manipulation. It is mainly designed for 8 or less columns matrix, for instance 8x8 matrix, 10x8 matrix, 5x7 matrix etc. It output an pattern header file with a 2D array frame by frame from an animated gif input. We only tested with AVR-gcc, but it should be useful for other MCUs too. You can find more information on the gif2led project page, http://labs.bitartist.org/gif2led/

Let start with our demonstration, the project is called LED Egg, it is based on a 10x10 matrix (but we only use 10x8 in our case) with an Egg case to hold the circuit board.

To prepare the animated gif, we use macromedia Flash, and here is the screenshot:



Noted that the frame 0 (marked as CAL above) is a special frame, which used for calibration. When used with gif2led tool, the frame 0 is the pattern of your led matrix with all led ON.

and then export the movie to an animated gif:



Then simply run the following command, we can obtain the 2D array header file:
ruby gif2led pattern.gif 20 > pattern.h
//selected ratio is 20.0%
//Cal result: LED Matrix (row*col) = (10*8)
const unsigned char pattern[63][10] PROGMEM = { //Frame 0 {0x42,0x00,0xa5,0x00,0x84,0x21,0x00,0x42,0x21,0x84} //Frame 1 ,{0x00,0xa5,0x00,0x84,0x21,0x00,0x42,0x21,0x84,0x42}
...
...
#define MAX_FRAME 63
#define ROWS 10
Now, we have to prepare the circuit part, we use AVR tiny13 together with 4017, please refer to the circuit diagram<here>. 4017 is used as a row counter, and such that we can only use 1 pin for row shifting. The remaining 4 IOs of the tiny13 would use for column output, we are using 10x8 matrix this time, so we assume the pattern is symteric to save pins, so 1 I/O drive 2 columns in our case. The circuit showed below:



So Lets add an egg case, the egg is made from pu foam plastic, it is used for Easter decoration.





Video demonstration:


Close look on the LED pattern:



To download the gif2led tool, AVR source codes, and flash template, please find in the following links:

Gif2led project page:
http://labs.bitartist.org/gif2led/


Gif2led Rubyforge page:
http://rubyforge.org/projects/gif2led/

Sunday, March 2, 2008

Small 5x7 Dot Matrix LED display

What is 5x7 dot matrix display?


5x7 dot matrix Led display is usually used to cascade together to make a large led matrix display as you see in train station.


(A typical LED matrix display)

The small size of 5x7 dot matrix led display is good for small electronic project, typically the 5x7 dot matrix is used to display one character a time, i.e. 5x7 dot matrix font. In order to use only one 5x7 dot matrix to display information, we have to use the 5x7 dot matrix horizontally. We use the 5x4 dot matrix font instead and of course text scrolling will be necessary.

The KAAS Led flower vase is using the 5x7 dot matrix display for displaying messages.

kaas used one AVR tiny13 and two 74hc595 chips to drive the led matrix, the result is very impressive. The detail information of the LED flower vase is here.

Another interesting project is the Twitter LED scroller Build from davidnin. He used the Arduino board and one 74HC595 to drive the 5x7 dot matrix led. Please check out the cool video:

Another project from us, GIF2LED!
it allows you to convert a gif animation to LED header file to speed up your coding time:)

Check it out:
http://www.bitartist.org/2008/06/gif2led-released-and-with-my-led-egg.html


Another cool tiny message scroller using ATtiny2313 from kalanda:

http://www.kalanda.com/scroller-de-7x5-leds-basado-en-micro-attiny2313.html




Monday, February 18, 2008

Information on Integrated Circuit/IC Packaging.



Integrated circuit is the key component of every electronic project, it can be simple as logic gates, counter, multiplexer to highly complex microprocessor. When you buy IC online for your project, the same IC may have different packages, you have to choose the right package type for your prototype. For example, DIP, PLCC, BGA etc. This website (Integrated Circuit, IC Package Type) gives you a list of common package type definitions, you can get more information there. For me, I usually make my project on the wooden prototype board, so surface mount package type is not prefer unless I make the PCB myself. I usually used the DIP package for the microprocessor(MCU) and also the other IC, like 74HC595 and 555 Timer. It is easy for soldering and also wire wrapping.


#1 - Transistor with TO-92 package


#2 - MCU(AVR tiny13, DIP package) contains in a plastic tube.


#3 - 74HC595 IC in DIP package plugged into the wooden prototype board.

If you really want to find in depth information of the IC packaging type, please visit this website: Discrete Packaging (Fairchild Semi)