Thursday, October 29, 2009

Building LCD Thermometer [Temperature Display in LCD Module]

Here I’ll describe how to display texts in LCD module using AVR Atmega32 and how to connect a temperature sensor to measure the current temperature and display in LCD.
First we describe the LCD we used. There are two kinds of LCD modules.

Ø LCD modules with driver
Ø LCD modules without driver

GDM 1602A is a standard LCD module with driver and controller [S6A0069] [see sample image of the LCD module we used].



Features of GDM 1602A
1. 5x8 dots
2. Built-in controller (S6A0069 or equivalent)
3. +5V power supply (also available for =3.0V)
4. 1/16 duty cycle
5. Easy interface with 4-bit or 8-bit MPU
6. BKL to be driven by pin1, pin2, or pin15, pin16 or A, K
7. 16x2 characters

Know more about your LCD module for example pin connection, what driver it has from corresponding datasheet. If you use GDM1602A see this datasheet.
The secret of success is approaching by eliminating confusions. If you have confusions then make clear your lcd basics. These links will help you very much. I’d like to share them.

http://www.geocities.com/dinceraydin/lcd/intro.htm
http://home.iae.nl/users/pouweha/lcd/lcd0.shtml

Before discussing how to display characters in LCD module let’s have some words about the temperature sensor we used. It’s most popular one which is LM35, a precision integrated-circuit temperature sensor. Let’s begin from the first.

What is a temperature sensor?
Temperature sensor is an electronic device which provides a voltage analogue of the temperature of the surface on which it is mounted.
Example, thermistor.

In other ways, an analog temperature sensor is pretty easy to explain, it's a chip that tells you what the ambient temperature is!

These sensors use a solid-state technique to determine the temperature. That is to say, they don't use mercury (like old thermometers), bimetallic strips (like in some home thermometers or stoves), nor do they use thermistors (temperature sensitive resistors). Instead, they use the fact as temperature increases, the voltage across a diode increases at a known rate. (Technically, this is actually the voltage drop between the base and emitter - the Vbe - of a transistor). By precisely amplifying the voltage change, it is easy to generate an analog signal that is directly proportional to temperature. There have been some improvements on the technique but, essentially that is how temperature is measured.

Because these sensors have no moving parts, they are precise, never wear out, don't need calibration, work under many environmental conditions, and are consistent between sensors and readings. Moreover they are very inexpensive and quite easy to use.

Types of temperature Sensors
There are big differences between different kind of temperature sensors. They may be classified into two groups:
Ø Contact
Ø Non-contact

Contact Sensors
Contact temperature sensors measure their own temperature.
One infers the temperature of the object to which the sensor is in contact by assuming or knowing that the two are in thermal equilibrium, that is, there is no heat flow between them.

Noncontact Sensors
Most commercial and scientific noncontact temperature sensors measure the thermal radiant power of the Infrared or Optical radiation that they receive from a known or calculated area on its surface, or a known or calculated volume within it (in those cases where the obect is semitransparent within the measuring wavelength passbad of the sensor).

One then infers the temperature of an object from which the radiant power is assumed to be emitted (some may be reflected rather than emitted). Sometimes the inference requires a correction for the spectral emissivity (NB: the two words, spectral & emissivity, are used together in correcting IR Thermometer readings -the "emissivity", unspecified, is a big trap which even some of the suppliers of devices and calibration equipment fall into unwittingly for a variety of reason about which one can only speculate ) of the object being measured.

Knowing how and when to apply a spectral emissivity correction is part of the inference, too, and can introduce significant errors if not done correctly. See our Trip down the E-missivity Trail to help you understand that aspect a little better.

Notes
The truism that all sensor have errors in their readings - all the time. One key secret to high quality measurement results is to have confidence in the error estimates. Neglecting to make a careful error analysis can result in error much larger than the assumed values.

A figure of the temperature sensor we used is given below.



Features of LM35

1. Calibrated directly in ° Celsius (Centigrade)
2. Linear + 10.0 mV/°C scale factor
3. 0.5°C accuracy guaranteeable (at +25°C)
4. Rated for full −55° to +150°C range
5. Suitable for remote applications
6. Low cost due to wafer-level trimming
7. Operates from 4 to 30 volts
8. Less than 60 μA current drain
9. Low self-heating, 0.08°C in still air
10. Nonlinearity only ±1⁄4°C typical
11. Low impedance output, 0.1 W for 1 mA load

