Sunday, January 30, 2011

How to make Digital Dice


Digital Dice


This digital dice project is an interesting project that will display in random the number from 1 to 9 on the 7 segment display. This is an alternative device that can be used to replace the traditional dice when you are playing games such as snake ladder, monopoly etc. The generation of clock is done by using a 555 timer which is connected in the astable mode at a frequency of approximately 50 Hz. This clock signal is fed into the decade counter which outputs are connected to 4 bit binary adder which provides a binary output equavalent to binary input + 1. The outputs are then connected to a BCD to 7 Segment Decoder which is used to drive a common anode 7 segment display.

As shown in the schematic above, when push button PB is pressed, a square output will be generated from the 555 timer whichgives a frequency of approximately 50 Hz to the 7490 decade counter IC. The frequency of the astable 555 timer is calculated by using the standard formula of the timer.
f = 1.44/(1K + 2*1K)(0.01uF) = 48 Hz.



The output from the 555 timer is then connected to the input of U1 7490 decade counter. When the decade counter reach the count of 9, the outputs of QA and QD will go to logic "1" and the counter is reset. The 7447 BCD to 7 segment decoder is used to drive the 7 segment common anode display.


Parts List




Solar Charger Circuit Diagram




The schematic uses a 12 volt solar panel and a variable voltage regulator IC LM 317. The solar panel consists of solar cells each rated at 1.2 volts. 12 volt DC is available from the panel to charge the battery. Charging current passes through D1 to the voltage regulator IC LM 317. By adjusting its Adjust pin, output voltage and current can be regulated. VR is placed between the adjust pin and ground to provide an output voltage of 9 volts to the battery. Resistor R3 Restrict the charging current and diode D2 prevents discharge of current from the battery. Transistor T1 and Zener diode ZD act as a cut off switch when the battery is full. Normally T1 is off and battery gets charging current. When the terminal voltage of the battery rises above 6.8 volts, Zener conducts and provides base current to T1. It then turns on grounding the output of LM 317 to stop charging.

Thursday, January 20, 2011

How to make Line Follower Robot ( video tutorial )

New Computer Technology



How to make Line follower robot (Detailed tutorial)





Line Follower ROBOT 








I designed my Robot, which use two motors control  rear wheels and the single front wheel is free. It has 4-infrared sensors on the bottom for detect black tracking tape, when the sensors detected black color, output of  comparator, LM324 is low logic and the other the output is high.
Microcontrollor AT89C2051 and H-Bridge driver L293D were used  to control direction and speed of motor. 




Fig 1. schematic diagram of my Robot.






 
Fig 2. schematic diagram of Infrared sensors and comparators. 
 
 
 
  
 

Fig 4.  Position of sensors,  left hand side is
side view and right hand side is top view.



 
Program In C-language
 
#include d:\mc51\8051io.h
#include d:\mc51\8051reg.h
extern register unsigned char speedleft,speedright;
register unsigned char high,low,flag,time;

main()
{
P1=0x40;
P3=0xff;
high = 80;
low = 30;
flag = 0;
time = 50;
Start();
while(1) {
P3|= 0x0f;
Run();
}
}

Start()
{
char exit,key;
exit =1;
while(exit)
{
key = P1;
if((key & 0x40)==0) exit=0;
}
}

Run()
{
char sensors;
sensors = (P3 &=0x0f);

if((sensors & 0x01)==0) {
TurnRight();
flag = 1; }

else if((sensors & 0x08)==0) {
TurnLeft();
flag = 2; }
else if(sensors == 0x09) {
Forward(high);
flag = 0; }

else if(((sensors==0x0b)||(sensors==0x0d))&&(flag==0))
Forward(low);

}

Forward(char speed)
{
P1=0x64;
speedright = speed+10;
speedleft = speed;
delay(time);
}

TurnRight()
{
P1=0x68;
speedright = low+5;
speedleft = low;
delay(time);
}

TurnLeft()
{
P1=0x54;
speedright = low+5;
speedleft = low;
delay(time);
}

Reverse(char speed)
{
P1=0x58;
speedright = speed;
speedleft = speed+5;
delay(time);
}

( watch video tutorial )

Tuesday, January 18, 2011

How to breadboard a DIY USB power supply

Today we turn a 7805 Voltage Regulator and 4 AA batteries into a very simple Power Supply to charge anything that runs off USB. Breadboarding schematics are fun!

How to build a hand cranked charger for your mobile phone

