Friday, December 7, 2012

RF remote controlled home loads.

RF remote controlled home loads
                As  I already mentioned earlier the basic need to build an embedded system is the desired application. First you decide what application you want. I chose my application that is  to build a system that can control the home loads through  remote.  I decided to do that project strongly, and what is next step ?  That Is our required functionality. Here I decided to control four home loads that might be fan, lights, TV, etc., .  
Then draw the basic block diagram of your application

I built my block diagram as I required.  Go through the required components, I chose                              

Transmitter Part:-
Ø  Since I am using wireless communication I required one receiver transmitter pair.

     Here am using RF Txr &Rxr pair which will be operated in 433MHz frequency band. These pair can operate in limited area  up to 80mtrs. Instead we can use IR transmission also but it can operate in line –of-sight conditions.
Ø  To operate the four loads I can choose 4-push buttons at the transmitter side. Since wireless communication is a serial communication we can’t transmit parallel data. So we require a Encoder which can convert parallel data to serial data. Here I chose HT12E encoder. With this I completed the basic requirements to build transmitter part. The total circuit will
      be shown later.
Receiver Part:-
Ø  Encoded data will be received through the RF receiver.  It has
    to convert from serial data to parallel data, for that  we need to
    use the compatible Decoder. I chose HT12D  decoder.
Ø  To control the actions we need one controller. I am choosing AT89C51 controller because am good at this.
Ø  Since we are controlling AC loads we need Relay circuits(SPDT single pole double threw 12-v)
Designing:-
Transmitter:-
HT12E is 18-pin dip it has 8-Address pins and 4 Data pins.


Pins 1-8 are address pins here we don’t need. 14-pin is floating pin. Pins 10-13 are data pins D8 to D11 respectively. 15 and 16 pins are oscillator pins.17th pin is Data out. S1-S4 are push buttons.
Receiver:-
          Receiver data flow:-
                       RF receiver à Decoder à microcontroller à relays à loads
Ø  The RF receiver part connection is same just like transmitter part. The parallel is fed to AT89C51 microcontroller. The resulted outputs are  fed to relays through transistors.





MicroController:-
 It is a 8-bit and 40-pin DIP micro controller developed by Atmel corporation. It has 4 ports
PORT-0: multiplexed  Address and Data lines floating pins
PORT-1: I/O port floating pins
PORT-2: higher order Address pins floating pins
PORT-3: I/O pins and have a special function to each pin
11.0592MHz crystal provides the Clock frequency to the Micro controller.
Relay:-
 1N4148 diode protects the transistor and relay from the damage and back emf.
FLOW CHART:-
        Flow chart will illustrates the total control functionality of the circuit






Initially all the inputs are assigned to ‘1’ and all the loads are assigned to ‘0’.      
  When switch1 is pressed at the Txr it generate 1110 data. This data is compared in the micro-controller. If it matches then load1 preformed XOR operation  with ‘1’. If initial value is ‘0’
 
                                   0 xor 1=1;                                                                                                                                                                                                                                                        When second time pressed the same switch-1 then (already load-1=’1’)
                                               1 xor 1=0;
 The same operation is performed to switches-1,-2 and -3.

Source Code:-

