Sari la conținut
ELFORUM - Forumul electronistilor

RECUNOASTEREA UNUI BUTON DE LA TELECOMNDA :)


klaudyux

Postări Recomandate

Salut ! Vreau ca sa aprind si sa sting lumina in camera cu telecomanda de la tv; am cateva butoane in plus; am facut o schema cu un receptor ir dar reactioneaza la orice buton de la telecomanda. Cum pot face sa "decodez" doar anumite butoane ale telecomenzii ? Se poate ? cum... ?

Link spre comentariu
  • Răspunsuri 33
  • Creat
  • Ultimul Răspuns

Top autori în acest subiect

  • klaudyux

    8

  • XAN77

    4

  • tuffguy

    3

  • vlad_2770

    3

Top autori în acest subiect

O telecomanda ca cea de tv pentru fiecare tasta emite un cod destul de lung (informativ 10-30 de octeti) care banuiesc ca (,) contine pe linga numarul comenzii o gramada de octeti de ecc (detectie si corectie de erori)Ca sa afli ce tasta a fost apasat trebuie, evident, sa-l decodeziCa sa vezi cum arata poti folosi de exemplu un irda-to-serial legat la pc si pe nenea hyperterminal, atita ca la vremea cind am incercat mergea la distanta destul de mica, plus ca nu stiam sa decodez tot cirnatul si la cea mai mica eroare nu recunostea comanda. Oricum a fost un mod interesant de a controla un winamp :)

Link spre comentariu

O telecomanda ca cea de tv pentru fiecare tasta emite un cod destul de lung (informativ 10-30 de octeti) care banuiesc ca (,) contine pe linga numarul comenzii o gramada de octeti de ecc (detectie si corectie de erori)Ca sa afli ce tasta a fost apasat trebuie, evident, sa-l decodeziCa sa vezi cum arata poti folosi de exemplu un irda-to-serial legat la pc si pe nenea hyperterminal, atita ca la vremea cind am incercat mergea la distanta destul de mica, plus ca nu stiam sa decodez tot cirnatul si la cea mai mica eroare nu recunostea comanda. Oricum a fost un mod interesant de a controla un winamp :)

http://www.adelaida.ro/product_info.php ... cts_id=515 Cred cu siguranta :P ca acest montaj este ce am nevoie. Poate cineva sa imi dea schema si softul pt microcontroler ??? :prayer:
Link spre comentariu

Da, eu!Dar nu pt. PIC, cum e cel de la Adelaida, ci pt. AVR.Si merge numai cu telecomenzi RC5, de altfel si cel de la Adelaida la fel.Sper sa fac cat mai curand si eu un astfel de kit.Intentionez ca, in viitorul apropiat, sa fac niste kituri pe care sa le pun in vanzare, dar cred ca mai dureaza vreo luna-doua.

Link spre comentariu

Da, eu!

Dar nu pt. PIC, cum e cel de la Adelaida, ci pt. AVR.

Si merge numai cu telecomenzi RC5, de altfel si cel de la Adelaida la fel.

Sper sa fac cat mai curand si eu un astfel de kit.

Intentionez ca, in viitorul apropiat, sa fac niste kituri pe care sa le pun in vanzare, dar cred ca mai dureaza vreo luna-doua.

Daca te lasa inima trimite-mi si mie schema si softul la [email protected]

 

Vreau sa mai testez si schema asta, nu e chiar ce caut eu dar merge; problema e ca nu am softul in format .hex, ma poate ajuta cineva ???

 

http://www.geocities.com/vsurducan/elec ... serial.htm

Link spre comentariu
Vizitator alex

Hai ca iti dau eu cod de PIC :d

Se compileaza cu HT-SOFT PICC.

 

main.c