To know more information on lm35 view this datasheet. Others follow your corresponding datasheet. Simply search in google with terms “datasheet” followed by your temperature sensor model.


How lm35 works?
If you are wondering how lm35 works here's it. As the temperature increases, the voltage across diode increases at a known rate. As lm35 has diodes inside it happens same there. So what lm35 does is adjusting the output voltage per oC in real.
So if lm35 outputs 10mV it means 1 oC. If it outputs 20mV then it is 2 oC.

We’ve attached the Vout of LM35 in PA0 of Atmega32. We use Atmega32 to do the analog to digital conversion. See the complete pin connection of the circuit in the image below.


Fig: Circuit Connections


If you only want to test the LCD module ignore the lm35 part and respective pin connection.
Here comes the coding part that you’re waiting for. If you’ve connected the LCD correctly with Atmega32 and provided power supply then the following code will display “Welcome to Matrices!”.

#include <mega32.h>
#include <stdio.h>
#include <delay.h>

// Alphanumeric LCD Module functions
#asm
   .equ __lcd_port=0x18 ;PORTB
#endasm
#include <lcd.h>

// Declare your global variables here

void main(void)
{
    int i;

    // Declare your local variables here

    // Input/Output Ports initialization
    // Port A initialization
    // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In 
    // State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T 
    PORTA=0x00;
    DDRA=0x00;

    // Port B initialization
    // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In 
    // State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T 
    PORTB=0x00;
    DDRB=0x00;

    // Port C initialization
    // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In 
    // State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T 
    PORTC=0x00;
    DDRC=0x00;

    // Port D initialization
    // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In 
    // State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T 
    PORTD=0x00;
    DDRD=0x00;

    // Timer/Counter 0 initialization
    // Clock source: System Clock
    // Clock value: Timer 0 Stopped
    // Mode: Normal top=FFh
    // OC0 output: Disconnected
    TCCR0=0x00;
    TCNT0=0x00;
    OCR0=0x00;

    // Timer/Counter 1 initialization
    // Clock source: System Clock
    // Clock value: Timer 1 Stopped
    // Mode: Normal top=FFFFh
    // OC1A output: Discon.
    // OC1B output: Discon.
    // Noise Canceler: Off
    // Input Capture on Falling Edge
    // Timer 1 Overflow Interrupt: Off
    // Input Capture Interrupt: Off
    // Compare A Match Interrupt: Off
    // Compare B Match Interrupt: Off
    TCCR1A=0x00;
    TCCR1B=0x00;
    TCNT1H=0x00;
    TCNT1L=0x00;
    ICR1H=0x00;
    ICR1L=0x00;
    OCR1AH=0x00;
    OCR1AL=0x00;
    OCR1BH=0x00;
    OCR1BL=0x00;

    // Timer/Counter 2 initialization
    // Clock source: System Clock
    // Clock value: Timer 2 Stopped
    // Mode: Normal top=FFh
    // OC2 output: Disconnected
    ASSR=0x00;
    TCCR2=0x00;
    TCNT2=0x00;
    OCR2=0x00;

    // External Interrupt(s) initialization
    // INT0: Off
    // INT1: Off
    // INT2: Off
    MCUCR=0x00;
    MCUCSR=0x00;

    // Timer(s)/Counter(s) Interrupt(s) initialization
    TIMSK=0x00;

    // Analog Comparator initialization
    // Analog Comparator: Off
    // Analog Comparator Input Capture by Timer/Counter 1: Off
    ACSR=0x80;
    SFIOR=0x00;

    // ADC initialization
    // ADC Clock frequency: 125.000 kHz
    // ADC Voltage Reference: AVCC pin

    // my code here
    for (i=0; i<500; i++)
   delay_ms(1);

    // LCD module initialization
    if (lcd_init(16))
        PORTC = 1;
    for (i=0; i<200; i++)
       delay_ms(1);

    lcd_gotoxy(0,0);
    lcd_putsf("    Welcome to");
    lcd_gotoxy(0,1);
    lcd_putsf("    Matrices!");

    while (1);
}


This code should be compiled in codevision avr compiler[If you don’t have download codevision from here]. Remember it is a tested code. So if it doesn’t work think again if your hardware connections are okay. Remember if lcd is not dectected lcd_init function returns 1. So you can check it by writing like this

if (lcd_init(16))
    PORTC = 1;

