|
|
View previous topic :: View next topic |
Author |
Message |
John_Rio
Joined: 22 Jan 2005 Posts: 12 Location: Rio de Janeiro, Brazil
|
Decoder for B&O remote control. |
Posted: Fri Feb 25, 2005 2:10 pm |
|
|
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
|
UPS. A small code mistake. |
Posted: Fri Feb 25, 2005 2:42 pm |
|
|
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
|
|
Posted: Mon Feb 28, 2005 10:00 am |
|
|
..
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
|
Done the edit. |
Posted: Tue Mar 01, 2005 1:56 pm |
|
|
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
|
Re: Done the edit. |
Posted: Tue Mar 01, 2005 2:35 pm |
|
|
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. |
|
|
|
|
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
|