/*(c) 2005 - 2006 Alexandru Mirea PENTRU UTILIZARE DOAR IN SCOPURI NECOMERCIALEMerge doar cu telecomenzi RC5Modulul de telecomanda este pe 38kHz si este conectat la RB0.Scheme si detalii la http://www.xs4all.nl/~sbp/knowledge/ir/ir.htmPENTRU UTILIZARE DOAR IN SCOPURI NECOMERCIALE*/#define PIC16F877A#include <pic.h>#include <stdlib.h>#include <stdio.h>#include "setup.h"#include "delay.h"__CONFIG(WDTDIS & PWRTEN & HS & UNPROTECT & DEBUGDIS & BORDIS & LVPDIS); #define PORTBIT(adr, bit) ((unsigned)(&adr)*8+(bit))static bit IR @ PORTBIT(PORTB, 0);static bit IR_TRIS @ PORTBIT(TRISB, 0);unsigned char counter, adresa, comanda;unsigned bank1 char rc5[12];bit IRflag;static void interrupt isr(void){	if ((INTF==1)&&(IRflag==0))	{		adresa=0x00;		comanda=0x00;			counter=1;		DelayBigUs(4750);		do		{			rc5[counter]=IR;			DelayBigUs(1700);			counter++;		}		while (counter<12);		for(counter=5;counter>=1;counter--)		{			if (rc5[counter]==0)				{adresa = (adresa >> 1) | (0<<7);}			else				{adresa = (adresa >> 1) | (1<<7);}		}		adresa = (adresa >> 1) | (0<<7);		adresa = (adresa >> 1) | (0<<7);		adresa = (adresa >> 1) | (0<<7);		for(counter=11;counter>=6;counter--)		{			if (rc5[counter]==0)				{comanda = (comanda >> 1) | (0<<7);}			else				{comanda = (comanda >> 1) | (1<<7);}		}		comanda = (comanda >> 1) | (0<<7);		comanda = (comanda >> 1) | (0<<7);		if (adresa==0)			IRflag=1;		INTF=0;	};	INTF=0;}void comenzi(void){	if (IRflag==1)	{			if (adresa==0x00)		{			lumina(1);					if (comanda==12) //SBY			{				//fa ceva			}		}	IRflag=0;	}}void main(void){	//Configurare porturi	IR_TRIS=1;	//configurare intrerupere	INTEDG=0;	INTE=1;	TMR0IE=0;	GIE=1;	IRflag=0;	for(;;)	{		comenzi();		//aici poti sa mai faci si altceva	}}

setup.h

/*Setup Header*///Configuratie uC#define PIC_CLK 	20000000//Definire telecomanda#define AV				0x00;#define VOLp			0x10;#define VOLm			0x11;#define CHp				0x20;#define CHm				0x21;#define PWR				0x0C;//Moduri ventilator#define FAN_AUTO		0x00;#define FAN_ON			0x01;

delay.h