#include<reg51.h>
sfr rfr=0x90;
sbit load1=P3^0;
sbit load2=P3^1;
sbit load3=P3^2;
sbit load4=P3^3;
unsigned int i;
void main()
{
rfr=0x0F;  // initialising as input port
load1=0;   // output pin
load2=0; // output pin
load3=0; // output pin
load4=0;  // output pin
while(1)  // super loop
{
if(rfr==0x0E // checks if switch-1 is pressed or not
{
  load1^='1';   //xor operation
for(i=0;i<50;i++);
}
else if(rfr==0x0D)  // checks if switch-2 is pressed or not
{
load2^='1';    //xor operation
for(i=0;i<50;i++);
}
else if(rfr==0x0B)   // checks if switch-3 is pressed or not
{
load3^='1'; //xor operation
for(i=0;i<50;i++);
}
else if(rfr==0x07)   // checks if switch-4 is pressed or not
{
load4^='1';  //xor operation
for(i=0;i<50;i++);
}

}
}









Propeller project.
#include<reg51.h>
  sfr leds=0xB0;
  unsigned int i;
  void main()
  {
   leds=0x00;
   while(1)
   {
    leds=0xFE;
leds=0x14;
leds=0x12;
leds=0x12;
leds=0x14;
leds=0xF8;
for(i=0;i<10;i++);
leds=0xFE;
leds=0x04;
leds=0x04;
leds=0x08;
leds=0x10;
leds=0x20;
leds=0xFE;
for(i=0;i<10;i++)
leds=0xFE;
leds=0x14;
leds=0x12;
leds=0x12;
leds=0x14;
leds=0xF8;
for(i=0;i<10;i++);
leds=0xFE;
leds=0x04;
leds=0x04;
leds=0x08;
leds=0x10;
leds=0x20;
leds=0xFE;
for(i=0;i<10;i++)
    leds=0xFE;
leds=0x82;
leds=0x44;
leds=0x38;
  }
}

Friday, November 9, 2012


One has to do these programs to use the specific controller in the real world applications

Friday, August 17, 2012

simple Secure data transmission using AT89C51


//--- data encryption and decryption---//
//--- same program for receiver and transmitter
#include<reg51.h>
sfr in=0x80;
sfr out=0x90;
void delay(void);
void main()
{
  in=0xFF;
  out=0x00;
  while(1)
  {
   unsigned int i,p1,seq,p2;
   p1=in;
   seq=~p1;
   p2=seq^0x55;
   out=p2;
   for(i=0;i<10;i++)
   {
   delay();
   }
   }
}
 void delay(void)
 {

  TMOD=0x10;
  TL1=0xFD;
  TH1=0x4B;
  TR1=1;
  while(TF1==0);
  TF1=0;
  }

Friday, July 20, 2012

PART-1:- Basic embedded system designing 
   In a simple manner  embedded system is a system that can control some specific devices automatically or manually.To design an embedded system we need to follow these steps

1).  For any embedded system design the first requirement is the application, which we want to design
in practical.

2). Select the input and output devices which you want to interface (like input devices are sensors, switches etc., and output devices are motors, lcd display etc.,).

3).The input and output devices must be selected as per our requirements only.

4). Take out your required functioning and draw the simple block diagram of the system.

5). Draw the flow chart

6). Select the I/O devices and controller for your system.

7). write the functioning code in Embedded-C or in any language.. and check the functionality in KEIL simulation software.

8). Design your own circuit now. There are some important things while designing the circuit.
     i). Study the datasheets of the selected devices and find the operating voltage and current levels.
     ii). find if there is any requirement of oscillatory circuit.
     iii). choose the predefined parameters for the device for the  basic functionality. These predefined
          parameters are available in datasheets.
    iv). solder the main blocks first and do not insert any IC's into the baser until you check the voltage and
        currents in the baser.
    v). if every thing is properly soldered then insert IC's and then dump the program into the controller.
     vi). now check the functionality of the circuit.
        These steps will be explained with example in the PART-2...

Thursday, July 5, 2012



source code:-


//----- reading the char or no from the keyboard----//
#include<reg51.h>
sfr ROW=0x80; //assigning PORT-0 to read rows
sfr COL=0xA0; //assigning PORT-2 to read colomns
sfr ldata=0x90; //assigning PORT-1 for LCD data
sbit rs=P3^0;
sbit rw=P3^1;
sbit en=P3^2;
sbit busy=P2^7;
void lcdcmd(unsigned char value);
void lcddata(unsigned char value);
void lcdready(void);
void msdelay(unsigned int itime);
void lcddisplay(unsigned char ch);
  void clear(void);

