• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Question about identifying signals from RC5 remote with pic

Status
Not open for further replies.

sikhjumn

New Member
I cannot identify signals from the RC5 remote with PIC18f4520 to control a cd-player. For cd-player, different data of buttons should be recognized. Below are some of my c program code.
----------------------------------------------------
void GetPulse(void)
{
int counter=0;
Delay100TCYx(143); // to delay ~1.778ms,using 32MHZ
while(PORTBbits.RB3==1);
putrsXLCD("SENSE"); //prove that it sense the falling edge

while(counter<14) //14bits of RC5
{
if(PORTBbits.RB3==0)
counter++;
Delay100TCYx(143);
}
if (counter>8)
putrsXLCD("SENSE for 9 zero");
}
--------------------------------------------
I get a problem that when a signal is sent from the remote, the counter will add to 14 everytime. Is there any wrongs in my program.
 

sikhjumn

New Member
HI~be80be

I have read this page for several time. But I don't know what wrong with my method....:(Can you specified it??thanks...
 

be80be

Well-Known Member
I never done any RC5 but it looks like to me your code is counting the carrier and that will hit 14 real fast. You need to get the start bit first which is 889uS low followed by 889uS high and the catch the next 13 you need to catch the low to high for 1 and high to low for a 0 which is not going to happen with a 1.778mS delay. Here you some to code to look at it's in C http://www.edaboard.com/ftopic197570.html
 
Last edited:

sikhjumn

New Member
Now I can recognize different buttons refer to AtomSoft's program.
http://www.electro-tech-online.com/threads/sony-infared-code-in-c18.93570/

But...the signal is unstable.,or is there any wrong in my program??

--------------------------

void GetPulse(void)
{

char x;
unsigned char count=0;
unsigned char lTime=0;

StartLook:

while(irPin); //wait for it to be low
lTime = 0; //reset the counter

while(irPin == 0){ //while the pin is low which is our pulse count
lTime++; //increment every 200uS until pin is high
Delay100TCYx(16); //200uS delay
}

if(lTime <= 4) //Start too short
goto StartLook; //Restart
if(lTime >= 6) //Start too long
goto StartLook; //Restart

putrsXLCD("SENSE");

lTime = 0;
for(x=0;x<13;x++){ //repeat 13 times for command

while(irPin); //wait for it to be low
lTime = 0; //reset the counter

while(irPin == 0){ //while the pin is low which is our pulse count
lTime++; //increment every 100uS until pin is high
Delay100TCYx(8); //100uS delay
}
if(lTime >= 6) {
count++;
}

}
--------------------------------------------

I wanna use 'count' to recognizethe data.However, the numbers of count are unstable that will change. How can I fix it??
 

Brian Hoskins

New Member
I'm not certain how you're going to collect the data with that code - it seems to me that the variable 'count' would merely count the number of low pulses which would indeed vary between button presses.

I wrote some code not so long ago that collects the address and command information from the RC5 data stream and stores it in "Command" and "Address" respectively. After that it applies some ascii correction to the data and splits the resulting ascii number into its hundreds, tens and unit components. It then prints the data out onto an LCD display.

Some of this code may be useful to you. You may not want all of it, or you may just want to use it as a basis for your own ideas. In any case I have attached it in this post for you to look at if you want. I have also attached some pictures that show the system working in practice.

The Toggle bit information is a bit buggy - sometimes it works and sometimes it doesn't. I haven't got around to figuring out what is wrong with it yet. But the address and command data is always accurate, so in that respect it is reliable. In your application, you would want to act upon the data rather than display it of course.

Hope it helps.

Brian
 

Attachments

AtomSoft

Well-Known Member
Thanks for linking to my post. I havent had much time to read this but if ya need help just tell me and ill try to help.
 
Last edited:
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top