And you can connect a led to PC0 pin to check if led is lit. If LED is not lit then checkout lcd connections again.
After compiling the c code, burn the hex code of your program into your atmega MPU using atmel burning tools. After programming MPU is done place the it on the circuit. Now connect the power supply. I think you’ll have some fun.
To use this code with atmega16 change this line


“#include <mega32.h>”
To
“#include <mega16.h>”

In the same way, change to mega8.h for atmega8 mpu. You can download the whole project code and proteus simulation files which works perfectly for atmega32 from here.


Attaching Temperature Sensor for Displaying Temperature

If you want to know how atmega ADC works follow here.
With codevision you might be in confusion how to do a simple adc read. Don’t wonder I was worried too. But I’ve found it easy finally.

The function to read the analog data is like this one:

// if you are using AVCC as reference, to set internal voltage as reference // you need to set it to 0xC0
#define ADC_VREF_TYPE 0x40
// Read the AD conversion result 
unsigned int read_adc(unsigned char adc_input) 

    // Set ADMUX register to let it know which is your reference voltage
    ADMUX=adc_input | (ADC_VREF_TYPE & 0xff); 
    // Delay needed for the stabilization of the ADC input voltage 
    delay_us(10); 
    // Start the AD conversion, set ADSC bit in Status register
    ADCSRA|=0x40; 
    // Wait for the AD conversion to complete, check if ADIF bit is 1, wait
    // until it is set to one
    while ((ADCSRA & 0x10)==0); 
    ADCSRA|=0x10; 
    return ADCW; 
}


Assuming this code is in top of your main function a simple call to this function will return value for analog input.

int temp;
temp = read_adc(0); // 0 means 1st input of PortA

Some images of the final project has been attached below. Click on the images to view in high resolution.


Fig: Atmega32 MPU in a Project Board


Fig: LCD connection with MPU


Fig: A Power supply of 5V has been attached





Fig: The Illumniated LCD (GDM1602A)

Download this document as doc file from here.

Saturday, October 24, 2009

ICPC Regional Contest 2009 (Dhaka Site).



ICPC Dhaka Regional Contest which is hosted by Northsouth University this year is one of the major events today.
See the results of the contest here:
Regional Contest 2009 [Dhaka Site] Summary

Notice the contest ranking updated last was before 20 minutes till the contest ends. So final result might change.

Saturday, October 17, 2009

About Importing Blogs on FaceBook

Blogging is fun every blogger knows it. It becomes more fun when friends visit your blog site. Obviously, facebook, the social networking website can help you to a great extent. You may not know that there is an option in facebook to import your blog whether it is Bangla blog, Blogger (blogspot.com) or others you are using. Here I describe how you can import your blog in facebook notes.

Step 1: Log into FaceBook as usual.

Step 2
: There is an application menu button on the left bottom of your facebook homepage. Click that to display the menu. Look on the left hand side of your screen you’ll see a menu list of different Applications.


There is an option there called Notes. Click on that link.

Step 3: It will bring you to your notes page where notes of you and your friends are displayed. Look on the right side of the page. There is link saying “import a blog” under Note Settings. Clink on it.




Step 4: A form with a textbox will be displayed which like one in the below image.



Enter your blog url in the textbox. For example, http://saint-atique.blogspot.com
Tick the checkbox underneath the url. You don’t need to setup additional thing. Facebook will detect it automatically.
And some tips in advance, once you write a post in your blog it will be imported in your facebook notes. If you want some of the posts not to display on notes just feel free to delete them from facebook notes. It will be in your blog still available but in facebook it is not displayed.
When a post is imported by facebook update of the posts afterwards in your blog never takes effect on facebook. The updated one remains in your blog, facebook displays the old version.
It’s why I always encourage you to read the original post by clicking the link from facebook notes as shown below:


Friday, October 16, 2009

Google Chrome Latest Releases Direct Download Links and Google Search Tips & Tricks

Google Chrome Latest Stable and Beta Releases without Google Updater

Google Chrome is an open-source browser which doesn't require a introduction now. Still it is a light-weight fast web browser that now supports themes.
Also it has some intelligent things integrated with. For example, all google search syntax can be applied on the address bar.


The most significant thing I like about google chrome in first is it's powerful virtual machine. Did you notice the load time of New Yahoo Mail and Gmail in Chrome? It's damn faster. Every site with javascript and other rendering contexts will load faster in chrome. We spend most of our time in web browser than other applications. If our pageloads take longer time just sum of wasted valuable time gets huge. So the suggestion is use Google Chrome, save your time.

With Google Chrome 4 you can use many themes as well as huge set of extensions.


