20 Band Audio Spectrum Analyzer

I recently ordered some samples from TI, which included the TMP275 digital sensor. The sensor has some nice features which I quote from it’s datasheet:

The TMP275 is a 0.5°C accurate, Two-Wire, serial output temperature sensor available in an MSOP-8 or an SO-8 package. The TMP275 is capable of reading temperatures with a resolution of 0.0625°C. The TMP275 is SMBus-compatible and allows up to eight devices on one bus. It is ideal for extended temperature measurement in a variety of communication, computer, consumer, environmental, industrial, and instrumentation applications. The TMP275 is specified for operation over a temperature range of −40°C to +125°C.

The easiest way to get the temperature out of the TMP275 seemed to be I2C. So I started by designing a board which has all the components needed: the sensor, an atmega8 brain, and some other components needed for the display and for powering the board. The display is a 4 digit 7 segment display from kingbright product code CA56-12GWA. As for the display part of the board, I used PNP transistors on the common anodes and resistors on the segments to limit the current draw on the atmega’s pins. The transistors are not current limited so the display will alaways light-up the same no matter how many segments are turned on.

TMP275 digital thermometer board

For the supply part of the board, I choose to make it portable and power it from a 9V battery, so I needed to use a voltage regulator. The choice was the good old 7805 because it’s cheap and easy to find.

I2C is a pretty common protocol so various libraries can be found on the web. I chose Peter Fleury’s I2C library because it was very well documented. The only external components needed by the TMP275 are a bypass capacitor between VCC and GND and two pull-up resistors required on SDA and SCL lines.

All the I2C stuff is handled by the library, so I only had to write a couple of lines of code to get the temperature out of the sensor:

 i2c_start_wait(sensor+I2C_WRITE);	// set device address and write mode
 i2c_write(0x0);			// write pointer register 00000000 to select temp register
 i2c_rep_start(sensor+I2C_READ);	//set device address and read mode
 temp_high=i2c_readAck();		// Read high byte of temperature
 temp_low=i2c_readNak();		// Read low byte of temperature

After reading the temperature from the sensor I had to display it on the 4 digit display. For that I had to write a display macro, which figures out the numbers and how to display them, basically I used software multiplexing. I even tested it on negative temperatures by placing the sensor in my fridge :) . The readout was correct because I checked with another thermometer.

These new type of digital sensors are great, because you don’t have to worry about analog to digital conversion, all the  ADC is done inside the sensor. I mainly started working with this sensor because I want to incorporate a temperature reading function into a future project. Now that this part is done, is time to move onto the next one, ultrasonic range finder, which I’m guessing wont be as easy as the temperature reading.

I tried to comment every line of my code, but if you feel you don’t understand something, just post a comment and I’ll reply.

June 30th, 2009

LiIon Battery Charger

LiIon Battery Charger

Even though not much information is published about Lithium Ion Batteries, we find them more and more often powering our portable electronics. While their price sometimes can go pretty high, LiIon batteries offer higher capacity from less weight and volume and faster charging. Laptops, portable media players, cell phones, cameras, etc. almost all use the LiIon so there is a very high probability to recover the battery from a damaged device and this way get all the advantages at a small price.

Like with other batteries, inside the LiIon type there are one to four cells connected in series, each at about 3.6-3.7V. Higher capacity is obtained by connecting series groups of cells in parallel. All is nice though until the battery gets empty, then the tricky part starts. Conventional chargers don’t work on LiIon and can even destroy them. There are some generic charges on the market but either they’re very expensive or they’re for small batteries.

Newer batteries communicate with the charger telling the settings to be used for charging. Even older batteries have a thermistor that monitors temperature and a protection against complete depletion. This being said, in this project is presented a DIY solution for a LiIon Battery Charger. There are some things you must know about the battery so that you can safely charge it.

First of all you must know the pin-out, you risk damaging the battery and/or charger if you connect it the wrong way. Then you must know the number of cells but you can determine this by dividing the battery voltage rating by 3.7V, you must also know the capacity and thermistor value. The charge current can vary between half and full capacity rating, the lower value the safest but the slower.

The charger presented in the link is based on application note AVR450 from Atmel. The project uses the AtMega8 microcontroller and it  features adjustable charging settings as well as Smart Battery Interface. Schematics and code for the Atmel are available as well as information on how to operate it. Good luck!


LiIon Battery Charger: [Link]

May 30th, 2009

Digital Thermometer

Digital Thermometer

Here is a very good looking thermometer project showing the reading as a discrete value and as a bar-graph on a LCD. The idea is simple, we have a sensor, the LM35, who outputs a voltage depending on the ambient temperature, LM35′s rating is 10mV/ degree Celsius. Since the sensor’s output is analog we need to convert it to digital in order to display the value on LCD. The ATmega8 microcontroller will handle the A/D conversion, with a 4.8mV resolution it is within the accuracy range of the sensor.

Once the LM35′s output has been converted to digital, the microcontroller will make the calculations necessary to determine the temperature and display that value. The LCD is a 20×4 type so the bar-graph will show 20 levels. ATmega8′s port C0  reads the analog data from the sensor and port D controls the LCD. The code was written in BASCOM AVR which has some built-in functions to handle the A/D converter of the microcontroller. For Fahrenheit measurement use LM34 sensor.

All in all it is easy to build, as a school project perhaps,  with possibility for upgrade, for example to be able to change the bar-graph’s scale.


Digital Thermometer: [Link]

April 29th, 2009

AVR Object tracker

AVR Object tracker

Just the simple interfacing of camera with the micro controller sounds a lot of fun, then how about real time object tracking? This device has an amazing 27 fps speed and can track multiple objects which are defined by colors. The image sensor is OV6620 CMOS, and the brain is the ATmega8, trough the serial interface the user can download snapshots, configure the device or just view the tracked objects.

This project is an ideal start-up for those involved in robotics, by upgrading the basic IR based obstacle detection your robots gain a lot more freedom and intelligence.  Beside the amazing speed of execution the hardware is quite simple, my first thought was that the firmware is written in assembler I was surprised to see that the entire project is written in C. The PC program is in java and made available by the author, great way to get started with image processing methods and algorithms.

If you want to embed this project into your application the best way is to build it as is, and use a second controller for the other functions, since the tight synchronization needed between the atmega8 and the image sensor any other functionality would greatly reduce the image processing speed.

AVR Object tracker: [pdf] [download]

March 27th, 2009

ATmega with SD card

ATmega with SD card

I was looking for quite a time to interface the SD card and avr’s in my projects, fortunately here is this demonstrative project which can be a good starting point for anybody who needs to store large amounts of data. By implementing the FAT32 file system the stored data can be accessed directly from any PC, without the micro controller interface. This is very useful since you don’t have to carry a laptop or the entire data logger around.

The project is well documented, it really gives the insight needed to understand the FAT32 system and how SD card work, the authors project has serial interface so the SD card can be accessed trough the Hyperterminal. The Atmega8 might be short in memory for the advanced FAT32 handling, so for the actual device it is recommended about 32K flash capacity controller.

Just imagine, instead of the I2C 32kbyte external eeprom you can have 1G storage capacity, and with the FAT32 system you won’t need the serial interface, usually used to download the stored data.

ATmega with SD card: [link]



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