/*Delay header file (c) Shane Tolmie shane [ at ] keyghost.com*/#include "setup.h"#ifndef __DELAY_H#define __DELAY_Hextern unsigned char delayus_variable;#if (PIC_CLK == 4000000)#define dly125n please remove; for 32Mhz+ only#define dly250n please remove; for 16Mhz+ only#define dly500n please remove; for 8Mhz+ only#define dly1u asm("nop")#define dly2u dly1u;dly1u#elif (PIC_CLK == 8000000)#define dly125n please remove; for 32Mhz+ only#define dly250n please remove; for 16Mhz+ only#define dly500n asm("nop")#define dly1u dly500n;dly500n#define dly2u dly1u;dly1u#elif ( (PIC_CLK == 16000000) || (PIC_CLK == 16257000) )#define dly125n please remove; for 32Mhz+ only#define dly250n asm("nop")#define dly500n dly250n;dly250n#define dly1u dly500n;dly500n#define dly2u dly1u;dly1u#elif (PIC_CLK == 20000000)#define dly200n asm("nop")#define dly400n dly250n;dly250n#define dly2u dly400n;dly400n;dly400n;dly400n;dly400n#elif (PIC_CLK == 32000000)#define dly125n asm("nop")#define dly250n dly125n;dly125n#define dly500n dly250n;dly250n#define dly1u dly500n;dly500n#define dly2u dly1u;dly1u#else#error delay.h - please define pic_clk correctly#endif//*****//delay routine#if PIC_CLK == 4000000#define DelayDivisor 4#define WaitFor1Us asm("nop")#define Jumpback asm("goto $ - 2")#elif PIC_CLK == 6000000#define DelayDivisor 3#define WaitFor1Us asm("nop")#define Jumpback asm("goto $ - 2")#elif PIC_CLK == 8000000#define DelayDivisor 2#define WaitFor1Us asm("nop")#define Jumpback asm("goto $ - 2")#elif ( (PIC_CLK == 16000000) || (PIC_CLK==16257000) )#define DelayDivisor 1#define WaitFor1Us asm("nop")#define Jumpback asm("goto $ - 2")#elif PIC_CLK == 20000000#define DelayDivisor 1#define WaitFor1Us asm("nop"); asm("nop")#define Jumpback asm("goto $ - 3")#elif PIC_CLK == 32000000#define DelayDivisor 1#define WaitFor1Us asm("nop"); asm("nop"); asm("nop"); asm("nop"); asm("nop")#define Jumpback asm("goto $ - 6")#else#error delay.h - please define pic_clk correctly#endif#define DelayUs(x) { \			delayus_variable=(unsigned char)(x/DelayDivisor); \			WaitFor1Us; } \			asm("decfsz _delayus_variable,f"); \			Jumpback;#define LOOP_CYCLES_CHAR	9							//how many cycles per loop, optimizations on#define timeout_char_us(x)	(long)(((x)/LOOP_CYCLES_CHAR)*(PIC_CLK/1000000/4))#define LOOP_CYCLES_INT		16							//how many cycles per loop, optimizations on#define timeout_int_us(x)	(long)(((x)/LOOP_CYCLES_INT)*(PIC_CLK/1000000/4))//if lo byte is zero, faster initialization by 1 instrucion#define timeout_int_lobyte_zero_us(x)	(long)(((x)/LOOP_CYCLES_INT)*(PIC_CLK/4.0)&0xFF00)//function prototypesvoid DelayBigUs(unsigned int cnt);void DelayMs(unsigned char cnt);void DelayMs_interrupt(unsigned char cnt);void DelayBigMs(unsigned int cnt);void DelayS(unsigned char cnt);#endif

delay.c

/*Delay routines (c) Shane Tolmie shane [ at ] keyghost.com*/#ifndef __DELAY_C#define __DELAY_C#include <pic.h>unsigned char delayus_variable;#include	"delay.h"void DelayBigUs(unsigned int cnt){	unsigned char	i;	i = (unsigned char) (cnt >> 8);	while (i >= 1)	{		i--;		DelayUs(253);		CLRWDT();	}	DelayUs((unsigned char) (cnt & 0xFF));}void DelayMs(unsigned char cnt){	unsigned char	i;	do	{		i = 4;		do		{			DelayUs(250);			CLRWDT();		}		while (--i);	}	while (--cnt);}//this copy is for the interrupt functionvoid DelayMs_interrupt(unsigned char cnt){	unsigned char	i;	do	{		i = 4;		do		{			DelayUs(250);		}		while (--i);	}	while (--cnt);}void DelayBigMs(unsigned int cnt){	unsigned char	i;	do	{		i = 4;		do		{			DelayUs(250);			CLRWDT();		}		while (--i);	}	while (--cnt);}void DelayS(unsigned char cnt){	unsigned char i;	do	{		i = 4;		do		{			DelayMs(250);			CLRWDT();		}		while (--i);	}	while (--cnt);}#endif

always.h