Is your Droid always running out of power, and a charger isn't always convenient? Start with a hand cranked flashlight, then wire it up so you can charge your phone by hand! Great for pulling your dying phone out of emergencies.

How to make a cheap multi-touch pad like in the MacBook Air


A simple multitouch pad made from a plastic bag, some dyed water, and a camera.

How to get free electricity from a phone jack

Learn how to get free electricity from your home telephone line just by watching this video. Save money on your power bill, and hack into the electricity coming out of the phone jack. The phone company doesn't monitor electricity usage, so you can probably get away with this con. Check out this video tutorial and learn how to tap into the electrical energy source in your phone line.

     

How to make a multitouch table computer pad

Multi-touch input has been spreading throughout a huge variety of devices, from phones to all-in-one PCs. However, most multitouch (table) displays that can function with your computer tend to be fairly expensive, so with this project we're going to make our own display, that can run on any operating system, and reuses some useless everyday materials.
Watch this video tutorial to learn how to make a multitouch table computer pad.

How to make a homemade acetate heater pad

Learn in this video how to make sodium acetate (hot ice experiment)with household item,and how to make heater pad re-usable more than 100time,give 45*c for 1 hour.

How to make a full functioning A_C and Heater

This video tutorial shows how to make a homemade air conditioner with cool/hot function. No need to buy both a heater and an a/c, this home-made device does both jobs. Watch this video schematicry tutorial and learn how to modify and build a full functioning air-conditioning and heating combo device.

How to build a portable personal heater

In this video, we learn how to build a portable personal heater. This is a great weekend project that is easy to make and will keep you warm during a freezing winter. You will need: two double a batteries, charger, twin double a battery charger, winding wire, and balsa wood. First, cut the wood the size of the battery holder and cut it out. Now, reel off 30 ft of winding wire and hold down with duct tape. Wind the wire around the piece of wood and tape down the other end of the wire. Scrape off parts of the end of the wires, then apply hot glue to the battery holder and attach the wood with coil. Now, solder the connections from the wires onto the battery holder. When finished, you can turn this on and it can be a heater whenever you would like!

Saturday, January 15, 2011

How to build USB power chargers.


From Systm learn how to build a USB battery supply that can charge your cell phone.
In today's episode, we're going to help you build three USB battery power supplies so you never run out of power for your favorite gadgets!

Saturday, January 1, 2011

INTERFACING LCD TO 89C51

Liquid crystal display is very important device in embedded system. It offers high flexibility to user as he can display the required data on it. But due to lack of proper approach to LCD interfacing many of them fail. Many people consider LCD interfacing a complex job but according to me LCD interfacing is very easy task, you just need to have a logical approach. This page is to help the enthusiast who wants to interface LCD with through understanding. Copy and Paste technique may not work when an embedded system engineer wants to apply LCD interfacing in real world projects.You will be knowing about the booster rockets on space shuttle. Without these booster rockets the space shuttle would not launch in geosynchronous orbit.  
Similarly to understand LCD interfacing you need to have booster rockets attached! To get it done right you must have general idea howto approach any given LCD.This page will help you develop logical approach towards LCD interfacing.

First thing to begin with is to know what LCD driver/controller is used in LCD.Yes, your LCD is dumb it does not know to talk with your microcontroller. LCD driver is a link between the microcontroller and LCD. You can refer the datasheet of LCD to know the LCD driver for e.g. JHD 162A is name of LCD having driver HD44780U.You have to interface the LCD according to the driver specification. To understand the algorithm of LCD interfacing user must have datasheet of both LCD and LCD driver. Many people ignore the datasheets and end up in troubles. If you want to interface LCD successfully you must have datasheets.
Why people ignore datasheets? Most of us do not like to read 100 pages of datasheet. But for a accurate technical specification datasheets are must. I will show you a technique to manipulate a datasheet within minutes.
First thing to find out in datasheet is the features viz. operating voltage, type of interface, maximum speed for interface in MHz, size of display data RAM, number of pixels, bits per pixel, number of row and columns. You must have the pin diagram of LCD.Pin diagram of LCD driver can be omitted.
Study the type of communication protocol whether it is parallel or serial interface. Check how LCD discriminates data bytes and command bytes, which pins on LCD are used for communication. Study Interface timing diagram given in the datasheet.
From datasheet of LCD driver find out whether hardware reset is required at startup, what is the time of reset pulse, is it active low and which pins of LCD are to be toggled.
Major task in LCD interfacing is the initialization sequence. In LCD initialization you have to send command bytes to LCD. Here you set the interface mode, display mode, address counter increment direction, set contrast of LCD, horizontal or vertical addressing mode, color format. This sequence is given in respective LCD driver datasheet. Studying the function set of LCD lets you know the definition of command bytes. It varies from one LCD to another. If you are able to initialize the LCD properly 90% of your job is done.
Next step after initialization is to send data bytes to required display data RAM memory location. Firstly set the address location using address set command byte and than send data bytes using the DDRAM write command. To address specific location in display data RAM one must have the knowledge of how the address counter is incremented.

