Pages

Powered By Blogger

Thursday 30 June 2011

POWER SUPPLY for MICROCONTROLLERS


The input to the circuit is applied from the regulated power supply. The A.C. input i.e., 230V from the mains supply is step down by the transformer to 12V and is fed to a rectifier. The output obtained from the rectifier is a pulsating D.C voltage. So in order to get a pure D.C voltage, the output voltage from the rectifier is fed to a filter to remove any A.C components present even after rectification. Now, this voltage is given to a voltage regulator to obtain a pure constant dc voltage.


Transformer

Usually, DC voltages are required to operate various electronic equipment and these voltages are 5V, 9V or 12V. But these voltages cannot be obtained directly. Thus the a.c input available at the mains supply i.e., 230V is to be brought down to the required voltage level. This is done by a transformer. Thus, a step down transformer is employed to decrease the voltage to a required level.

Rectifier

The output from the transformer is fed to the rectifier. It converts A.C. into pulsating D.C. The rectifier may be a half wave or a full wave rectifier. In this project, a bridge rectifier is used because of its merits like good stability and full wave rectification.

Filter

Capacitive filter is used in this project. It removes the ripples from the output of rectifier and smoothens the D.C. Output received from this filter is constant until the mains voltage and load is maintained constant. However, if either of the two is varied, D.C. voltage received at this point changes. Therefore a regulator is applied at the output stage.

Voltage regulator

As the name itself implies, it regulates the input applied to it. A voltage regulator is an electrical regulator designed to automatically maintain a constant voltage level. In this project, power supply of 5V is required. In order to obtain these voltage levels, 7805 voltage regulator is to be used. The first number 78 represents positive supply and the numbers 05 represent the required output voltage levels.

Friday 17 June 2011

led dancing with switch


Pgm1:led dancing with switch
#include<reg51.h>
#define led P0
sbit sw=P1^0;
void delay(unsigned char);
void main()
{
P0=0xff;
while(1)
{
if(sw==1)
{
led=0x55;
delay(100);
led=0xaa;
delay(100);
}
else
{
led=0xaa;
delay(100);
led=0x55;
delay(100);
}
}
}
void delay(unsigned char b)
{
unsigned char i,j;
for(i=0;i<5;i++)
for(j=0;j<b;j++);
}
Prg2:led dancing
#include<reg51.h>
#define led P0
sbit sw=P1^0;
void delay(unsigned char);
void main()
{
P0=0xff;
while(1)
{
led=0x55;
delay(100);
led=0xaa;
delay(100);
}
}
}
void delay(unsigned char b)
{
unsigned char i,j;
for(i=0;i<5;i++)
for(j=0;j<b;j++);
}

Saturday 11 June 2011

switch and LED


#include<reg51.h>
#define led P0
sbit s1=P1^0;
sbit s2=P1^1;
void main()
{
P0=0xff;
while(1)
{
if (s1==0)
{
led=0x33;
P1=0xff;
}
else if(s2==0)
{
led=0xcc;
P1=0xff;
}
}
}

Serial Tx


#include<reg51.h>

void main()
{
TMOD=0x20;
TH1=0xFD;
SCON=0x50;
TR1=1;
while(1)
{
SBUF='A';
while(TI==0);
TI=0;
}
}

Serial Rx


#include<reg51.h>

void main()
{
unsigned char z;
TMOD=0x20;
TH1=0xFD;
SCON=0x50;
TR1=1;
while(1)
{
while(RI==0);
z=SBUF;
P1=z;
RI=0;
}
}

LED


#include<reg51.h>
#define led P0
void delay(unsigned char);
void main()
{
P0=0xff;
while(1)
{
led=0x55;
delay(10);
led=0xAA;
delay(10);
}
}
void delay(unsigned char b)
{
unsigned char i,j;
for(i=0;i<5;i++)
for(j=0;j<b;j++);
}

LCD


#include<reg51.h>
#define port P0
void lcddata(unsigned char);
void lcdcmd(unsigned char);
void Delay(unsigned char);
sbit RS=P1^0;
sbit RW=P1^1;
sbit EN=P1^2;
void main()
{
unsigned int i;
unsigned char A[5]={0x38,0x01,0x0f,0x06,0x80},D[7]="KISHORE",W[8]={'W','I','N','E','Y','A','R','D'};
for(i=0;i<5;i++)
lcdcmd(A[i]);
Delay(2);
for(i=0;i<7;i++)
lcddata(D[i]);
Delay(2);
lcdcmd(0xc0);
for(i=0;i<8;i++)
lcddata(W[i]);
}
void lcdcmd(unsigned char cmd)
{
port=cmd;
RS=0;
RW=0;
EN=1;
Delay(2);
EN=0;
}
void lcddata(unsigned char dat)
{
port=dat;
RS=1;
RW=0;
EN=1;
Delay(2);
EN=0;
}
void delay(unsigned char value)
{
unsigned char j;
for(j=0;j<value;j++);
}