/*Common header file (c) Shane Tolmie shane [ at ] keyghost.com*///warning about #if statements: if any of the arguments are spelled wrong or//unrecognised by the compiler, it will not generate a warning, but not include code#ifndef ALWAYS_H#define ALWAYS_H/*Turning bits on/off according to maskuse ~0 instead of 0xFF, etc, because this ensures machine independenceif int changes from 16-bit to 32-bitExample C:x=0b001;bits_on(x,0b100)  //now x=0b101*/#define bits_on(var,mask) var |= mask#define bits_off(var,mask) var &= ~0 ^ mask//defines#define INPUT 1		//port directions, ie: TRISA0=INPUT;#define OUTPUT 0#define TRUE 1#define FALSE 0#define	HIGH 1#define	LOW 0#define	hi 1#define	lo 0#define b asm("nop")		//convenient point for breakpoint (debugging)#define l while(1)			//loop for ever (debugging)//see AM576.  If interrupt occurs just when gie gets set to zero, it won't be cleared#define	gie_on		GIE=1#define gie_off		while(GIE==1) GIE=0/*Reading an 8-bit byte in a 16-bit intWith Hi-Tech C, this method is better than using pointers, as using pointers indifferent banks needs different #definesIt is just as efficient - the optimizer picks out the correctbyte.  Of course, >>7 requires 7 shifts.This method cannot be used to alter a hi/lo byte, this needs pointers (as below)Example C:unsigned int x;unsigned char y;x=0x1234;y=hibyte(x);  	  //now y=0x12 - works for variables in any bank 0 to 3y=lobyte(x);		//now y=0x34lobyte(x)=0xaa;   //will not work :( - use pointers*/#define hibyte(x) (unsigned char)(x>>8)#define lobyte(x) (unsigned char)(x & 0xFF)/*given variable of any type (char, uchar, int, uint, long) it modifies	the unsigned char residing at that memory location	for ints, byte1 is msb, byte0 is lsb (least significant byte)	for longs	byte3 is msb, byte0 is lsb	ie: sample C code	unsigned int myint=0x4321;	long mylong=0x87654321;	//for myint 	byte1(myint)=0x43; (msb) and byte0(myint)=0x21; (lsb)	//for mylong	byte3(mylong)=0x87; (msb), byte2(mylong)=0x65;								byte2(mylong)=0x43; and byte0(mylong)=0x21; (lsb)	note:	to avoid fixup overflow errors add bankX if the target variable				resides in banks 1, 2 or 3*/#define byte0(x)		(unsigned char)(*(((unsigned char *)&x)+0))#define byte1(x)		(unsigned char)(*(((unsigned char *)&x)+1))#define byte2(x)		(unsigned char)(*(((unsigned char *)&x)+2))#define byte3(x)		(unsigned char)(*(((unsigned char *)&x)+3))#define lobyte_atbank0   byte0   //another way of saying it#define hibyte_atbank0   byte1#define byte0_atbank1(x)		(unsigned char)(*(((bank1 unsigned char *)&x)+0))#define byte1_atbank1(x)		(unsigned char)(*(((bank1 unsigned char *)&x)+1))#define byte2_atbank1(x)		(unsigned char)(*(((bank1 unsigned char *)&x)+2))#define byte3_atbank1(x)		(unsigned char)(*(((bank1 unsigned char *)&x)+3))#define lobyte_atbank1   byte0_atbank1  //another way of saying it#define hibyte_atbank1   byte1_atbank1#define byte0_atbank2(x)		(unsigned char)(*(((bank2 unsigned char *)&x)+0))#define byte1_atbank2(x)		(unsigned char)(*(((bank2 unsigned char *)&x)+1))#define byte2_atbank2(x)		(unsigned char)(*(((bank2 unsigned char *)&x)+2))#define byte3_atbank2(x)		(unsigned char)(*(((bank2 unsigned char *)&x)+3))#define byte0_atbank3(x)		(unsigned char)(*(((bank3 unsigned char *)&x)+0))#define byte1_atbank3(x)		(unsigned char)(*(((bank3 unsigned char *)&x)+1))#define byte2_atbank3(x)		(unsigned char)(*(((bank3 unsigned char *)&x)+2))#define byte3_atbank3(x)		(unsigned char)(*(((bank3 unsigned char *)&x)+3))/*given variable of any type (char, uchar, int, uint, long) it modifies	the int residing at that memory location	ie: sample C code	unsigned char array[4];	unsigned int test;	uint_atbyteaddr(&array[0])=0x4321;			//now array[0->3]={0x21,0x43,0,0};	uint_atbyteaddr(&array[0+2])=0x8765;		//now array[0->3]={0x21,0x43,0x65,0x87};	test=uint_atbyteaddr(&array[0+2])				//now test=0x8765	note: do NOT use &(array[0]+1) to reference the int stored at array[1] as it will				reference the int after array[0] in pointer arithmetic.  This will				result with the int at array[2].				Instead use &array[0+1] to reference the int at uchar array[1]	note:	to avoid fixup overflow errors add bankX if the target variable				resides in banks 1, 2 or 3*/#define	uint_atbyteaddr(x)					(unsigned int)(*(((unsigned int *)x)))#define	uint_atbank1byteaddr(x)			(unsigned int)(*(((bank1 unsigned int *)x)))#define	uint_atbank2byteaddr(x)			(unsigned int)(*(((bank2 unsigned int *)x)))#define	uint_atbank3byteaddr(x)			(unsigned int)(*(((bank3 unsigned int *)x)))#define THE_BEER_IS_PLENTIFUL_AND_THE_PARTY_SWINGING TRUE/*NOTE: it is not recommended that unions are used to reference hi/lo bytes orbits of a variable.  Use >>8 or &FF or pointers instead, as above.  It makespassing variables to a function difficult, as the function must be defined toaccept variables of the same union.  Then, the function will no longer acceptnormally defined variables.these two structures allow access to 2 byte word, high and low bytes of variabledeclaration:	union wordtype x;usage:	x.word=0xABCD; x.byte.high=0xAB; x.byte.low=0xCD;				x.part.bit15=1; (msb), x.part.bit0=1; (lsb)declaration:	union chartype x;usage:	x.byte=0xAB;				x.part.bit7=1; (msb), x.part.bit0=1; (lsb)*/struct sixteen_bits{	unsigned char bit0 : 1;	unsigned char bit1 : 1;	unsigned char bit2 : 1;	unsigned char bit3 : 1;	unsigned char bit4 : 1;	unsigned char bit5 : 1;	unsigned char bit6 : 1;	unsigned char bit7 : 1;	unsigned char bit8 : 1;	unsigned char bit9 : 1;	unsigned char bit10 : 1;	unsigned char bit11 : 1;	unsigned char bit12 : 1;	unsigned char bit13 : 1;	unsigned char bit14 : 1;	unsigned char bit15 : 1;};struct eight_bits{	unsigned char bit0 : 1;	unsigned char bit1 : 1;	unsigned char bit2 : 1;	unsigned char bit3 : 1;	unsigned char bit4 : 1;	unsigned char bit5 : 1;	unsigned char bit6 : 1;	unsigned char bit7 : 1;};struct two_bytes{	unsigned char low;	unsigned char high;};union wordtype{	unsigned int word;	struct two_bytes byte;	struct sixteen_bits part;};union chartype{	unsigned char byte;	struct eight_bits part;};#endif
Link spre comentariu