Schematic


Algorithm to send data to LCD:

1.Make R/W low
2.Make RS=0 ;if data byte is command
RS=1 ;if data byte is data (ASCII value)
3.Place data byte on data register
4.Pulse E (HIGH to LOW)
5.Repeat the steps to send another data byte

LCD Initialization:

This is the pit fall for beginners.Proper working of LCD depend on the how the LCD is initialized. We have to send few command bytes to initialize the lcd. Simple steps to initialize the LCD
1.Specify function set:
Send 38H for 8-bit,double line and 5x7 dot character format.
2.Display On-Off control:
Send 0FH for display and blink cursor on.
3.Entry mode set:
Send 06H for cursor in increment position and shift is invisible.
4. Clear display:
Send 01H to clear display and return cursor to home position.



Addresses of cursor position for 16x2 HD44780 LCD

line1 80H 81H 82H 83H 84H 85H 86H 87H 88H 89H 8AH 8BH 8CH 8DH 8EH 8FH 
line2 C0H C1H C2H C3H C4H C5H C6H C7H C8H C9H CAH CBH CCH CDH CEH CFH 

Assembly Language Code

; Interfacing LCD 16x2 in 4-bit mode.
; Port0 to higher nibble data pins of LCD
; Crystal 3.579545 MHz
; AT89C51
;P2.0 to RS pin
;P2.1 to Enable Pin


ORG 0000H
AJMP MAIN
ORG 0030H
MAIN:
MOV SP,#60H ;STACK POINTER 
ACALL LCD_INIT ;Initialize lcd
MOV DPTR,#MESSAGE1 
CALL LCD_STRING ;Display message on LCD
CALL NEXT_LINE ;Place cursor to;second Line
MOV DPTR,#MESSAGE2 
CALL LCD_STRING ;Display message on LCD
HERE: AJMP HERE


LCD_INIT: ;initialize LCD in 4-bit mode
ANL P0,#0F0H
CALL LOOP
MOV DPTR,#LCDCODE 
MOV A,#0H
MOV R6,#0H
MOV R7,#0H
CLR P2.0 ;RS COMMAND
NEXT: ;8-bit code is split into two 4-bit nibbles.
INC R6
MOVC A,@A+DPTR
MOV R7,A
ANL A,#0F0H
SWAP A
ANL P0,#0F0H
ORL P0,A
ACALL ENABLE ;PULSE E sending first nibble
MOV A,R7
ANL A,#0FH
ANL P0,#0F0H
ORL P0,A
ACALL ENABLE ;PULSE E sending second nibble
MOV A,R6
CJNE R6,#09H,NEXT
RET


LCD_STRING:
MOV P0,#00H
SETB P2.0 ;RS DATA 
MOV A,#00H
MOV R6,#00H
NC: ;checks the end of message string
MOVC A,@A+DPTR
CJNE A,#2FH,NC1
RET
NC1:
LCALL LCD_WRITE
INC R6
MOV A,R6
AJMP NC


LCD_WRITE:
SETB P2.0 ;RS DATA
CALL LO
RET


NEXT_LINE:
MOV P0,#00H
CLR P2.0 ;RS COMMAND 
MOV A,#0C0H
CALL LO
RET


LCD_CLEAR: ;This Subroutine is used to clear LCD
CALL DELAYL
ANL P0,#00H
MOV A,#01H
CLR P2.0 ; RS command 
LO: ;8-bit code is split into two 4-bit nibbles.
MOV R7,A
ANL A,#0F0H
SWAP A
ANL P0,#0F0H
ORL P0,A
CALL ENABLE
MOV A,R7
ANL A,#0FH
ANL P0,#0F0H
ORL P0,A
CALL ENABLE
RET




ENABLE: ;Give High-to-low pulse at enable pin
SETB P2.1
CALL DELAYL
CLR P2.1
CALL DELAYL
RET




