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.

interfacing of atmega16 with tsop1736 using rc5 protocol

Status
Not open for further replies.

vishu489

Advanced Member level 4
Joined
Aug 28, 2011
Messages
116
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,298
Activity points
2,120
hello friend, i want to interface atmega16 with tsop 1736 using rc5 protocol to control appliances . if anyone having source code then please give me. i already know the rc5 protocol but i'm having problem to decode it. please help me
 

Why dont you try it out with examples available in the net instead of asking for code
 

hi friends
below i'm providing my code for rc5 decoding but when i tested it everytime led connected to pc1 glows.i also check tsop ,it gives voltage of 4.86v when there is no ir signal from philips ir remote and when i pressed any button from remote its voltage drops to 4.26v and only PC1 led glows. i don't know where i'm going wrong? please help me

in my coding i'm waiting for first low voltage then i'm providing delay of 4.752ms so that code flow jumps to half of first half of first address bit and then i'm providing delay of 1.728ms to read next 11 bits


#include<avr/io.h>
#include<util/delay.h>
#include<avr/interrupt.h>


#define IR PB0

void init_timer0(void);
unsigned int decode_rc5(void);

volatile uint8_t timer_flag=0;
unsigned int temp=0;
unsigned int rc5_data=0;
unsigned int command=0;
unsigned char result=0;

//defining macros
#define TIMER_STOP 0
#define WAIT_FOR_TIMER() {while(timer_flag==0); timer_flag=0;}


void init_timer0(void)
{
cli();
TCCR0|=(1<<WGM01)|(1<<CS02)|(1<<CS00);// prescaler clk/1024 ,ctc mode,oc0 disconnect
TIMSK|=(1<<OCIE0); // compare match interrupt enable
OCR0=74; // generating delay of 4.752ms
TCNT0=0;
sei();
}

ISR(TIMER0_COMP_vect)
{
timer_flag=1; // setting flag
OCR0=27; // modifying compare value for the delay of 1.728ms
}

unsigned int decode_rc5(void)
{
init_timer0();
WAIT_FOR_TIMER(); // waiting for the delay of 4.752 ms
for(int x=0;x<11;x++)
{
if(PINB&(1<<IR))
{
temp=temp|0X01;
}
rc5_data=temp<<1;
WAIT_FOR_TIMER();
}
TCCR0=TIMER_STOP; // timer0 stop
command=(rc5_data&0X003F); // extracting command
return command;
}

int main(void)
{
DDRB&=~(1<<IR); // declaring IR pin as i/p
PORTB|=(1<<IR); // making IR pin high
DDRC=0XFF; // portc as o/p port
while(1)
{
while(PINB&(1<<IR)) // waiting for ir signal
{
}
result=decode_rc5(); // decoding ir data
PORTC=result; // applying command to PORTC
_delay_us(1);
}
return 0;
}
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top