Alex esti magnific, ce imi scri tu aici e un roman :) :rolleyes:

Nu ma pricep la programare, eu stiu ca daca am un program in format .hex pot cu el sa programez pic-ul :finga:

Ma intereseaza acum pt schema cu emitator si receptor cu pic 16f84, pe site e ceva asemanator cu ce imi scri tu dar eu vreau compilat (daca spun bine) ceva .hex :weedman: http://www.geocities.com/vsurducan/elec ... serial.htm

Link spre comentariu

Alex, am o intrebare: Ai verificat codul tau pentru mai multe telecomenzi RC5? Pentru ca eu am vazut pe osciloscop ca nu prea sunt toate la fel. Pe site am gasit scris:- Constant bit time of 1.778ms dar in realitate este departe de asa ceva. Am vizualizat pe osciloscop 5 telecomenzi si toate aveau perioada mai mica de 1700ms si nu erau doua la fel dar ... pe TV mergeau toate struna!! Cum fac aia decodarea pe TV de le merg toate??

Link spre comentariu

salut,si eu am facut un soft de decodare RC5 pt pic.am avut aceeasi problema cu respectarea timpilor.efectiv am facut programu de vreo 4 ori de la capat, in 4 moduri diferite, pentru ca pur si simplu nu mergea. nu am avut osciloscop sa verific. panca cand intr-o zi mi-a venit ideea sa mai maresc toleranta la timpi. ce sa vezi....toate telecomenzile mergeau :Ddaca vrei iti pot da softu. eu lam facut in micropascal. hexul nu am cum sa til dau, ca nu am decat programu care afiseaza pe LCD si aprinde niste leduri in functie de partea de prog pe care o executa(asta foloseam eu pentru test). programul l-am lasat "in paragina" pentru ca nu am avut timp...la vara dupa admitere...o sa il mai dezvolt.

Link spre comentariu

salut

uite pun aici codul, ca poate mai este si alta lume interesata. Quartzul folosit este de 4MHz.

 

 

