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.

Can anybody help me to make

Status
Not open for further replies.

Praful

Member level 3
Joined
Jul 3, 2005
Messages
54
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,665
Can anybody help me to make the program of Remote as well as push button operated LED on /off controller using “C” language and AT89c51 and Any RC-5 coded Remote controller. Cause I’m a beginner in “uC” projects now I’m learn in 2nd year.
1) I don’t know how to access buttons with debounce time delay.
2) How to assign a remote code to certain feature.
Please help me ………………
Thanking You in advance……
Prafulk25@rediffmail.com
:|
 

techie

Advanced Member level 3
Joined
Feb 5, 2002
Messages
839
Helped
58
Reputation
116
Reaction score
9
Trophy points
1,298
Location
Pakistan
Activity points
7,801
Do it in two steps. The switches and LED should be simple. Leave the remote control part to the second phase. It is not very simple for a beginner. Once you get the switches and LEDs to work, then try on RC. There are many websites that describe it.
 

Praful

Member level 3
Joined
Jul 3, 2005
Messages
54
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,665
First of all Thanx to Techie and Seadolphine2000, to show your interest to help me.
Ok, now the details are I just want to toggle a led by using a uC like AT89c51
with a touch button and also with a remote but acording to techie firstly I want to on/off a LED's by using a key pad as shown in last diagram which I sent before or as shown bellow.
Please send me a program in "C" language can cause I can study it .
Thanking you all.......
prafulk25@rediffmail.com
 

techie

Advanced Member level 3
Joined
Feb 5, 2002
Messages
839
Helped
58
Reputation
116
Reaction score
9
Trophy points
1,298
Location
Pakistan
Activity points
7,801
I dont have a readymade program for you. But I am sure if you do some study yourself, you should be able to write one easily.
 

ikarakaya

Junior Member level 3
Joined
Nov 2, 2001
Messages
26
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
139
which code do you use for IR? I can advice you RC5(standart coding of Sony remote). It is very simple. If you give details i can send you a code in C lang. and PICBASIC
 

Praful

Member level 3
Joined
Jul 3, 2005
Messages
54
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,665
Dear ikarakaya,
the code of RC-5 remote which I,ve are 38 DE, 22 DE,22 CE. I am very thankful if u send me such a program in "C" language for AT89c51
Thanking YOU again...........:|
 

hjamleh

Junior Member level 2
Joined
Oct 6, 2005
Messages
24
Helped
3
Reputation
6
Reaction score
1
Trophy points
1,283
Location
Taiwan
Activity points
1,597
It is easy man. I want to show you the steps which I followed to build an IR reciever for one of my projects

1. It is easy to build the Reciever first, Transmitter is not important as reciever, because you can buy a remote contol ready made with cheap price compatible with the IR-code that you want to use... "infrared_protocols_samples.pdf" file will show you samples of some protocoles.

2. For recieving matters you have to buy a Reciver module, it is 3 legs IC, but becareful, you must buy a reciever which is compatible with the frequency of the transmitter which will transmit the modulated code with specific frequency. You can know about it from allready built circuit on this link:

3.Before programming using C, you have to know about some prepherals in the microcontroller, especially; external interrupt and internl Timer TMR0.

4. Choosing good uC, I suggest to use PIC16F84, because it is small 18 pins, cheap, easy to use, high capabilities, and available.

5. Use good C lang., I suggest CCS, from www.ccsinfo.com, which is just for PIC uCs, but before you can decode the coming signal to your uC you have to set up the external interrupt which is attached with the receiver IC and setting up the TMR0 which you have to use to read the time of coming mark or space.

6. You can visit www.microchip.com to know more about IR devices.

7. Good luck:D
 

Praful

Member level 3
Joined
Jul 3, 2005
Messages
54
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,665
I've made a project in which a relay can be operated through a IR remote
but one problem occurred is if we press and hold remote button a relay can toggles on to off to on to off to on to off
I want must function same as TV remote function off mean off and on means on it cant toggle
even a key pressed and hold it. It only operates again when we release the button and press it again to on.
So Please can any body tell me the solution for it I used a delay but also it toggles after a delayed time
The hardware, which I used, is At89c52 uC. and Keil compiler and a program is in "C" language.
Example shown:---
case 0xAC: onf1var--;
if(onf1var<=0)
{
ONF1ON=~ONF1ON;
putchar(digit[ONF1ON]); ONF1();
for(i=0;i<5500;i++);
}
break;