;With respect to crystal frequency 3.579 MHz
DELAYL: ; 5ms DELAY
SETB PSW.4 ; SELECT BANK 2
MOV R7,#25
HDH:
MOV R6,#60
DJNZ R6,$
DJNZ R7,HDH
CLR PSW.4 ;DEFAULT BANK 
RET


LOOP: ;1 SEC DELAY
MOV R7,#100
LOOP1:
CALL DELAYL
CALL DELAYL
DJNZ R7,LOOP1
RET

;LCD INITIALIZING CODE (DO NOT DISTURB THIS)
LCDCODE:
DB 02H
DB 02H
DB 02H
DB 28H
DB 28H
DB 28H
DB 0CH
DB 06H
DB 01H




;DATA TO BE DISPLAYED
;Maximum message length = 16 characters.
;To notify end of message place '/' at the end.


MESSAGE1: DB "LCD INTERFACING /" ;Change Message1


MESSAGE2: DB " BY JAYANTH /" ;Change Message2


END


Servo Motor control through Keypad using 8051 Microcontroller (AT89C51)


This project allows the servo motor to move to an angle specified by the user. The pulse train required to rotate the servo is produced by AT89C51 microcontroller. The desired angle of rotation is provided through a 4x3 keypad interfaced to the microcontroller. A 16x2 LCD is also connected with the microcontroller to display the angle of rotation entered by the user.



The first pin of port P1 (P1^0) of AT89C51 microcontroller is set as the output pin to provide control signal to the servo motor. Ports P0 and P2 are used to interface keypad and data pins of LCD, respectively. Ports P1^3, P1^4 and P1^5 are connected to RS, RW and EN pins of LCD, respectively.

Before connecting to the control wire of servo, the output from the microcontroller (P1^0) is fed through a comparator IC LM 324, so that the signal is protected from any loss due to overloading.
When the schematic is powered, the LCD prompts the user to enter the angle of rotation. The user can enter the angle in degrees through keypad. The angle entered by the user is also displayed on the LCD screen. As the user presses ‘*’ button of keypad, the angle of rotation is accepted by the microcontroller and the servo moves to the user defined angular position. If an angle greater than 180° is entered, the difference of the input with 180° is considered as the angle of rotation.
The program uses one of the 8051 timers to generate a 50 µs delay. A timer function is written which produces delay in multiples of 50 µs. A variable is taken as the argument to this function that determines the multiples. Initially when the microcontroller executes program, a pulse with ON time of 700 µs (14 x 50 µs) followed by OFF time of 18 ms is generated. This shifts the servo horn to 0° angle.
The angle entered by the user is stored in a variable whose value is added to the argument of the timer function. For example, if the user enters 90, the argument of the timer function is increased by 90 and becomes 104 (90 + 14). The ON time for the next train of pulses then corresponds to multiple of 50 µs. In this case the ON time of the next train of pulses will be 5200 µs (104 x 50 usec) followed by OFF time of 18 ms. This maintains the servo at 90° angle until the user enters the next angle.

C PRODRAMME:


// Program to rotate servo to user defined angular position

// 0 degree = 700us
// 180 degree = 5500us
// Timer1 pulse after 50us -23

#include<reg51.h>
#define dataport P2 // Data port for LCD
#define key P0 // Port for Keypad
#define port P1
sbit output = port^0;
sbit rs = port^3;
sbit rw = port^4;
sbit en = port^5;
sbit col1 = key^4;
sbit col2 = key^5;
sbit col3 = key^6;
sbit row1 = key^0;
sbit row2 = key^1;
sbit row3 = key^2;
sbit row4 = key^3;
int count=0,time=0,check, digit[3];
void delay(unsigned int msec) // Function for delay
{
int i,j;
for(i=0;i<msec;i++)
for(j=0;j<1275;j++);
}

void lcd_cmd(unsigned char item) // Function to send command to LCD
{
dataport = item;
rs= 0;
rw=0;
en=1;
delay(1);
en=0;
return;
}

void lcd_data(unsigned char item) // Function to send one byte data to LCD
{
dataport = item;
rs= 1;
rw=0;
en=1;
delay(1);
en=0;
return;
}

void lcd_data_string(unsigned char *str) // Function to send string to LCD
{
int i=0;
while(str[i]!='\0')
{
lcd_data(str[i]);
i++;
delay(10);
}
return;
}

