Showing posts with label LCD. Show all posts
Showing posts with label LCD. Show all posts

Monday, 31 March 2014

Digital Thermometer Interfaced with Android

The main aim of the project is to build a digital thermometer which can calculate temperature and send it to an android phone via a bluetooth module



Major Components


8051 Microcontroller board, LM35, ADC 0804, 16x2 LCD, Bluetooth Module, Serial board to board connector, Android phone

Block Diagram




Block Diagram showing Digital Thermometer Interface with Android


Circuit


Circuit showing Digital Thermometer Interface with android

Working


1. Temperature Sensor

LM35 is used as temperature sensor. It has a output Voltage proportional to Celsius temperature. The sensitivity is 10mV/C which means a temperature of 30 ℃ will produce a output voltage of 0.3V

2. Analog to Digital Converter

ADC0804 IC is used as ADC. It is a single channel ADC i.e can take only one analog signal as input. It has 8 bits which means it can produce a digital output between 0 to 255. It uses successive approximation technique to convert the analog input to digital output.

The step size can be adjusted by Vref/2 pin. If there is no voltage set at Vref/2 pin, the ADC considers Vcc as the reference voltage. So, for a 5V input the step size is 5/256 = 19.53mV. In case we provide 1.28V at Vref/2 pin, the reference voltage will be 2.56V so that step size is 2.56/256 = 10mV. This means for every 10mV increase in the analog input the digital output is incremented by 1 bit.

3. Micro controller

The digital output of ADC is interfaced to a 8051 microcontroller. The 8051 sets the start of conversion (SOC) on ADC and reads the digital values at the end of conversion (EOC). The digital values are in HEX, it is converted to BCD and displayed on LCD as char. Here is the code to interface 8051 with LCD
  • CS (pin 1 in the circuit) is always grounded which means ADC is always enabled
  • For SOC, provide a edge trigger from 0 to 1 to the WR pin (pin 3 in the circuit)
  • The ADC will take finite amount of time for conversion, after which INTR pin is indicates low (pin 5 in the circuit). This indicates EOC
  • After EOC, we can read the digital output by providing an edge trigger from 0 to 1 at RD pin (pin 2 in the circuit)
The micro controller is also interfaced to a serial profile Bluetooth module at a baud rate of 9600. Once the Bluetooth handshake is finished, a message packet constructed with temperature is also sent continuously to the Bluetooth via serial port

4. Android app

A custom built android app discovers the nearby Bluetooth devices and connects to the one with serial port profile. The message packet sent from 8051 is decoded and the temperature is displayed on the mobile screen

Monday, 16 April 2012

LCD Interface with 8051 Microntroller


C Code


#include <regx51.h>
#define LCD_COMMAND 0
#define LCD_DATA 1
#define LCD_RS P0_0       //Edit it per your circuit design
#define LCD_RW P0_1       //Edit it per your circuit design
#define LCD_EN P0_2       //Edit it per your circuit design
#define LCD_PORT P2       //Edit it per your circuit design

char *message_1 = "electronicsprojs";
char *message_2 = ".blogspot.com";

/*Function Prototypes*/

void LCD_delay(unsigned int);
void LCD_putc(int,int);
void LCD_puts(unsigned char*);
void LCD_init();

main()
{
 LCD_init();
 LCD_putc(0x80,LCD_COMMAND); //Write to Row 1
 LCD_puts(message_1);
 LCD_putc(0xC0,LCD_COMMAND); //Write to Row 2
 LCD_puts(message_2);
 LCD_delay(1000);
 while(1);
}

void LCD_init()
{
 LCD_EN = 1;
 LCD_RS = 0;

 LCD_putc(0x38,LCD_COMMAND); //Use 2 lines 5X7 matrix
 LCD_putc(0x0C,LCD_COMMAND); //Display on Cursor on
 LCD_putc(0x01,LCD_COMMAND); //Clear Screen
 LCD_delay(256);
}

void LCD_delay(unsigned int i)
{
 while(i>0)
  i--;
}


void LCD_putc(int character, int type)
{

 LCD_delay(10);
 LCD_RS = type;  //1 : Write Data, 0 : Write Command
 LCD_RW = 0;
 LCD_PORT = character;
 LCD_EN = 0;   //Latch data with a low to high pulse
 LCD_delay(10);
 LCD_EN = 1;
}

void LCD_puts(unsigned char *string)
{

 while (*string)
 {
  LCD_putc(*string++,LCD_DATA);
 }
}


Sunday, 4 March 2012

People Counting Machine with GSM

The main objective of this project is to design a system which counts the number of people present inside a premises with the count being sent automatically as an SMS upon dialing the phone number.


It consists of 3 modules

1. Infrared Transmitter and Receiver
There are two of them say IR1 and IR2. Breaking the beam of IR1 first and then IR2 will increment the count by 1 where as breaking the beam IR2 and then IR1 will decrement the count. The output of IR1 and IR2 are connected to microntroller interrupts INT0 and INT1 respectively. Complete design of IR Tx and Rx can be found here : Infrared Beam break Detector


2. Microncontroller with LCD
The microcontroller used here is 89c51. INT0 and INT1 of the micronctroller is connected to output of IR1 and IR2 respectively. It is connected to a GSM module via a serial port. And the microncontroller is also connected to a LCD which displays the total count at any given point of time. The microntroller increments or decrements the count based on weather INT0 interrupt occurs first and then INT1 or vice versa and continuously displays on the LCD. Micronctroller will also receive a serial interrupt when there is an incoming call in whch time it will read the phone number, disconnect and send the total count as a SMS

3. GSM Module
The microcontroller sends AT commands to GSM module to read the phone number, disconnect and send an SMS to the calling number. Below are the AT commands used.

1. Disconnect a call
ATH  and Enter

2. Read the phone number of an incoming call
  • Set the below AT command only once
  • AT+CLIP=1 and Enter
  • When there is a incoming call, the data from GSM will be similar to below for default settings
    • RING
      +CLIP: "+919449XXXXXX",145,"","",0
      RING
      +CLIP........
    • Read the phone number above into an array and send the SMS
    3. Send an SMS

    AT+CMGF=1 and Enter
    AT+CMGS="+919449XXXXXX" and Enter
    "Hello World" and CTRL+Z

    During programming CTRL+Z requires to be sent as 0x1A Ascii character while the escape character for Enter is '\r'. For better understanding on sending a SMS and C code, refer to Sending SMS using AT commands