void ONF1(void)
{
if(ONF1ON)
{
ONF1LED=0;
}
if(!ONF1ON)
{
ONF1LED=1;
}
for(i=0;i<5500;i++);
:|:!:
 

Jack// ani

Advanced Member level 3
Joined
Dec 2, 2004
Messages
759
Helped
107
Reputation
222
Reaction score
58
Trophy points
1,308
Activity points
5,006
I got this code from some where.....a RC5 decoder written for AVR. Hope may be useful to you
Code:
/*
   rc5dec.c 0.2.0 - Interrupt driven RC5 decoder for Atmel AVR µC's.
   Website: **broken link removed**
   Copyright (C) 2003  Mark Haemmerling <rc5@markh.de>

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

   Preconfigured for INT1 (PD3) and Timer/Counter0.
*/

#include <inttypes.h>
#include <avr/signal.h>
#include <avr/interrupt.h>
#include <avr/io.h>

// set your clock speed here
#define XTAL 1000000

// you may have to experiment a little with this
// in case of heavy disturbance, try values around 60
// try to use odd values (for symmetrical level detection)
#define RC5RESAMPLE 11

// this autoconfigures all timer values:
#if XTAL < 285000
# define PRESCALEDIV 1
# define TIMERCR (1<<CS00)
#elif XTAL < 2300000
# define PRESCALEDIV 8
# define TIMERCR (1<<CS01)
#elif XTAL < 18000000
# define PRESCALEDIV 64
# define TIMERCR (1<<CS01) | (1<<CS00)
#else
# define PRESCALEDIV 256
# define TIMERCR (1<<CS02)
#endif
#define RC5TIMERFIRST 0x100-((uint8_t) (XTAL/PRESCALEDIV*0.0008890))
#define RC5TIMERSECOND 0x100-((uint8_t) (XTAL/PRESCALEDIV*0.0004445))
#define RC5TIMERCANCEL 0x100-((uint8_t) (XTAL/PRESCALEDIV*0.0008890))

volatile uint16_t rc5_code = 0;
volatile uint8_t rc5_first_half;

SIGNAL (SIG_INTERRUPT1) {
/*	external interrupt handler
	edge from IR receiver detected.
	this is assumed to be the middle of a bit.
*/
	uint8_t i;
	
	// resample to filter out spikes
	if (MCUCR & (1<<ISC10)) {
		// we were waiting for a rising edge, so cancel if we sample low
		for (i = RC5RESAMPLE; i; i--) if (!(PIND & (1<<PIND3))) return;
	} else {
		// vice versa...
		for (i = RC5RESAMPLE; i; i--) if ((PIND & (1<<PIND3))) return;
	}

	TCNT0 = RC5TIMERSECOND; // preset timer to sample (ovf int) at second half (3/4 bit time)
	rc5_first_half = 0; // next sample will be in the second half
        sbi(TIMSK, TOIE0); // enable timer ovf int
	cbi(GICR, INT1); // disable ext int (this handler)
}

SIGNAL (SIG_OVERFLOW0) {
/*	timer overflow handler
	sample the present level of the interrupt line.
*/	
	static uint16_t rc5_shift, rc5_temp;
	static uint8_t rc5_bit = 0, level, first_level = 1;
	uint8_t i = 0, temp;

	// resample to filter out spikes
	for (temp = RC5RESAMPLE; temp; temp--) if (PIND & (1<<PIND3)) i++;
	level = (i > ((uint8_t) (RC5RESAMPLE/2)));

	if (rc5_first_half == 2) {
		// this is a timeout, cancel operation
		goto rc5_cancel;
	} else if (rc5_first_half == 1) {
		// this sample is taken in the first half of the bit (1/4 bit time)
		first_level = level; // save current level
		if (level) cbi(MCUCR, ISC10); // currently at high level, wait for falling edge
		else sbi(MCUCR, ISC10); // currently at low level, wait for rising edge
		rc5_first_half = 2; // special code, means: next ovf int is a timeout
		sbi(GICR, INT1); // much better: wait for edge ;)
		TCNT0 = RC5TIMERCANCEL; // at timer ovf (in around 1/2 bit time) we should get a timeout
	} else {
		// this sample is taken in the second half of the bit (3/4 bit time)
		TCNT0 = RC5TIMERFIRST; // next sample at first half (1/4 bit time) of next bit
		rc5_first_half = 1;
		if (first_level != level) {
			// levels differ -> valid manchester encoded bit detected
			if (!rc5_bit) {
				// this is the first bit, reset values
				rc5_temp = 0;
				rc5_shift = 0x8000;
			}
			if (!level) rc5_temp |= rc5_shift; // low level (low-active) so store a '1'
			else if (rc5_bit < 2) goto rc5_cancel; // high level ('0' bit) as startbit -> error
			if (++rc5_bit == 14) {
				// reception complete, stop operation
				rc5_code = rc5_temp;
				goto rc5_cancel;
			}
			if (rc5_shift == 0x0100) rc5_shift = 0x0020;
			else rc5_shift >>= 1;
		} else {
			// error in manchester stream -> cancel operation
			goto rc5_cancel;
		}
	}
	return;

rc5_cancel:
	cbi(MCUCR, ISC10); // falling edge
	sbi(GICR, INT1); // ext. int. enabled
	GIFR = (1<<INTF1); // clear an eventually set ext. int. flag
	cbi(TIMSK, TOIE0); // disable timer int.
	first_level = 1; // as the next ext. int. appears at the falling edge, assume the first level as high
	rc5_bit = 0;
}


void rc5_init(void) {
/*	init for ext. int. and timer.
	call this once to activate the rc5 decoder.
*/
	TCCR0 = TIMERCR;
	cbi(DDRD, PD3); // pin is input
	cbi(PORTD, PD3); // pullup disabled (receiver has defined output)
	cbi(TIMSK, TOIE0); // timer ovf disabled. gets enabled by ext. int.
	sbi(MCUCR, ISC11); // ext. int. activated by falling edge
	cbi(MCUCR, ISC10);
	GIFR = (1<<INTF1); // clear ext. int. flag
	sbi(GICR, INT1); // enable ext. int.
}

int main(void) {
	// example main program:
	rc5_init(); // activate RC5 detection
	
	DDRB = 0xff; // PORTB is output
	PORTB = 0x00; // all pins low
	
	// start main loop
	for (;;) {
		if (rc5_code) {
			// ...do some action here...
			PORTB = (uint8_t) rc5_code; // output low-byte at PORTB
			rc5_code = 0; // clear code
		}
	}
}

// EOF
 

M!k

Advanced Member level 2
Joined
Apr 22, 2002
Messages
682
Helped
109
Reputation
218
Reaction score
35
Trophy points
1,308
Activity points
4,819
Praful said:
I've made a project in which a relay can be operated through a IR remote but one problem occurred is if we press and hold remote button a relay can toggles on to off to on to off to on to off ...
Take a look at the RC5 protocol. There's a toggle bit which toggles each time when a key is newly pressed. So you can easily determine if the key was released ....


Mik
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top