View previous topic :: View next topic |
Author |
Message |
sahu77
Joined: 08 Sep 2011 Posts: 202
|
ir decoder + led drive |
Posted: Wed Sep 14, 2011 1:10 pm |
|
|
I want to make ir decoder which can on\off (relay). It is based on NEC & RC5. Anybody guide & help me ? I use pic 16f72 / 676. _________________ sahu |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9246 Location: Greensville,Ontario
|
|
Posted: Wed Sep 14, 2011 1:25 pm |
|
|
Make Google your friend !
Typing in some of your 'keywords' got me over 100,000 'hits', lots with complete source code, examples, etc. |
|
|
sahu77
Joined: 08 Sep 2011 Posts: 202
|
|
Posted: Wed Sep 14, 2011 1:51 pm |
|
|
temtronic wrote: | Make Google your friend !
Typing in some of your 'keywords' got me over 100,000 'hits', lots with complete source code,examples, etc. |
I am new in CCS. So want need help. _________________ sahu |
|
|
sahu77
Joined: 08 Sep 2011 Posts: 202
|
|
Posted: Sun Sep 18, 2011 2:26 am |
|
|
not reply yet...
any body .pl help me _________________ sahu |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Sun Sep 18, 2011 5:31 am |
|
|
We can only help you if we know what your problem is.
We are not going to do the whole project for you, but if you have specific problems we can help you to solve them.
Have you managed to create a project with a blinking LED? This is the most basic type of project but proves you have a working set of compiler and hardware. From this you can expand.
This type of project has been many times before, so next best step is to use Google as suggested. Find at least three different projects using the PIC and a remote control. Study these projects to understand the different solutions and learn which approach suits your project the best.
Continue in small steps, for example first build and test the driver for one relay, then for multiple relays and then add the RC-receiver.
If you run into problems, then tell us what you have tried and what fails. We might have a solution for your problem, but only when we see you have tried to put in some effort yourself first. |
|
|
sahu77
Joined: 08 Sep 2011 Posts: 202
|
|
Posted: Sun Sep 18, 2011 11:42 am |
|
|
I found one code.
which are as...
Code: |
/* --- RC5 driver configuration --- */
#define RC5_DATA_PIN PIN_B1 /* IR sensor (SFH5110-36) connected to RB1 */
#define RC5_TICKS_PER_MS (1000/26) /* timer increments every 25.6us, */
/* i.e. around 39 ticks per millisecond */
#define RC5_GetTimer() get_timer0() /* timer0 shall be used for RC5 decoding */
#include "rc5.h" /* RC5 driver include */
/* --- macros to switch on/off LED --- */
#define Led_On() output_high(PIN_A0)
#define Led_Off() output_low(PIN_A0)
/*****************************************************************************/
/* Interrupt_RB */
/* */
/* Port B change interrupt service routine. */
/* Used to decode RC5 IR signal. */
/*****************************************************************************/
#INT_RB
void Interrupt_RB(void)
{
Led_On();
RC5_InterruptHandler();
clear_interrupt(INT_RB);
Led_Off();
}
/*****************************************************************************/
/* main */
/* */
/* Configures timer0 as time base for RC5 decoding and enables port B */
/* interrupt on change. */
/* Main loop checks if a RC5 code has been received and writes the code */
/* to the RS232 interface. */
/*****************************************************************************/
/* NOTE: Currently it only works if PIC is reset after programming? */
void main()
{
uint16 rc5code;
/* FOSC/4 is timer source */
/* FOSC = 20MHz => 5MHz, i.e. timer increment every t = 1/(FOSC/4) = 200ns */
/* with prescaler of 128 timer will increment every 25.6us */
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_128);
/* configure port B interrupt on change */
set_tris_b(0xFF); /* all pins on port B are input */
input_b(); /* read port B to clear mismatch condition */
clear_interrupt(INT_RB); /* clear port B interrupt flag */
enable_interrupts(INT_RB1); /* enable RB1 interrupt on change */
/* global interrupt enable */
enable_interrupts(GLOBAL);
printf("**** RC5 Demo started! **** \n\r");
while(TRUE)
{
/* check if new data is available */
if (RC5_CodeReady())
{
/* get code */
rc5code = RC5_GetCode();
printf("RC5 Code=0x%04LX DevAddr=0x%02X Toggle=%d Cmd=0x%02X\n\r",
rc5code,
RC5_GetDeviceAddr(rc5code),
RC5_GetToggleBit(rc5code),
RC5_GetCmd(rc5code));
}
/* this function increments the RC5 timeout timer */
/* NOTE: Decoding will also work without calling this function, but */
/* it could happen that RC5 codes are sometimes not getting */
/* recognized because of decoding state machine stucks due */
/* to erroneous RC5 signal. */
RC5_TimeoutIncrement();
}
}
| but cont understand how can toggle led\realy as receive cmd
hope help now... _________________ sahu |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Sun Sep 18, 2011 3:05 pm |
|
|
Quote: | but cont understand how can toggle led\realy as receive cmd | I guess you refer to the following code? Code: | #INT_RB
void Interrupt_RB(void)
{
Led_On();
RC5_InterruptHandler();
clear_interrupt(INT_RB);
Led_Off();
} |
Here the LED is switched on and off when a remote signal is received, just to show you that the PIC is receiving something. The real work is performed in the function RC5_InterruptHandler(), my guess is this function is in the include file rc5.h. |
|
|
sahu77
Joined: 08 Sep 2011 Posts: 202
|
|
Posted: Mon Sep 19, 2011 9:28 am |
|
|
ckielstra wrote: | Quote: | but cont understand how can toggle led\realy as receive cmd | I guess you refer to the following code? Code: | #INT_RB
void Interrupt_RB(void)
{
Led_On();
RC5_InterruptHandler();
clear_interrupt(INT_RB);
Led_Off();
} |
Here the LED is switched on and off when a remote signal is received, just to show you that the PIC is receiving something. The real work is performed in the function RC5_InterruptHandler(), my guess is this function is in the include file rc5.h. |
i want to like this
Code: | switch(command)
{
case RC5_NEMERIC_KEY_1:
PORTC = ~output(RL1);
break;
case RC5_NUMERIC_KEY_2:
PORTC = ~output(RL2);
break;
case RC5_NEMERIC_KEY_3:
PORTC = ~output(RL3);
break;
case RC5_NUMERIC_KEY_4:
PORTC = ~output(RL4);
break;
case RC5_NEMERIC_KEY_5:
PORTC = ~output(RL5);
break;
case RC5_NUMERIC_KEY_6:
PORTC = ~output(RL6);
break;
case RC5_NEMERIC_KEY_7:
PORTA = ~output(RL7);
break;
case RC5_NUMERIC_KEY_8:
PORTA = ~output(RL8);
break;
|
_________________ sahu |
|
|
|