Permet le décodage d?une télécommande RC5 , d?afficher quelques résultas sur un écran LCD 4x16 et de commander 6 sorties en fonction de vos besoins.
Le fichier « Montage_LCD.bmp » est une aide pour la connectique.
ryl?
merci beaucoup c est un très bon travail ça marche très bien chez moi. juste j ai une remarque quand j'allume un port j arrive pas a a le mettre en zero que une fois je click sur on off du telecommade RC5
Merci pour l'auteur de ce programme qui a fait un magnifique travail! Si bien que j'ai modifié à mon goût et qui bien sûr nécessite qq questions.
Voilà, j'ai viré la partie LCD et conservé uniquement le décodage du RC5. De plus j'ai modifié pour obtenir l'accès à 15 touches que je récupère en BCD sur le port B. Le capteur est déporté sur RB7. Je ne sait pas comment ont peut insérer le fichier asm mais bon je vais tenter un copier / coller sur ce post. Mais avant mes questions:
1) comment augmenter le nbre de touches, je souhaite porté à 32 touches mais impossible de valider au-delà de 15
2) J'ai pas compris ce jeu d'instruction (0x10 ^ 0x09)????? Pourtant c'est en travaillant sur cette routine que je suis arrivé à 15 touches
3) J'ai pensé modifié aussi cette cde mais ça change pas grand chose en faite j'ai valisé RB5 et RB6 en + pensant augmenter le nbre de code touche
andlw b'01111111'
andlw b'00111111'
Voici le asm modifié
ORG 0x0000
bsf STATUS,RP0 ; Select Bank 1
clrf TRISA ;
MOVLW B'10000000' ; portb.7 en entrée
MOVWF TRISB
bcf STATUS ,RP0 ; Select Bank 0
bcf INTCON, GIE ; disable Interupt
debut
call tempox
boucl_prog
clrf PORTB
call Recv_RC5 ; Récéption d'un code RC5
movfw RC5_DATA ; si RC5_DATA =0 (touche N°0 de la TC)
btfsc STATUS,Z ;
goto Action_1
busy movwf NB_TEMPO ; Temporisation : dure 500µs x "la valeur contenue dans W"
boucle movlw .123
movwf BUSY_1
boucle1 NOP
decfsz BUSY_1,1
goto boucle1
decfsz NB_TEMPO,1
goto boucle
return ; retour de la sous-routine
;-----------------------------------Tempo XXµS-----------------------------------
tempox movlw 0x0B ; pour x boucles
tempoxx movwf cmpt1 ; dans cmpt1
boucle2 movlw 0x25
call busy ; TEMPO xxxx µS
decfsz cmpt1 , f ; si 0, décrémenter compteur 3
goto boucle2 ; si cmpt1 pas 0, recommencer boucle2
return ; retour de la sous-routine
;-----------------------------------Réception des codes IR-----------------------------------
; RECEPTION D'UN CODE RC5
; RB6 en entrée (TSOP 1738...ou equivalent infra rouge)
; Controle RC5 : RC5_CTRL => 1 bit
; Adresse RC5 : RC5_ADR => 5 bits
; Données RC5 : RC5_DATA => 6 bits
Recv_RC5
btfsc PORTB, 7 ; Attendre un "0"
goto Recv_RC5 ; du bit de start
call Tempo444 ; attendre 444us, 1/4 cycle pour capture bit a bit
btfsc PORTB, 7 ; tester si "0" (anormal probabl... une emission en cours mal sync!)
goto Fin_RC5 ; ERREUR ! finir la phase de reception
nextbit rlf donn1,f ; rotation a gauche de tous les bits
rlf donn2,f ;
bcf donn1, 0 ; forcer a "0" le bit0 de "donn1"
btfsc PORTB, 7 ; si RB6 (infra rouge) =0
bsf donn1, 0 ; forcer a "1" le bit0 de "donn1"
call Set_bit ; attendre flanc montant ou desc en fonction de l'etat de RB6 (infra rouge)
call Tempo444 ; attendre 3/4 de Bit pour se ;tempo ; = 444,5 us
call Tempo888 ; placer a 1/4 du bit suivant ;tempo ; = 889 us
decfsz Loop3,f ; les 13 bits sont t-ils tous reçus
goto nextbit ; si non, recommencer reception du bit suivant
;Recuperation des bits du code RC5 des variables "donn1" "donn2"
movfw donn1 ; recuperation des 6 bits de Données RC5
andlw b'01111111' ; 0 sur les bits non utilisés
movwf RC5_DATA ; Placer val dans "RC5_DATA"
rlf donn1,f ; decalage a gauche de 2
rlf donn2,f ; pour faire "remonter" les bits
rlf donn1,f ; de l'Adresse RC5
rlf donn2,f ; de donn1
movfw donn2 ; vers donn2
andlw b'00111111' ; 0 sur les bits non utilisés
movwf RC5_ADR ; recuperation des 5 bits dans "RC5_ADR"
clrf RC5_CTRL ; recuperation du bit
btfss donn2, 5 ; de controle RC5
bsf RC5_CTRL, 0 ; dans "RC5_CTRL"
Fin_RC5
return
;-------------------------Attendre fin bit fonction de PORTB6 (IR)-----------------------------
btfsc PORTB, 7 ; si "0"
goto haut
bas btfsc donn1, 0 ; bit en cours =0 ?
return ; flanc haut/bas
goto saut_l
haut btfss donn1, 0 ; bit en cours =1 ?
return ; flanc bas/haut
saut_l decfsz Loop1,f
goto tim11
return
;--------------------------------------- TEMPORISATION POUR RC5--------------------------------------
Tempo888 movlw 0x12 ; Temporisation de 888µs
goto tim0
merci pour ta reponse
est il possible d'avoir un petit schema pour faire ces sorties supplementaires ainsi que la modif du fichier de programation car biensur cette application sort du projet initial
merci encore
a+
christian
Ce prg fonctionne avec les télécommandes suivantes:
Marantz (lecteur CD7001)
Cyrrus CD système
Philips RD6830
+ télécommande universelle programmable
Merci
Merci pour l'auteur de ce programme qui a fait un magnifique travail! Si bien que j'ai modifié à mon goût et qui bien sûr nécessite qq questions.
Voilà, j'ai viré la partie LCD et conservé uniquement le décodage du RC5. De plus j'ai modifié pour obtenir l'accès à 15 touches que je récupère en BCD sur le port B. Le capteur est déporté sur RB7. Je ne sait pas comment ont peut insérer le fichier asm mais bon je vais tenter un copier / coller sur ce post. Mais avant mes questions:
1) comment augmenter le nbre de touches, je souhaite porté à 32 touches mais impossible de valider au-delà de 15
2) J'ai pas compris ce jeu d'instruction (0x10 ^ 0x09)????? Pourtant c'est en travaillant sur cette routine que je suis arrivé à 15 touches
3) J'ai pensé modifié aussi cette cde mais ça change pas grand chose en faite j'ai valisé RB5 et RB6 en + pensant augmenter le nbre de code touche
andlw b'01111111'
andlw b'00111111'
Voici le asm modifié
ORG 0x0000
bsf STATUS,RP0 ; Select Bank 1
clrf TRISA ;
MOVLW B'10000000' ; portb.7 en entrée
MOVWF TRISB
bcf STATUS ,RP0 ; Select Bank 0
bcf INTCON, GIE ; disable Interupt
debut
call tempox
boucl_prog
clrf PORTB
call Recv_RC5 ; Récéption d'un code RC5
movfw RC5_DATA ; si RC5_DATA =0 (touche N°0 de la TC)
btfsc STATUS,Z ;
goto Action_1
xorlw (0x01 ^ 0x00)
btfsc STATUS,Z ;
goto Action_2
xorlw (0x02 ^ 0x01)
btfsc STATUS,Z
goto Action_3
xorlw (0x03 ^ 0x02)
btfsc STATUS,Z
goto Action_4
xorlw (0x04 ^ 0x03)
btfsc STATUS,Z
goto Action_5
xorlw (0x05 ^ 0x04)
btfsc STATUS,Z
goto Action_6
xorlw (0x06 ^ 0x05)
btfsc STATUS,Z
goto Action_7
xorlw (0x07 ^ 0x06)
btfsc STATUS,Z
goto Action_8
xorlw (0x08 ^ 0x07)
btfsc STATUS,Z
goto Action_9
xorlw (0x09 ^ 0x08)
btfsc STATUS,Z
goto Action_10
xorlw (0x10 ^ 0x09)
btfsc STATUS,Z
goto fini
xorlw (0x11 ^ 0x10)
btfsc STATUS,Z
goto fini
xorlw (0x12 ^ 0x11)
btfsc STATUS,Z
goto fini
xorlw (0x13 ^ 0x12)
btfsc STATUS,Z
goto fini
xorlw (0x14 ^ 0x13)
btfsc STATUS,Z
goto fini
xorlw (0x15 ^ 0x14)
btfsc STATUS,Z
goto fini
xorlw (0x16 ^ 0x15)
btfsc STATUS,Z
goto fini
xorlw (0x17 ^ 0x16)
btfsc STATUS,Z
goto fini
xorlw (0x18 ^ 0x17)
btfsc STATUS,Z
goto fini
xorlw (0x19 ^ 0x18)
btfsc STATUS,Z
goto fini
xorlw (0x20 ^ 0x19)
btfsc STATUS,Z
goto Action_11
xorlw (0x21 ^ 0x20)
btfsc STATUS,Z
goto Action_12
xorlw (0x22 ^ 0x21)
btfsc STATUS,Z
goto fini
xorlw (0x23 ^ 0x22)
btfsc STATUS,Z
goto fini
xorlw (0x24 ^ 0x23)
btfsc STATUS,Z
goto fini
xorlw (0x25 ^ 0x24)
btfsc STATUS,Z
goto fini
xorlw (0x26 ^ 0x25)
btfsc STATUS,Z
goto fini
xorlw (0x27 ^ 0x26)
btfsc STATUS,Z
goto fini
xorlw (0x28 ^ 0x27)
btfsc STATUS,Z
goto fini
xorlw (0x29 ^ 0x28)
btfsc STATUS,Z
goto fini
xorlw (0x30 ^ 0x29)
btfsc STATUS,Z
goto Action_13
xorlw (0x31 ^ 0x30)
btfsc STATUS,Z
goto fini
xorlw (0x32 ^ 0x31)
btfsc STATUS,Z
goto fini
xorlw (0x33 ^ 0x32)
btfsc STATUS,Z
goto fini
xorlw (0x34 ^ 0x33)
btfsc STATUS,Z
goto fini
xorlw (0x35 ^ 0x34)
btfsc STATUS,Z
goto Action_14
xorlw (0x36 ^ 0x35)
btfsc STATUS,Z
goto Action_15
xorlw (0x37 ^ 0x36)
btfsc STATUS,Z
goto fini
xorlw (0x38 ^ 0x37)
btfsc STATUS,Z
goto fini
xorlw (0x39 ^ 0x38)
btfsc STATUS,Z
goto fini
xorlw (0x40 ^ 0x39)
btfsc STATUS,Z
goto fini
xorlw (0x41 ^ 0x40)
btfsc STATUS,Z
goto fini
xorlw (0x42 ^ 0x41)
btfsc STATUS,Z
goto fini
xorlw (0x43 ^ 0x42)
btfsc STATUS,Z
goto fini
xorlw (0x44 ^ 0x43)
btfsc STATUS,Z
goto fini
xorlw (0x45 ^ 0x44)
btfsc STATUS,Z
goto fini
xorlw (0x46 ^ 0x45)
btfsc STATUS,Z
goto fini
xorlw (0x47 ^ 0x46)
btfsc STATUS,Z
goto fini
xorlw (0x48 ^ 0x47)
btfsc STATUS,Z
goto fini
xorlw (0x49 ^ 0x48)
btfsc STATUS,Z
goto fini
xorlw (0x50 ^ 0x49)
btfsc STATUS,Z
goto fini
xorlw (0x51 ^ 0x50)
btfsc STATUS,Z
goto fini
xorlw (0x52 ^ 0x51)
btfsc STATUS,Z
goto fini
xorlw (0x53 ^ 0x52)
btfsc STATUS,Z
goto fini
xorlw (0x54 ^ 0x53)
btfsc STATUS,Z
goto fini
xorlw (0x55 ^ 0x54)
btfsc STATUS,Z
goto fini
xorlw (0x56 ^ 0x55)
btfsc STATUS,Z
goto fini
xorlw (0x57 ^ 0x56)
btfsc STATUS,Z
goto fini
xorlw (0x58 ^ 0x57)
btfsc STATUS,Z
goto fini
xorlw (0x59 ^ 0x58)
btfsc STATUS,Z
goto fini
xorlw (0x60 ^ 0x59)
btfsc STATUS,Z
goto fini
xorlw (0x61 ^ 0x60)
btfsc STATUS,Z
goto fini
xorlw (0x62 ^ 0x61)
btfsc STATUS,Z
goto fini
xorlw (0x63 ^ 0x62)
btfsc STATUS,Z
goto fini
xorlw (0x64 ^ 0x63)
btfsc STATUS,Z
goto fini
xorlw (0x65 ^ 0x64)
btfsc STATUS,Z
goto fini
xorlw (0x66 ^ 0x65)
btfsc STATUS,Z
goto fini
xorlw (0x67 ^ 0x66)
btfsc STATUS,Z
goto fini
xorlw (0x68 ^ 0x67)
btfsc STATUS,Z
goto fini
xorlw (0x69 ^ 0x68)
btfsc STATUS,Z
goto fini
xorlw (0x70 ^ 0x69)
btfsc STATUS,Z
goto fini
xorlw (0x71 ^ 0x70)
btfsc STATUS,Z
goto fini
xorlw (0x72 ^ 0x71)
btfsc STATUS,Z
goto fini
xorlw (0x73 ^ 0x72)
btfsc STATUS,Z
goto fini
xorlw (0x74 ^ 0x73)
btfsc STATUS,Z
goto fini
xorlw (0x75 ^ 0x74)
btfsc STATUS,Z
goto fini
xorlw (0x76 ^ 0x75)
btfsc STATUS,Z
goto fini
xorlw (0x77 ^ 0x76)
btfsc STATUS,Z
goto fini
xorlw (0x78 ^ 0x77)
btfsc STATUS,Z
goto fini
xorlw (0x79 ^ 0x78)
btfsc STATUS,Z
goto fini
xorlw (0x80 ^ 0x79)
btfsc STATUS,Z
goto fini
xorlw (0x81 ^ 0x80)
btfsc STATUS,Z
goto fini
xorlw (0x82 ^ 0x81)
btfsc STATUS,Z
goto fini
xorlw (0x83 ^ 0x82)
btfsc STATUS,Z
goto fini
xorlw (0x84 ^ 0x83)
btfsc STATUS,Z
goto fini
xorlw (0x85 ^ 0x84)
btfsc STATUS,Z
goto fini
xorlw (0x86 ^ 0x85)
btfsc STATUS,Z
goto fini
xorlw (0x87 ^ 0x86)
btfsc STATUS,Z
goto fini
xorlw (0x88 ^ 0x87)
btfsc STATUS,Z
goto fini
xorlw (0x89 ^ 0x88)
btfsc STATUS,Z
goto fini
xorlw (0x90 ^ 0x89)
btfsc STATUS,Z
goto fini
xorlw (0x91 ^ 0x90)
btfsc STATUS,Z
goto fini
xorlw (0x92 ^ 0x91) ; si RC5_DATA =h0C (touche ON/OFF de la TC)
btfsc STATUS,Z
goto fini
xorlw (0x93 ^ 0x92)
btfsc STATUS,Z
goto fini
xorlw (0x94 ^ 0x93)
btfsc STATUS,Z
goto fini
goto fini
;-----------------------------------Validation des sorties-----------------------------------
Action_1
movlw B'00001010' ; Touche 0
movwf PORTB
goto fini
Action_2
movlw B'00000001' ; Touche 1
movwf PORTB
goto fini
Action_3
movlw B'00000010' ; Touche 2
movwf PORTB
goto fini
Action_4
movlw B'00000011' ; Touche 3
movwf PORTB
goto fini
Action_5
movlw B'00000100' ; Touche 4
movwf PORTB
goto fini
Action_6
movlw B'00000101' ; Touche 5
movwf PORTB
goto fini
Action_7
movlw B'00000110' ; Touche 6
movwf PORTB
goto fini
Action_8
movlw B'00000111' ; Touche 7
movwf PORTB
goto fini
Action_9
movlw B'00001000' ; Touche 8
movwf PORTB
goto fini
Action_10
movlw B'00001001' ; Touche 9
movwf PORTB
goto fini
Action_11
movlw B'00001011' ; Touche Next
movwf PORTB
goto fini
Action_12
movlw B'00001100' ; Touche Previous
movwf PORTB
goto fini
Action_13
movlw B'00001101' ; Touche Pause
movwf PORTB
goto fini
Action_14
movlw B'00001110' ; Touche Play
movwf PORTB
goto fini
Action_15
movlw B'00001111' ; Touche Stop
movwf PORTB
goto fini
Action_16
movlw B'00010000' ; Touche
movwf PORTB
goto fini
Action_17
movlw B'00010001' ; Touche
movwf PORTB
goto fini
Action_18
movlw B'00010010' ; Touche
movwf PORTB
goto fini
Action_19
movlw B'00010011' ; Touche
movwf PORTB
goto fini
Action_20
movlw B'00010100' ; Touche
movwf PORTB
goto fini
Action_21
movlw B'00010101' ; Touche
movwf PORTB
goto fini
Action_22
movlw B'00010110' ; Touche
movwf PORTB
goto fini
Action_23
movlw B'00010111' ; Touche
movwf PORTB
goto fini
Action_24
movlw B'00011000' ; Touche
movwf PORTB
goto fini
Action_25
movlw B'00011001' ; Touche
movwf PORTB
goto fini
Action_26
movlw B'00011010' ; Touche
movwf PORTB
goto fini
Action_27
movlw B'00011011' ; Touche
movwf PORTB
goto fini
Action_28
movlw B'00011100' ; Touche
movwf PORTB
goto fini
Action_29
movlw B'00011101' ; Touche
movwf PORTB
goto fini
Action_30
movlw B'00011110' ; Touche
movwf PORTB
goto fini
Action_31
movlw B'00011111' ; Touche
movwf PORTB
goto fini
fini
call tempox ; tempo entre chaque detection
call tempox
goto boucl_prog ; recommencer la detection RC5
;-----------------------------------Tempo 500µS-----------------------------------
busy movwf NB_TEMPO ; Temporisation : dure 500µs x "la valeur contenue dans W"
boucle movlw .123
movwf BUSY_1
boucle1 NOP
decfsz BUSY_1,1
goto boucle1
decfsz NB_TEMPO,1
goto boucle
return ; retour de la sous-routine
;-----------------------------------Tempo XXµS-----------------------------------
tempox movlw 0x0B ; pour x boucles
tempoxx movwf cmpt1 ; dans cmpt1
boucle2 movlw 0x25
call busy ; TEMPO xxxx µS
decfsz cmpt1 , f ; si 0, décrémenter compteur 3
goto boucle2 ; si cmpt1 pas 0, recommencer boucle2
return ; retour de la sous-routine
;-----------------------------------Réception des codes IR-----------------------------------
; RECEPTION D'UN CODE RC5
; RB6 en entrée (TSOP 1738...ou equivalent infra rouge)
; Controle RC5 : RC5_CTRL => 1 bit
; Adresse RC5 : RC5_ADR => 5 bits
; Données RC5 : RC5_DATA => 6 bits
Recv_RC5
btfsc PORTB, 7 ; Attendre un "0"
goto Recv_RC5 ; du bit de start
call Tempo444 ; attendre 444us, 1/4 cycle pour capture bit a bit
btfsc PORTB, 7 ; tester si "0" (anormal probabl... une emission en cours mal sync!)
goto Fin_RC5 ; ERREUR ! finir la phase de reception
clrf donn1 ; donn1=0
clrf donn2 ; donn2=0
movlw .13 ; 13 bits a capturer
movwf Loop3 ; 12 sont traites
call Tempo888 ; 1/4 du 2' Bit
nextbit rlf donn1,f ; rotation a gauche de tous les bits
rlf donn2,f ;
bcf donn1, 0 ; forcer a "0" le bit0 de "donn1"
btfsc PORTB, 7 ; si RB6 (infra rouge) =0
bsf donn1, 0 ; forcer a "1" le bit0 de "donn1"
call Set_bit ; attendre flanc montant ou desc en fonction de l'etat de RB6 (infra rouge)
call Tempo444 ; attendre 3/4 de Bit pour se ;tempo ; = 444,5 us
call Tempo888 ; placer a 1/4 du bit suivant ;tempo ; = 889 us
decfsz Loop3,f ; les 13 bits sont t-ils tous reçus
goto nextbit ; si non, recommencer reception du bit suivant
;Recuperation des bits du code RC5 des variables "donn1" "donn2"
movfw donn1 ; recuperation des 6 bits de Données RC5
andlw b'01111111' ; 0 sur les bits non utilisés
movwf RC5_DATA ; Placer val dans "RC5_DATA"
rlf donn1,f ; decalage a gauche de 2
rlf donn2,f ; pour faire "remonter" les bits
rlf donn1,f ; de l'Adresse RC5
rlf donn2,f ; de donn1
movfw donn2 ; vers donn2
andlw b'00111111' ; 0 sur les bits non utilisés
movwf RC5_ADR ; recuperation des 5 bits dans "RC5_ADR"
clrf RC5_CTRL ; recuperation du bit
btfss donn2, 5 ; de controle RC5
bsf RC5_CTRL, 0 ; dans "RC5_CTRL"
Fin_RC5
return
;-------------------------Attendre fin bit fonction de PORTB6 (IR)-----------------------------
Set_bit movlw 0x09 ; Tempo
movwf Loop1
tim11 movlw 0x20 ;
movwf Loop2
tim22 decfsz Loop2,f
goto tim22
btfsc PORTB, 7 ; si "0"
goto haut
bas btfsc donn1, 0 ; bit en cours =0 ?
return ; flanc haut/bas
goto saut_l
haut btfss donn1, 0 ; bit en cours =1 ?
return ; flanc bas/haut
saut_l decfsz Loop1,f
goto tim11
return
;--------------------------------------- TEMPORISATION POUR RC5--------------------------------------
Tempo888 movlw 0x12 ; Temporisation de 888µs
goto tim0
Tempo444 movlw 0x09 ; Temporisation de 444µs
tim0 movwf Loop1
tim1 movlw 0x0F
movwf Loop2
tim2 decfsz Loop2,f
goto tim2
decfsz Loop1,f
goto tim1
return
end
==========================
Merci à tous
Cdlt,
est il possible d'avoir un petit schema pour faire ces sorties supplementaires ainsi que la modif du fichier de programation car biensur cette application sort du projet initial
merci encore
a+
christian
Vous n'êtes pas encore membre ?
inscrivez-vous, c'est gratuit et ça prend moins d'une minute !
Les membres obtiennent plus de réponses que les utilisateurs anonymes.
Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.
Le fait d'être membre vous permet d'avoir des options supplémentaires.