(C) Bogdan Raducanu//lcdul vine la portb, asa cum arata astai din cmpilator (D7-D4 vin la RB7-RB4, plus fol RB3 si RB2//si receiveru de IR vine la RB0// pe la porta sunt 2 leduri...astea asa ca sa verific eu cam cum isi pierde asta timpu//end.program receiver;var receptie, adresa, date, biti,timp,i,j, ndate, nadresa : byte;cod : array[33] of byte;   s_t : array[3] of char;procedure interrupt;  begin    clearbit(intcon, 7);                      //scot intreruperle;    setbit(porta, 1);                        //ledu de test aprins    timp := tmr0;                             //salvez timpul          if testbit(intcon, 1)=1 then         //daca am intrerupere de RB0 atunci vine cod             begin             if biti=0 then biti := 1;             if (timp>200) and (timp<220) then         //daca am primit preamblu, atunci dau dumu la receptie                begin                biti := 2;                end;              if (timp>11) and (timp<23) and (biti>1) then           //daca am 0, asta e, nu crest decat nr de biti;                begin                biti :=biti+1;                end;              if (timp>29) and (timp<41) and (biti>1) then           //dak am 1, in pun in vectoras;                begin                cod[biti-1]:=1;                biti := biti+1;                end;              if biti=34 then                begin                receptie := 1;                end;          end;          if testbit(intcon,2)=1 then             begin             biti := 0;             end;          clearbit(intcon, 1);                      //clearez bitu din intrerupere;          clearbit(intcon, 2);                      //clearez bitu din timer intrerupere          tmr0 := 0;                                //resetez tmr0;          option_reg :=  0x85;                      //pun registru option, setez prescaler          clearbit(porta,1);          setbit(intcon, 7);                        //dau drumu la intreruperi  end;procedure asamblare;          begin          adresa :=0;          date :=0;          nadresa :=0;          ndate :=0;          for i:=0 to 7 do              begin              if cod[i+1]=1 then setbit(adresa, i);              if cod[i+9]=1 then setbit(nadresa,i);              if cod[i+17]=1 then setbit(date,i);              if cod[i+25]=1 then setbit(ndate,i);              end;          end;begincmcon := 0x07;                                    //fara comparatoaretrisa := 0;                                       //PORTA iesirioption_reg :=0x85;                                //setare prescaler 1:64;intcon := 0xB0;porta := 1;lcd_init(portb);lcd_cmd(lcd_cursor_off);setbit(trisb, 0);lcd_out(1,1, 'remote');lcd_out(2,1, 'tester');delay_ms(1000);lcd_cmd(lcd_clear);porta := 0;adresa :=0;date :=0;j :=0;while true do      begin      if receptie=1 then         begin         asamblare;         bytetostr(adresa, s_t);         lcd_out(1,1, s_t);         bytetostr(nadresa, S_t);         lcd_out(1,5,s_t);         bytetostr(date, s_t);         lcd_out(2,1, s_t);         bytetostr(ndate, s_t);         lcd_out(2,5,s_t);         receptie := 0;         for i:= 1 to 32 do             begin              cod[i] :=0;             end;         biti :=0;         end;       j :=j+1;       if j=255 then          begin          if testbit(porta, 0)=1 then clearbit(porta,0)          else          setbit(porta, 0);          j :=j+1;          end;     end;end.
Link spre comentariu
  • 1 lună mai târziu...

Pana la urma a facut cineva treaba asta? Daca da sa-si faca mila de noi sa ne dea mura-n gura schema si hex-ul pls :rolleyes:

Se pare ca nu :( , dar mai asteptam, poate, poate ... :weedman:
Link spre comentariu

Creează un cont sau autentifică-te pentru a adăuga comentariu

Trebuie să fi un membru pentru a putea lăsa un comentariu.

Creează un cont

Înregistrează-te pentru un nou cont în comunitatea nostră. Este simplu!

Înregistrează un nou cont

Autentificare

Ai deja un cont? Autentifică-te aici.

Autentifică-te acum



×
×
  • Creează nouă...

Informații Importante

Am plasat cookie-uri pe dispozitivul tău pentru a îmbunătății navigarea pe acest site. Poți modifica setările cookie, altfel considerăm că ești de acord să continui.Termeni de Utilizare si Ghidări