TWI (I2C) interface on AVR

Two wire serial interfaces are included in following AVR microcontroller families: ATmega8x, ATmega16x, ATmega163x, ATmega32x, ATmega323x, ATmega64x, and ATmega128x. TWI interface is a “Philips” standard I2C. Using TWI interface you can connect up to 128 devices using only two wires: clock (SCL) and data (SDA). Only two pull-up resistors on each line are needed this interface to work properly. I2C interface circuit is open collector. This means if one of all devices has low level signal on a line, then it is ‘0’, and if all devices have high impedance state, then signal is considered to be high ‘1’. More details about TWI interface you can find on any ATmega datasheet. One of my examples Interfacing AD7416 digital temperature sensor you can find here: Analog Devices Digital temperature sensor AD7416

Continue reading

Using buttons and switches with AVR microcontrollers

In most designs you might want to put buttons and switches to control your program flow. This is not very difficult to read button state. You can connect button between pin and ground with internal pull up enabled. Then when button is pressed, then pin value will be 0 when released – 1. Of course you can use external pull-up resistor. In fact all mechanical contacts have their shortcomings – they generate multiple micro connections that can confuse AVR. Delay of this effect depends on quality of buttons or switches and can vary from 10 to 100ms.

Continue reading

Control 7 segment LED displays with AVR

LED displays are nothing more than sets of Light Emitting Diodes. The difference is that they have different shapes in order to display specific information. So driving LED displays is the same as regular LEDs. This is simple connection when there are enough of microcontroller Pins. But if you want to connect more displays you will need more microcontroller pins than it can give you. Then you need to make more advanced circuit with dynamic control.

Continue reading

Drive LED or Opto-isolators with AVR

This might be seem very simple to many of you, but I still get questions about simple microcontroller interfacing. So I will put a thread of notes about interfacing AVR microcontrollers to devices like LED’s, relays, I2C, etc. As you might know Diodes require pretty small current. This current depends on diode type and can be from 3mA up to 20mA and more. Working voltage is from 1.5 to 4V. One AVR pin can sink up to 20mA of current; it is convenient to connect diode directly to it with current limiting resistor. Never connect diode to pin without resistor – you may damage your AVR as your current may exceed the 20mA limit!

Continue reading

Life-giving to Atmega8

I have got two atmegas from my friend. He stated that they are burned and can be thrown to garbage. He also mentioned that they stopped responding after they were programmed. So I asked him to give those to me to try them. I had in my mind, that this is a result of bad usage of security bits. There is always confusion in these bits, because security bits are programmed by writing ‘0’ values and unprogramed with ‘1’. I didn’t really expected to make them working again as my friend did quite rude experiments with them. What can I say – he was right by saying they are burned. Bu I guess some of you will like to see what I was doing in order to recover them. I decided that he unprogrammed all four security bits ( CKSEL0, CKSEL1, CKSEL2, CKSEL3 )by writing ‘1’ to them. This situation means that Atmega8 has to be clocked from external clock signal. I supposed to program those bits to work atmega normally with quartz resonator.

Continue reading

Interfacing MPXV5100 pressure sensor to Atmega8

The MPX5100 series piezoresistive transducer is a state-of-the-art monolithic silicon pressure sensor designed for a wide range of applications, but particularly it is convenient to interface to microcontroller or microprocessor with A/D inputs. This is thin-film metallization, and bipolar processing to provide an accurate, high level analog output signal that is proportional to the applied pressure. More details can be found here MPXV5100 This sensor measures differential pressure comparing to atmospheric so when there is no pressure applied it shows 0kPa;

Continue reading