Sari la conținut
ELFORUM - Forumul electronistilor

Telecomanda cu PIC in JAL


vasile doru

Postări Recomandate

Stie cineva vreo metoda de a programa un PIC in JAL pt a recunoaste codurile unei telecomenzi? Daca aveti un mic exemplu de program mi-ar fi de mare ajutor. Multumiri anticipate.

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

Top autori în acest subiect

  • vasile doru

    3

Vizitator Vasile

-- Written by Benjamin Hinrichs ([email protected]) - DH3BEN - (c) 2003---- Part of _VV.jal-- Look there for copyright and further information-- ---- name    : rc5.jal-- version : v1.0-- author  : Ben Hinrichs-- date    : 7-Feb-2002-- purpose : Receive and decode RC5-Code-- requires: rc5p, jdelay, jpic---- [1] http://www.ustr.net/infrared/infrared1.shtml---- tested for 16f84_10, 16f877, 18f452---- Copyright (C) 2002 Benjamin Hinrichs----include jdelayinclude rc5pprocedure delay_1778us is-- should be 1728us [1] or 1778us [2]. Depends on where you look ;-)	delay_100us(17)	delay_1us(78)end procedureprocedure get_rc5 (byte out laddress, byte out lcommand, bit out ltoogle, bit out lrc5ok) is	var byte count1, count2	laddress = 0	lcommand = 0	ltoogle  = low	count1   = 255	count2   = 255	lrc5ok   = high-- wait for transmission-- A transmission is approx. 25 ms long. It includes 14 bits, each consisting of two half bits.-- Looking every 500 us shouldn't let us miss a transmission. Timeout is after 128 ms. The time-- from the starting bit to the starting bit of the following transmission is approx. 114 ms. 	while (ir_in == high) & (count1 > 0) loop		delay_500us		count1 = count1 - 1	end loop-- Found something ?	if count1 == 0 then		lrc5ok = low		return	end if-- ignore first transmission-- There is a space of approx. 90 ms between two transmissions. Waiting for 60 ms puts us between-- two transmissions. This ensures that we start reading at the beginning of the next transmission.	delay_10ms(6)-- wait for start-bit-- RC5 is Manchestercode. A 1 is transmitted as two bits, first low, second high. A 0 vice versa.-- The receiver inverts the input. If there is no signal, you will see a high-state on ir_in.-- The RC5-Code starts with two high bits (-> 0101, which means 1010 on ir_in). So we just have-- to wait for a low state and we are on the second half-bit of the starting bit. Remember, we are-- having a low condition an ir_in and the starting bit is 1. If we wait 1778us we are exactly-- one bit further in the stream and can read it, but it is inverted. So we should wait only 3/4 of-- the time for the first time to be on the first half-bit. After that we apply the full time -- between two bits an can read the correct logical levels (see [1] for details). In the following-- code the time between two bits is always 1778us. If think this works because of some inaccuracies-- in jdelay ;-)	count2 = 255	while (ir_in == high) & (count2 > 0) loop		count1 = 255		while (ir_in == high) & (count1 > 0) loop			delay_1us(1)			count1 = count1 - 1		end loop		count2 = count2 - 1	end loop	if count2 == 0 then		lrc5ok = low		return	end if-- Begin reception-- Decode second AGC-Bit. Should be high, otherwise this is no RC5-Code	delay_1778us	if (ir_in == low) then		lrc5ok = low	end if	delay_1778us-- Decode toogle-bit	if ir_in then		ltoogle = high	end if	delay_1778us-- Decode 5 address-bits	if ir_in then		laddress = laddress + 16	end if	delay_1778us	if ir_in then		laddress = laddress + 8		end if	delay_1778us	if ir_in then		laddress = laddress + 4	end if	delay_1778us	if ir_in then		laddress = laddress + 2	end if	delay_1778us	if ir_in then		laddress = laddress + 1	end if-- Decode 6 command-bits	delay_1778us	if ir_in then		lcommand = lcommand + 32	end if	delay_1778us	if ir_in then		lcommand = lcommand + 16	end if	delay_1778us	if ir_in then		lcommand = lcommand + 8	end if	delay_1778us	if ir_in then		lcommand = lcommand + 4	end if	delay_1778us	if ir_in then		lcommand = lcommand + 2	end if	delay_1778us	if ir_in then		lcommand = lcommand + 1	end ifend procedure

-- Written by Benjamin Hinrichs ([email protected]) - DH3BEN - (c) 2003---- Part of _VV.jal-- Look there for copyright and further information-- -- ir pindefsvar volatile bit ir_in is pin_e2pin_e2_direction = input
Link spre comentariu
  • 2 luni mai târziu...

Am incercar rutina, dar nu merge. Imi receptioneaza acelasi cod indiferent pe ce buton apas. Am incercat cu mai multe telecomenzi. Poate telecomenzile nu emit in IR5 sau PIC-ul nu receptioneaza corect (merge la 4MHz si mai facea si altceva)? Ce poate fi?

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