20 Band Audio Spectrum Analyzer

Atmega8 demo assembled

Like I promised in the Protostack kit review, here is the most simple application that a beginner can make, the simple embedded version of the “Hello world”, based on simple push button input turn on a led, this involves the usage of digital input read, and digital output write.

I made a simple application to read the PORTB.5 pin state and in response turn on or off the LED attached to the PORTB.0 pin, and I want to demonstrate the importance of the pull-up or pull-down resistors when using the digital port as input source. When you configure the digital port as input, the micro controller internal circuit is reconfigured and the pins input impedance is very high, in simple terms any weak signal can change the pins state.

This is a double bladed sword, since your signal source can easily drive the input, but when your signal source isn’t connected the smallest noise can interfere with your input, and give you false readings, this is mostly common with push button, matrix keyboard, switch contact inputs.

In digital electronics the engineers use the terms pull-up or pull-down resistor, this is a simple resistor usually between 10k and 100k, to define the input state when no signal source is connected, this way overriding the noise signal, common sense dictates that when you have potentially larger noise then a smaller resistor is needed, but don’t be careless about it, don’t place a 100Ohm resistor because your signal source must be able to “defeat” the pull-up(down) resistor. A rule of thumb is to use at least 10x larger pull-up(down) resistor then your signal source impedance.

The pull-up term is used when the resistor connects the pin to the + and pull-down when connects to the ground, but then which should you choose? Good question, in these days it doesn’t really mater, your application or the pcb design should dictate, the older generation digital IC’s had asymmetrical current sink/source capability, they could sink more current and because of that the pull-up resistor was more common.

Here is the schematic of the simple application, the power and ISP connection are not shown:

atmega8 demo schematic

The ATmega8 micro controller has internal pull-up resistors of 100-200k value, this comes handy since in most cases it will be enough, I made some simple tests with and without the internal pull-ups active.

Here you have the demonstration(no pull-up active):

atmega8 demo cable touch no pull-up

Since the PORTB.5 pins is the SCK pin for the In system programming interface it’s connected to the programming cable. It was enough to touch the cable and the input pin’s state was changed.

atmega8 demo proximity no pull-up

As you can see here, I am holding the tool close to the pin header and not touching it, but the input already picks up the noise.

Now you would ask, from where does the noise signal come, well since your house is wired with the mains voltage most of the noise is picked up from the 50/60Hz, the rest is probably high frequency noise.

After I enabled the internal pull-up on the input pin these annoying interferences disappear:

atmega8 demo cable touch with pull-up

Immune to the cable touch.

atmega8 demo finger touch with pull-up

Doesn’t triggers even when I bridge the input pin to ground trough my finger.

atmega8 contact with pull-up

The LED turns on only when I connect the input to ground by short circuiting the pin header with the tool, which is the correct operation.

Overall advice: when using digital inputs, always use pull-up or pull-down resistors the most simple way is to use the internal pull-ups, but check if effectively eliminates the noise, if not use external resistors, in case of external pull-down disable the internal pull-up!

Project archive with source file and additional photos: ATmega8 simple project

March 1st, 2009

ATmega8 kit from Protostack

ATmega8 kit unassembled

I received a kit from Protostack for review purposes, this kit is for the ATmega8 micro controller, and is probably the cheapest available with the shipping costs only 20$ worldwide,  so anybody can afford it.

After I assembled the kit, I also added a few extra parts, like series diode with the +5V supply and few capacitors for decoupling, filter choke for the AVCC, these are not mandatory, since the circuit works well without them(I tried), but its good to have it on the board.

Atmega8 kit assembled

After I changed the fuse settings to work with the external 16MHz crystal, I added a LED and resistor and a pin header, the circuit board has good quality solder mask and plating, this makes it easy to solder, it has large pads on the bottom, and no pads on the top layer, this way even when you use uncoated wires for connections which run over the pads on the top you don’t the risk short circuits.

Since the holes are trough plated, removing thicker wires like diode terminals can be tricky and you can rip out the hole plating, but even in this case the pad on the bottom remains intact, so this isn’t a problem. Although it would be better if no hole plating where used on the prototyping area.

The prototyping area is similar to a breadboard, the major difference is that the ATmega8 ports are nicely ordered, the supply and ground pins are connected together, and the programming pins are tied to a 10 pin header. I use the avr mk2 programmer which has only the 6pin header, so I had to make the adapter cable.

I also made a simple demo project with 1 LED, and 1 push button, in that project I will explain how to use the digital inputs and outputs, many people doesn’t pay attention to these simple peripherals and make typical design errors which will generate aleatory errors very hard to debug.

The demo project will get described in a future post.

ATmega8 kit from Protostack

February 13th, 2009

AVR FM transmitter

AVR FM transmitter

When it’s about FM transmitters most of the people think about complicated circuits with LC oscillators, tuning problems, pcb coupling issues and the high risk of failure. You can find dozen or more schematics on the web, I personally tried a few, but without luck because I couldn’t tune in the oscillator.

The mathematical background is complicated, but well explained for those interested, the code is written is assembler which is a must since the tight timing. Beside the inductor all of the components are widely available, this must be hand made and by stretching you can fine tune the oscillator, thing which will be probably needed.

By using surface mount components the pcb size could be greatly reduced, but keep in mind when making the layout to reduce coupling and noise susceptibility.

Make sure that you don’t disturb any local frequencies, or somebodies privacy with it.

AVR FM transmitter: [via] [Link]

February 12th, 2009

Video overlay with AVR

Video overlay with AVR

If you have a camera and want to add additional data in real time to the captured image, you need to overlay your text on the original picture, most of the cases the overlay image is a low resolution text, at first I thought this would be very complicated, but after I found this project I had to change my mind. By using only the ATmega8 and LM1881 the author can overlay any text on the S-video signal.

Video overlay with AVR

Since high frequencies are involved the proper ground is needed to avoid noise problems, since the breadboard isn’t suited for frequencies above 10kHz, the author used a thin aluminum  foil as shield, if you make a pcb keep in mind that the LM1881 is very sensitive.

The project doesn’t need any expensive components, and work even on a breadboard, the firmware is written in C and is available for download, you can easily modify it to display your custom messages. Since most of the video cards in PC’s have output in S-video format too, this device has a great potential.

Video overlay with AVR: [via] [Link]

February 7th, 2009

Random twinkling LED heart

Random twinkling LED heart

If you want to impress somebody on Valentine’s day this is a great opportunity, make a DIY led heart, the project comes along with all the source code schematics and even a tutorial to explain the software.

Beside the obvious, lets take a deeper look at the project, the leds are twinkling at random speed and pattern, and yes there are fading not just turning on and off, and there are 20 of them, so how do they do it? No there isn’t a large micro controller with 20 channel pwm, they emulate it in the firmware, and use random numbers to set each leds twinkle. Its worth looking at the solution since in many application, especially with leds  you will need to fade more channels than your pwm hardware can handle.

The project also comes with schematic, if you build this kit, place at least a series resistor of 100 Ohm value with PC5 pin, just in case you start to improve the software and forget that the pins can handle only 25mA.

Random twinkling LED heart: [Link]



© 2007-2011 YourITronics | Any logo, trademark and project represented here are property of their respective owners | Wordpress | Privacy Policy    RSS