You can save more of your time by directly typing search queries on address bar. If you want the definition of word technology type in the address bar "define: technology" (without the quotations).

You want to know the time type location preceded by time like this "time Bangladesh".
You want to know to do some calculations you can do that easily "2 + 2 = "
Need to know about weather? Type like this "weather Dhaka, Bangladesh"

Curious? Want to know more about Google Search Features? Click here. Users who are using other browsers like Mozilla Firefox can use these syntaxes in google web search site. Note this post will be updated with latest releases of Google Chrome. So you can bookmark if it helps. To Download Google Chrome full installer from google's server click on links below:

Download Latest Stable Release
Download Latest Development Release

Linux users follow this link:

Instruction for Installing Google Chrome on Linux

Related Links:
Google Chrome Home Page
Google's Official Chrome Release Blog
Google search Features
Google search basics

Wednesday, October 7, 2009

Resource for Learning .NET Framework and Visual Studio IDE.

.net is the easiest of those lanugages I have ever seen. Just keep trust one me. Visual Studio 2008 IDE does the most of your work. You just modify portion of the code to achieve what you need. To modify the code you need to understand .net framework. And also you must need to learn the IDE and how it works.
For beginners this book is best cause with c++ you'll feel comfortable. If you learn with one language others just get easy.



Beginning Visual C++ 2008 by Ivor Horton's. It's a very good book for beginners. Download it from the following link.
http://www.mediafire.com/?iph64jibfig
Another book



http://rapidshare.com/files/207860587/Wrox.Professional.Visual.Studio.2008.Jul.2008.eBook-DDU.pdf

For experts, Using Visual C 6th Special Edition by Ivor Hortons is cool. Click the below link to download.
http://www.mediafire.com/?en3rd1wvtam
Well, book on C#,

Microsoft Visual Studio .NET - Mastering C#



http://www.mediafire.com/?ja4lnqjojqg
http://rapidshare.com/files/152590839/Wrox_Beginning_Microsoft_Visual_C_Sharp_2008_May_2008.rar
Or you can learn them all from online tutorial http://winprog.org/tutorial/ including win32.
And of course microsoft msdn is a good resource you can access it online or the one available with Visual Studio.
For .net you can get help here:
http://msdn.microsoft.com/en-us/library/w0x726c2.aspx
http://msdn.microsoft.com/en-us/library/ms734712.aspx

When you work with databases these books will help
Microsoft SQL Server 2005 Unleashed ebook
http://mediafire.com/?9khyhl0yuml

Microsoft SQL Server 2005 Programming For Dummies
http://www.mediafire.com/?i4nzldwmwhm

For win32 access this page
http://msdn.microsoft.com/en-us/library/aa139672.aspx

I'll publish detail tutorials on .net and MFC soon including win32.
asp.net tutorial here: http://www.w3schools.com/aspnet/aspnet_intro.asp

Always use Visual Studio Pro versions. Express versions are free from microsoft but create a great deal of trouble. For real application you need Visual Studio 2008. Don't have Visual Studio 2008 Pro?
You can download Visual Studio 2008 Professional Edition (90-day Trial) from microsoft directly here: http://www.microsoft.com/downloads/details.aspx?FamilyID=83c3a1ec-ed72-4a79-8961-25635db0192b&displaylang=en

Can't find the books you want? Try this search engine
http://www.filestube.com/search.html?q=Beginning+visual+c%2B%2B+mediafire&select=All


Monday, October 5, 2009

Awaking the night.

There are interesting things I observe during night. Most of the people sleep at night. They start sleeping from 12:00 am normally which is exactly midnight and if you were in rural area you'd feel the deep dark night with some inspiring noises for sleeping from insects, birds sitting on the trees.

Well those villages are irrelevant here since we have come to a highly civilized and materialized sophisticated society with a lot of traffic jams, dusts and drains. Yeah Man! We're in the city. Well that's not a great mess!

Here people are not farmers (at least the most) and they wouldn't sleep at 10:00pm. Even some sleep but never think it lasts long. They have late night show. I'll tell you about it another day. For now just know that they're to flirt the girls they love or likely to love and that nap is just a preparation in the physical side!

As I live in a residential hall of University of Dhaka I see these things. As I'm a computer addicted person I wake up the nights sitting in from of my computer monitor, typing things using the keyboard and moving the objects using the mouse. That's how whole night is spent. Sometimes it worths, sometimes just waste in vein.