void main()
{
unsigned char dat[4][4]={'7','8','9','%', // assigning key matrix
                          '4','5','6','*',
  '1','2','3','-',
  'C','0','=','+'};
 unsigned char colloc,rowloc;
 COL=0xFF;
 ROW=0x00;
 rs=0;
 rw=0;
 en=0;
 busy=0;
 /* setting LCD screen*/
 ldata=0x00;
 lcdcmd(0x38);
 lcdcmd(0x0E);
 lcdcmd(0x01);
 lcdcmd(0x06);
 lcdcmd(0x80);
 while(1)
 {
/* reading character from keyboard */
   do
   {
    ROW=0x00;
    colloc=COL;
colloc&=0x0F;
}while(colloc!=0x0F);
do
{
do
{
 msdelay(25);
 colloc=COL;
 colloc&=0x0F;
 }while(colloc==0x0F);
 msdelay(25);
 colloc=COL;
 colloc&=0x0F;
 }while(colloc==0x0F);
    while(1)
{
ROW=0xFE;
colloc=COL;
colloc&=0x0F;
if(colloc!=0x0F)
{
 rowloc=0;
 break;
 }
 ROW=0xFD;
 colloc=COL;
 colloc&=0x0F;
  if(colloc!=0x0F)
  {
   rowloc=1;
break;
}
 ROW=0xFB;
 colloc=COL;
 colloc&=0x0F;
  if(colloc!=0x0F)
  {
   rowloc=2;
break;
}
 ROW=0xF7;
 colloc=COL;
 colloc&=0x0F;
if(colloc!=0x0F)
 {
     rowloc=3;
     break;
   }
  }
   if(colloc==0x0E)
   lcddisplay(dat[rowloc][0]);
   else if(colloc==0x0D)
   lcddisplay(dat[rowloc][1]);
   else if(colloc==0x0B)
   lcddisplay(dat[rowloc][2]);
   else
    lcddisplay(dat[rowloc][3]);
}
  }
  /*displaying char on LCD screen*/
void lcddisplay(unsigned char x)
{
 if(x=='C')
  {
   clear();
    }

 else
 lcddata(x);
   }
 /* sending commands to  LCD display to act in command mode */
void lcdcmd(unsigned char value)
{
 lcdready();
 ldata=value;
 rs=0;
 rw=0;
 en=1;
 msdelay(1);
 en=0;
 }
 /* sending commnad to LCD to display characters*/
void lcddata(unsigned char value)
{
 lcdready();
 ldata=value;
 rs=1;
 rw=0;
 en=1;
 msdelay(20);
 en=0;
 }
 /* checking LCD buffer for free */
void lcdready(void)
{
 busy=1;
 rs=0;
 rw=1;
 if(busy==1)
  {
   en=0;
   msdelay(20);
   en=1;
   }
}
/* generating delay*/
void msdelay(unsigned int value)
{
 unsigned int i,j;
 for(i=0;i<value;i++)
 for(j=0;j<100;j++);
 }
 void clear(void)
 {
  lcdcmd(0x01);
  }






                 This circuit can serve the pumping motor for 5-6sec when the push button was closed. This is a good thing of this circuit. so we can use it for decoration purposes. I made it for pouring milk and water on lord ganapathi head when somebody placed 5Rs/- coin in a money box.

 Working:- It is a Monotable Multivibrator circuit. The components R3 and C3 provides the Triggering to the IC555 timer. The push button is located at the coin entry level. so when somebody placed a coin the coin box it touches the push button. so that it can activate the triggering circuit. C3 and R3 provides the output pulse duration.  

Wednesday, July 4, 2012




source code:

 //-----data display in LCD screen-----//
#include<reg51.h>
sfr ldata=0x90;
sbit rs=P2^0;
sbit rw=P2^1;
sbit en=P2^2;
sbit sw1=P3^0;
sbit sw2=P3^1;
sbit sw3=P3^2;
//sbit sw4=P3^3;
void lcdcmd(unsigned char valude);
void lcddata(unsigned char value);
void delay(unsigned int itime);
void main()
{ unsigned int i;
 unsigned char x[30]={"THATI ANAND ELECTRONICS DEPT."};
 unsigned char x1[30]={" HELLO WORLD  WELCOME ECE"};
  unsigned char x2[30]={"HELLO EINSTEIN HOW ARE YOU SIR"};
  unsigned char c;
 ldata=0x00;
 rs=0;
 rw=0;
 en=0;
 sw1=1;
 sw2=1;
 sw3=1;
 //sw4=1;
while(1)
{
 lcdcmd(0x38);
 delay(25);
 lcdcmd(0x0E);
 delay(25);
 lcdcmd(0x01);
 delay(25);
 lcdcmd(0x06);
 delay(25);
 lcdcmd(0x81);
 delay(25);
 if(sw1==0)
   {
    for(i=0;i<12;i++)
      {
        c=x[i];
        lcddata(c);
         delay(25);
       }
     lcdcmd(0x0C0);
      delay(25);
     for(i=12;i<30;i++)
      {
       c=x[i];
    lcddata(c);
    delay(25);
    }
   }
if(sw2==0)
    {
for(i=0;i<12;i++)
     {
      c=x1[i];
      lcddata(c);
       delay(25);
     }
    lcdcmd(0x0C0);
    delay(25);
    for(i=12;i<30;i++)
      {
       c=x1[i];
       lcddata(c);
       delay(25);
    }
}
if(sw3==0)
   {
    for(i=0;i<15;i++)
      {
        c=x2[i];
        lcddata(c);
         delay(25);
       }
     lcdcmd(0x0C0);
      delay(25);
     for(i=15;i<30;i++)
      {
       c=x2[i];
    lcddata(c);
    delay(25);
    }
   }

 }
 }
 void lcdcmd(unsigned char value)
 {
  ldata=value;
  rs=0;
  rw=0;
  en=1;
  delay(1);
  en=0;
  return;
  }
 void lcddata(unsigned char value)
  {
   ldata=value;
   rs=1;
   rw=0;
   en=1;
   delay(1);
   en=0;
   return;
   }
   void delay(unsigned int itime)
   {
    unsigned int i,j;
for(i=0;i<itime;i++)
for(j=0;j<1275;j++);
}


