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.

C codes for decoding RC5 signals using PIC microcontoller

Status
Not open for further replies.
Any way, you are completely right about that, and I have read this kind of info regarding the use of mancheter decoding in order to derive the clock from the RC5 signal it self inorder to detect the leading and trailing edges of the RC5 signal.
 

Yes, Guilty as charged.
hey btbass, could u provide the schematic diagram of the rc5 decoder? thank you

- - - Updated - - -

hey btbass, could u provide the schematic diagram of the rc5 decoder? thank you
 

There is no schematic as such.
I just used a TSOP4838 Infrared Reciever with the output going to the interrupt pin on the micro. I had a 10K pull up on the pin, and the power supply to the TSOP4838 was decoupled with a 100n on the supply pins.
 
  • Like
Reactions: tmcn

    tmcn

    Points: 2
    Helpful Answer Positive Rating
There is no schematic as such.
I just used a TSOP4838 Infrared Reciever with the output going to the interrupt pin on the micro. I had a 10K pull up on the pin, and the power supply to the TSOP4838 was decoupled with a 100n on the supply pins.
by the way, how far the transfer range can up to?
 

With your average handset, it's powerful enough to cover most large rooms. It even reflects off walls around corners.

Unless you live in a castle?
 


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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
#include<reg51.h>
 
#define dataport P1  //lcd 16x2 data port
#define cont_port P2
 
sbit rs = cont_port^0; //lcd rd pin @ P2_0 
sbit rw = cont_port^1; //lcd rw pin @ P2_1
sbit en = cont_port^2; //lcd en pin @ P2_2
 
sbit input = P3^3; //ir pin connected to Port3_3
 
 
 
int i;
int cmd,add,flip,val,val1,nflip;
 
void delay1()    //delay of 3.024msec
{
   
        TMOD=1;
        TL0=0x1D;
        TH0=0xF5;
        TR0=1;
        while(TF0 == 0);
        TR0=0;
        TF0=0;
   
}
 
void delay() //delay of 1.658msec
{
   
        TMOD=1;
        TL0=0x07;
        TH0=0xFA;
        TR0=1;
        while(TF0 == 0);
        TR0=0;
        TF0=0;
   
}
 
void mdelay(int msec)
{
    while(msec != 0)
    {
        TMOD=1;
        TL0=0x1D;
        TH0=0xF5;
        TR0=1;
        while(TF0 == 0);
        TR0=0;
        TF0=0;
        msec--;
    }
}
 
void lcd_cmd(unsigned char item)  //Function to send command to LCD           
{
    dataport = item;
    rs= 0;
    rw=0;
    en=1;
    delay1();
    en=0;
    return;
}
 
void lcd_data(unsigned char item) // Function to send data to LCD
{
    dataport = item;
    rs= 1;
    rw=0;
    en=1;
    delay1();
    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++;
          delay1();
    }
    return;
}
 
void lcd_data_int(int time_val)  // Function to send number to LCD
{
    int int_amt;
    int_amt=time_val/10;
    lcd_data(int_amt+48);
    int_amt=time_val%10; 
    lcd_data(int_amt+48);
}
 
void tog()        //calculate flip bit
{
    flip=input;
}
 
void address()    //calculate the address 
{
        for(i=0; i<5; i++)
        {
            add=(add<<1) | input;
            delay();
        }
}
 
void command()       //calculate the command
{
        for(i=0; i<6; i++)
        {
           
            cmd=(cmd<<1) | input;
            delay();
        }
}
 
 
void value()
{
    if(cmd >=0 && cmd <=9)
    {
       
        val=cmd;
    //    val=val*10+cmd;
       
    }
    else
    {
        lcd_cmd(0xcb);   
        lcd_data_string("NV");
        return;
    }
 
        lcd_cmd(0xcb);   
        lcd_data_int(val);
}
 
void display_init()    //display init
{
    lcd_cmd(0x38);
    delay();
    lcd_cmd(0x0E);
    delay();
    lcd_cmd(0x01);
    delay();
    lcd_cmd(0x06);
    delay();
   
    lcd_cmd(0x80);
    delay();
   
    lcd_data_string("ADD:");   
           
    lcd_cmd(0x89);
    delay();
    lcd_data_string("FLIP:");       
   
    lcd_cmd(0xC0);
    delay();
    lcd_data_string("CMD:");
 
    lcd_cmd(0xC9);
    delay();
    lcd_data_string("V:");
}
 
void display_value()     //display value
{
    lcd_cmd(0x84);
    delay();
    lcd_data_int(add);
   
    lcd_cmd(0x8E);
    delay();
    lcd_data_int(flip);
    lcd_cmd(0xc4);   
    delay();
    lcd_data_int(cmd);
}
void main()
{
   
    display_init();
               
    while(1)
    {
        add=0;
        cmd=0;   
       
        while(input == 1);
       
        delay1();
        tog();
        delay();
        address();
        command();
        nflip=flip;
        if(add == 0 && (flip==1 || flip == 0))
        {
   
         display_value();
         //mdelay(1);
         value();
 
 
        }           
    }       
}



work fine with the 8051 controller. Adjust the timer to create delay for particular controller
Thanks
Ashwin Guru.
 
Last edited by a moderator:

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top