lcd_data_int(int time_val) // Function to send three digit number
{
int int_amt;
int_amt = time_val/100;
lcd_data(int_amt+48);
time_val = time_val%100;
int_amt = time_val/10;
lcd_data(int_amt+48);
int_amt = time_val%10;
lcd_data(int_amt+48);
}

void shape() // Function to make degree sign
{
lcd_cmd(64);
lcd_data(2);
lcd_data(5);
lcd_data(2);
lcd_data(0);
lcd_data(0);
lcd_data(0);
lcd_data(0);
lcd_data(0);
}

void timer(int msec) // Function to produce pulse as defined by user
{
int i;
TR1=1;
for(i=0;i<msec;i++)
{
while(TF1==0);
TF1=0;
}
TR1=0;
}

void digit_set(int num)
{
if(count==4)
{
lcd_cmd(0x01);
lcd_data_string("done");
check=num;
}
else
{
check=0;
if(count==1)
digit[0]=num;
else
{
if(count==2)
{
digit[1]=digit[0];
digit[0]=num;
}
else
if(count==3)
{
digit[2]=digit[1];
digit[1]=digit[0];
digit[0]=num;
}
}
lcd_data((num+48));
}
}

void check_col1() // Col1 check
{
row1=row2=row3=row4=1;
row1=0;
if(col1==0) // Key 1
{
delay(10);
count=count+1;
digit_set(1);
}
row1=1;
row2=0;
if(col1==0) // Key 4
{
delay(10);
count=count+1;
digit_set(4);
}
row2=1;
row3=0;
if(col1==0) // Key 7
{
delay(10);
count=count+1;
digit_set(7);
}
row3=1;
row4=0;
if(col1==0) // Key *
{
delay(10);
count=count+1;
if(count==4)
{
digit_set(10);
}
else
{
count=4;
digit_set(10);
}
}
row4=1;
}

void check_col2() //Col2 check
{
row1=row2=row3=row4=1;
row1=0;
if(col2==0) // Key 2
{
delay(10);
count=count+1;
digit_set(2);
}
row1=1;
row2=0;
if(col2==0) // Key 5
{
delay(10);
count=count+1;
digit_set(5);
}
row2=1;
row3=0;
if(col2==0) // Key 8
{
delay(10);
count=count+1;
digit_set(8);
}
row3=1;
row4=0;
if(col2==0) // Key 0
{
delay(10);
count=count+1;
digit_set(0);
}
row4=1;
}

void check_col3() // Col3 check
{
row1=row2=row3=row4=1;
row1=0;
if(col3==0) // Key 3
{
delay(10);
count=count+1;
digit_set(3);
}
row1=1;
row2=0;
if(col3==0) // Key 6
{
delay(10);
count=count+1;
digit_set(6);
}
row2=1;
row3=0;
if(col3==0) // Key 9
{
delay(10);
count=count+1;
digit_set(9);
}
row3=1;
row4=0;
if(col3==0) // Key #
{
delay(10);
count=count+1;
lcd_data_string("wrong data");
lcd_cmd(0x01);
lcd_data_string("enter degree:");
lcd_cmd(0xc5);
count=0;
}
row4=1;
}

void keypad()
{
if(col1==0)
check_col1();
else
if(col2==0)
check_col2();
else
if(col3==0)
check_col3();
delay(10);
}

void main()
{
int i;
col1=col2=col3=1;
TMOD=0x20; // MODE2
TH1= -23; // 50 usec timer
shape();
output=0;

lcd_cmd(0x38);
lcd_cmd(0x0e);
lcd_cmd(0x01);
delay(100);
while(1)
{
count=0;
lcd_cmd(0x01);
lcd_data_string("enter degree:");
lcd_cmd(0xc5);
check=0;
digit[0]=0;
digit[1]=0;
digit[2]=0;
while(check!=10)
{
row1=row2=row3=row4=0;
while(col1==1 && col2==1 && col3==1);
keypad();
}
time=(digit[0]+(digit[1]*10)+(digit[2]*100));
lcd_cmd(0xc4);
time=time%180;
lcd_data_int(time);
lcd_data(0);
time= time*0.5; // (110-14)/180=0.53
for(i=0;i<200;i++)
{
output=1;
timer(14);
output=0;
timer(360);
}
delay(100);
for(i=0;i<200;i++)
{
output=1;
timer(time+14);
output=0;
timer(360);
}
timer(3000000);
}
}