Here ADC0848 is replaced with push buttons at port-2.

Saturday, June 30, 2012

http://www.codeforge.com/s/0/SPI-Flash-Programmer-3.7

Free open source codes available here
http://www.careerairforce.nic.in/
Indian Air Force recruiting for the posts technical and ground duty candidates.
Last Date 09-July-2012 

Motion detection movable Robot with AT89C51

  The motion dependent applications are becoming  more popular in the present days for example  a door can open when there is a human movement in the sensor region. Likewise it can be used as person detection robot. This the prototype of that kind. Here we use simple circuit to detect the human is dead or alive. It is more important to identify and rescue the live persons when natural disaster situations.
This circuit is designed with AT89C51 microcontroller which is a basic microcontroller. Here we use PIR(Passive Infrared ) sensor to detect the motion. The robot can move in all directions. It is a wireless RF controlled robot.

Txr PART:-
          The transmitter part is shown in fig.1 it designed with HT12E Encoder and 4 push buttons. Whenever the user presses the buttons it generates 12-bit data which contains 8-bit address can set and 4 data bits. These data is transmitted to the robot by the RF transmitter which is running at 433MHz frequency. For each button pressed it generates a different code. The entire Transmitter circuit requires 5v DC supply.

Rxr PART:-

          This  contains the RF receiver and its output to the decoder. The decoder here we should use the HT12D to decode the received data. The output of the decoder is 4-bit data which is generated at the transmitter level when the  switch pressed. For motor operations we required to write the C code. Detection of  human is manual control. The commands can be passed to the robot whenever we want switch the detection. Here I used forward and backward buttons to control the detection operation. For this we need to stop the robot at doubted place and press the forward and backward buttons at a time. If the PIR detects motion then the controller sends  high input to the  buzzer to indicate that the person is alive. To smoothen the motor operations and currents we use L293D IC. These 60 RPM DC motors requires a voltage of 12V and it can be provided by lead acid battery.

          Assemble the circuit on a general purpose PCB. And arrange it on robotic structured cabinet. This was practically implemented and tested.  


                                                     Fig.1  Receiver part


Fig.2 Transmitter part

This circuit can detect motion with the help of PIR sensor, it is a simple and well working circuit. It was tested practically.

The source code is:

#include<reg51.h>
sfr rfr=0x90;
sfr mtr=0xB0;
sbit pir=P2^0;
sbit buz=P2^3;
void detection(void);
void main()
{
 rfr=0xFF;
 buz=0;
 while(1)
  {
   if(rfr==0x0E)
    {
  mtr=0x05;
  }
 else if(rfr==0x0D)
  {
   mtr=0x0A;
   }
 else if(rfr==0x0B)
  {
   mtr=0x02;
   }
 else if(rfr==0x07)
   {
    mtr=0x08;
    }
 else if(rfr==0x0C)
   {
   detection();
  }
   else if(rfr==0x0F)
    {

  mtr=0x00;
  buz=0;
   }
  else
      mtr=0x00;
   buz=0;
 }
 }
 void detection()
 {
 unsigned int i;
   mtr=0x00;
    if(pir==1)
     {
     buz=1;
     for(i=0;i<200;i++);   
      }
    else
       buz=0;
}