Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Conversion of 8051 program to pic16F877a

Status
Not open for further replies.

Anwarullah

Newbie level 1
Joined
Oct 27, 2016
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
24
Greetings friends,
I am a student doing my Btech.EEE, I am assigned to make a project compiling smart home automation using android devices, I just need some help to convert a 8051 program to pic16F877a.

hereby in this mail I send the main program of 8051 and circuit diagram


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include<reg51.h>
sbit Fan=P2^0;
sbit Light=P2^1;
sbit TV=P2^2;
 char str;
 char Charin=0;
void delay(int time)
{
 unsigned int i,j;
 for(i=0;i<time;i++)
 for(j=0;j<1275;j++);
}
void Serialwrite(char byte)
{
  SBUF=byte;
  while(!TI);
  TI=0;
}
void Serialprintln(char *p)
{
  while(*p)
  {
    Serialwrite(*p);
    p++;
  }
  Serialwrite(0x0d);
}
void Serialbegin()
{
   TMOD=0x20;
   SCON=0x50;
   TH1=0xfd;
   TR1=1;
}
void main()
{
  P2=0x00;
  Serialbegin();
  Serialprintln("System Ready...");
  delay(50);
  while(1)
  {
    while(!RI);
    Charin=SBUF;
    str=Charin;
    RI=0;
      if(str=='1')
      {
        Fan=1;
        Serialprintln(" Fan ON");
        delay(50);
      }
      else if(str=='2')
      {
        Fan=0;
        Serialprintln(" Fan OFF");
        delay(50);
      }
       else if(str=='3')
      {
        Light=1;
        Serialprintln(" Light ON");
        delay(50);
      }
       else if(str=='4')
      {
        Light=0;
        Serialprintln(" Light OFF");
        delay(50);
      }
       else if(str=='5')
      {
        TV=1;
        Serialprintln(" TV ON");
        delay(50);
      }
       else if(str=='6')
      {
        TV=0;
        Serialprintln(" TV OFF");
        delay(50);
      }
      str=0;
  }
}


please help me in completing the project friends.

Regards,
Anwarullah
 

Attachments

  • Bluetooth-Controlled-Home-Automation-Circuit-diagram.gif
    Bluetooth-Controlled-Home-Automation-Circuit-diagram.gif
    36.7 KB · Views: 101
Last edited by a moderator:

See the attached Proteus Simulation Video. Do you want something like this ?
 

Attachments

  • Proteus Simulation Video.rar
    43.6 KB · Views: 120

Source down to line 46 include 8051 specific low level code and have to be rewritten for PIC. Your compiler suite (XC8, Mikro-C, CCS C or what?) has library functions to simplify access to IO ports and UART.

Did you consider to learn something about PIC programming or just looking for a volunteer to write the code for you?

May be you find help for the latter option, but it doesn't sound so well if you report your project work in a job interview...
 
I have ported the code to PIC16F877A. As it is your University project which you have to do to get a degree Certificate it is not good to post the project here because your Instructor or project guide may see it. If you don't have problem with me posting the project here then I will post it here. I have also sent a Private Message. reply to it.
 

The schematic doesn't show bluetooth module HC-05 as Proteus doesn't have that model. Virtual Terminal is used to send data to PIC in Simulation. In real hardware he has to use PIC16LF877A 93.3V device) to directly interface with BT module (3.3V device) or if he uses PIC16F877A (5V device) then he has to use voltage divider made of two resistors between the Rx pin of BT module and Tx pin of PIC. I have tested the project in hardware (EasyPIC v7) using PIC16LF877A I/P and HC-05 ad it works fine.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top