CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug Reports on this forum. Send them to support@ccsinfo.com

Decoder for B&O remote control.

 
Post new topic   Reply to topic    CCS Forum Index -> Code Library
View previous topic :: View next topic  
Author Message
John_Rio



Joined: 22 Jan 2005
Posts: 12
Location: Rio de Janeiro, Brazil

View user's profile Send private message MSN Messenger

Decoder for B&O remote control.
PostPosted: Fri Feb 25, 2005 2:10 pm     Reply with quote

I was looking a long time for something like this, but ended up doing it by myself.
I anybody wants it, here it is.

The input B0 is connected to a infrared link receiver (B&O product) that gives 5 V pulses.

I did not try it with a standard infrared receiver.

The code is simple and can be adjusted to your own needs.

When a key is pressed on the remote, the PIC sends a string containing the 16 byte code. (send as A,B,C) since each "bit" has 3 states.

John (Still in Denmark)

Code:

#include <18F252.h>
#device ICD=TRUE
#device adc=8
#use delay(clock=20000000)
#fuses NOWDT,WDT128,EC_IO, NOPROTECT, NOOSCSEN, BROWNOUT, BORV20, NOPUT, STVREN, NODEBUG, LVP, NOWRT, NOWRTD, NOWRTB, NOWRTC, NOCPD, NOCPB, NOEBTR, NOEBTRB
#use rs232(baud=19200,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,enable=PIN_C5)

INT8  Counter=0;
INT16 time[25];
INT1  Received=0;
INT1  fejl;
INT8  Code[17];

#int_EXT

EXT_isr()
{
 time[counter]=get_timer0();
 set_timer0(0);
 Counter++;
 IF (counter==22)Received=TRUE;
}

#int_TIMER0
TIMER0_isr()
{
counter=0;
}

void Check_Start_Stop()
{
fejl =0;
IF (time[1]<5250 || time[1]>10500) {fejl=1;Break;}
IF (time[2]<5250 || time[2]>10500) {fejl=1;Break;}
IF (time[3]<33500 || time[3]>42000) {fejl=1;Break;}
IF (time[4]<5250 || time[4]>10500) {fejl=1;Break;}
IF (time[21]<26000 || time[21]>33500) {fejl=1;Break;}
}
void Check_Code()
{
INT8 i;
For (i=0;i<=15;i++)
 {
  IF (time[i+5]<5250) fejl=1;
  IF (time[i+5]>5250) code[i]='A';
  IF (time[i+5]>10500) code[i]='B';
  IF (time[i+5]>18250) code[i]='C';
  IF (time[i+5]>26000) fejl=1;

 }
}
void read_remote()
{
Check_start_stop();
IF (!fejl)
 check_code();
 IF (!fejl)
 {
 code[16]=0x00;
 Output_High(PIN_C5);
 Delay_us(500);
 printf(code);
 printf("\r");
 }
received=0;
}

void main()
{

   setup_adc_ports(NO_ANALOGS);
   setup_adc(ADC_OFF);
   setup_spi(FALSE);
   setup_wdt(WDT_OFF);
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_2);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
   enable_interrupts(INT_EXT);
   enable_interrupts(GLOBAL);
   enable_interrupts(INT_TIMER0);
   DO
   {
   IF (received) read_remote();
   }
   WHILE (true);

}


Last edited by John_Rio on Tue Mar 01, 2005 1:53 pm; edited 1 time in total
John_Rio



Joined: 22 Jan 2005
Posts: 12
Location: Rio de Janeiro, Brazil

View user's profile Send private message MSN Messenger

UPS. A small code mistake.
PostPosted: Fri Feb 25, 2005 2:42 pm     Reply with quote

The code in Check_Start _Stop is wrong.
It has to be:
Code:

IF (time[1]<5250 || time[1]>10500) {fejl=1;Break;}
IF (time[2]<5250 || time[2]>10500) {fejl=1;Break;}
IF (time[3]<33500 || time[3]>42000) {fejl=1;Break;}
IF (time[4]<5250 || time[4]>10500) {fejl=1;Break;}
IF (time[21]<26000 || time[21]>33500) {fejl=1;Break;}


Sorry about that.

John


Last edited by John_Rio on Wed Mar 02, 2005 5:27 am; edited 2 times in total
treitmey



Joined: 23 Jan 2004
Posts: 1094
Location: Appleton,WI USA

View user's profile Send private message

PostPosted: Mon Feb 28, 2005 10:00 am     Reply with quote

..

Last edited by treitmey on Wed Mar 02, 2005 12:45 pm; edited 3 times in total
John_Rio



Joined: 22 Jan 2005
Posts: 12
Location: Rio de Janeiro, Brazil

View user's profile Send private message MSN Messenger

Done the edit.
PostPosted: Tue Mar 01, 2005 1:56 pm     Reply with quote

Hi,
Sorry about the mistake.
I didnt know posts could be edited after posting.
I can though not find a way to delete my correction post !!


John
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

Re: Done the edit.
PostPosted: Tue Mar 01, 2005 2:35 pm     Reply with quote

John_Rio wrote:
Hi,
Sorry about the mistake.
I didnt know posts could be edited after posting.
I can though not find a way to delete my correction post !!


John


Just edit it and delete the text.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> Code Library All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group