During this time all other students sleep. Some watch bad dreams. They shout. I just get scared. Then I laugh. Some'd call out the names of actresses they love. Well I think they go through nice times during sleep.

If someone just cannot feel sleeping they start watching movies in their PCs to make the time worth. As I am always awake this time they are happy to see at least getting one companion. Sometimes come over to me to have fun and sometimes to see what I'm doing doing. They'd either see I'm in black console typing things using keyboard and it replies or in the internet browsing some sites on technical things. Sometimes they are surprised and then onwards it fades. But when hour of clock touches 4 or 5 they cannot stand any more and just fell asleep. I always win.

As this is very tough for me to close the windows floating in my monitor screen and shut the operating system down I can never make the sleep at night which costs a lot. It affects both physical and mental side.

It's kinda funny though. I thought of a software to rule against me being with the software. I thought many times about but could never make time for it. As for now I've done it. This software installed in any PC'd make the PC shut down from 1:00AM to 9:00AM I'm getting into disciplines. If feels exciting.

If you've any suggestion (especially if you find it useful) about the software feel free to leave it in comments.

You can download it here. One thing, you may need Visual C++ Redistributable to run it.

Minimum requirement Windows NT. It means it'll run in any PCs with current Windows OSs.

Friday, October 2, 2009

A Coder's Approach to Blogger, creating posts using html

The blogger’s editor is worse! Either it will mess the codes or the output. Never gives me the desired result. Understanding the code really helped me. Below I mention every type of formatting and a sample code to use for that. If you paste those codes on blogger [html edit option] you will see in the preview how nice it works.

Simple Title
<div style="text-align: center;">
<span style="line-height: 15px; white-space: normal;">
<span style="font-size: x-large;"><span style="color: #783f04;">
<span style="font-family: Arial, Helvetica, sans-serif;">
This is the title to be shown
</span></span></span></span>
</div>

A Standard Title that I like
<div style="text-align: center;">
<span style="font-family: Arial, Helvetica, sans-serif;">
<span style="font-size: x-large;">
<span style="color: #b45f06;"> // We can set color as we wish
Standard Title to be Shown
</span></span></span></div>

Normal Text
<div style="text-align: justify;"> // Justify the text
<span style="line-height: 15px; white-space: normal;">
// White spaces visible
<span style="font-family: Verdana, sans-serif;">
// Set font verdana
<span style="font-size: small;"> // Set small font
Making Money Online: A True Approach
</span></span></span>
</div>

Inserting an image
<div class="separator" style="clear: both; text-align: center;">
<a href="http://bux.to/images/top.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;">
<img border="0" src="http://bux.to/images/top.png" /></a>
</div>

My Own Numbering
<span style="font-size: x-large;"> // I’m trying a large one
<span style="color: #990000;">
<span style="font-family: Verdana, sans-serif;">
1 // use any symbol you want
</span></span></span>

Hyperlink Text Segment
It’s as easy as it is in html.
<a href="https://www.alertpay.com/">
<span style="font-family: Verdana, sans-serif;"> // set font
Text to show</span></a>

Beautified Tabbed Links
<span style="font-family: Arial, Helvetica, sans-serif; font-size: small;">
<span style="font-size: 12px; line-height: 15px; white-space: pre-wrap;">
// To accept space and newlines
<a href="http://ptc-investgations.blogspot.com/2009/04/buxto-confirmed-scammer.html">
http://ptc-investgations.blogspot.com/2009/04/buxto-confirmed-scammer.html
</a></span></span>

Bold
<span style="font-family: Arial, Helvetica, sans-serif; font-size: small;">
<span style="font-size: 12px; line-height: 15px; white-space: pre-wrap;">
<b>Bold Statement</b>
</span></span>

Tips and Tricks
Justify texts
<div style="text-align: justify;"></div>
New paragraph
<div>Para here</div>
Alternative to new lines:
<span style="font-size: small;"></span>

Office Equivalent Title
<div style="text-align: left;">
<span style="line-height: 15px; white-space: pre-wrap;">
<span style="font-size: x-large;">
<span style="color: #4F81BD;">
<span style="font-family: Cambria, sans-serif;">
This is the title to be shown
</span></span></span></span> </div>

Programming Language Codes In html
Only care should be taken for < and > signs. "<" should be noted by &gt; and ">" should be noted by &lt;
Outside of code tags, you may need to use entities for some characters:
For: Use:
& &amp
< &lt;
> &gt;
[ &#91;
] &#93;