Infrared remote control receiving program made by PIC

Publisher:未来感觉Latest update time:2017-12-04 Source: eefocusKeywords:PIC Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

There are three methods that are commonly used for infrared reception. 
1. Inquiry method, that is, the software keeps inquiring whether it is low (remote control signal) and then reads the header code and 
data 0 or 1 code  through precise delay.
2. When a signal input is read, turn on the timing counter, and then determine the header code and 0, 1 by reading the number of timer interrupts. 
3. RB0 or ​​RB4-RB7 plus timer (or software delay) The advantage of using input interrupts is that real-time control can be performed. 

As follows: 
;***The transmission is 6221, and the received code value is sent to the PORTC port of IC D for display****** 

;**************** *************** 
         org 0000h 
         nop 
         goto start 
         org 0004h 
         goto serv 
;************************************************** 
start 
         bsf status,rp0 ;body 1 
         MOVlw 0000h 
         MOVwf trisc ;C port output 
         MOVlw 0ffh ;B port RB0 input 
         MOVwf trisb 
         MOVlw B'00000100' ;1:64 
         MOVwf option_reg ;TMR0 timer 
         bcf status,rp0 ;body 0 
         clrf i NTC on ;10010000 
         bsf intcon,7 ;Open INT falling edge interrupt 
         bsf intcon,4 
         bcf intcon,1 
         clrf portc 
loop      
         sleep 
         nop 
         goto loop 
;****************Context protection******************************** 
serv       
         MOVwf w_temp 
         swapf status,0        
         clrf status          
         MOVwf status_temp     
         MOVf pclath,0 
         MOVwf pclath_temp 
         clrf pclath 
     
;***************Remote control processing.****************************** 

         bcf intcon,1 
         btfsc portb,0 ;Check if RB0 is 0. 
         goto zdhh ;RB0 is not 0, wrong interrupt. Return to  
         call delay8 ;Call 8MS delay. Header code detection. 
         btfsc portb,0 ;Check header code 
         goto zdhh ;Not interrupt return to 
         call delay5 ;Delay 5MS before data detection. 
         btfss portb,0 ;Check if RB0 is high level . 
         goto zdhh ;If not, continue detection. 
;************************************************ 
         
         clrf data1 ;20H 
         clrf data2 ;21H 
         clrf data3 ;22H 
         clrf data4 ;24H 
         clrf jsp2 ;32-bit counter 
         clrf sj ;Received data register 
         clrf jsp1 ;8-bit counter 
         MOVlw 0x20 ;20H register to W 
         MOVwf fsr ;Send 20H from W to FSR 
jc btfsc portb,0 ;Check if RB0 is low level. 
         goto jc ;Do not continue to check. 
;**************0 and 1 data check****************************        
js call delay1 ;Delay 1.3MS 
         btfsc portb,0 ;Check if the header code is 0 or 1, 
         goto s1 ;The detected data is not "1" 
;****************0 data processing******************************** 
         bcf sj,c ; data is "0" 
         rrf sj,1 ; 0 data right shift to SJ register 
         goto j1 
;**************1 data processing.**************************** 
s1 bsf sj,c 
         rrf sj,1 
ddp btfsc portb,0 
         goto ddp 
;**************RAM shift*************************** 
j1 incf jsp1 ;8-bit counting register 
         incf jsp2 ;32-bit number, counter register. 
         btfss jsp1,3 ; whether there is 8-bit 
         goto js 
         clrf jsp1 
         MOVf sj,0 ; shift 8-bit number to W 
         MOVwf indf ; W to DATA 
         incf fsr ; RAM address plus 1 
         clrf sj 
;******************************** 
         btfss jsp2,5 ; check whether 32 bits have been received. 
         goto js ; if not, check again. 
         MOVlw B'10001111' ; send IC high 8-bit code 
         xorwf data1,0 ; subtract (Z: 1 = result is 0; 0 = result is not 0) 
         btfss status,2 ; if the result is 0, go to the next step. 
         goto zdhh ; if the subtraction result is not 0, interrupt and return 
          MOVlw B'101010101' ; detect low 8-bit IC code 
          xorwf data2,0 
         btfss status,2 
          goto zdhh 
         ; comf data4,0 ; data inverse code detection. Not used for the time being. 
         ;subwf data3,0 
         ;btfss status,2 
         ;goto zdhh 
         MOVf data3,0 ; send digital code to C port 
         MOVwf portc 
          goto zdhh ; after receiving 32 bits, interrupt and return 
;****************zdhh interrupt return program************************ 
zdhh     
         MOVf pclath_temp,0 
         MOVwf pclath 
         swapf status_temp,0 ;Swap STATUS and W contents, restore body selection. 
         MOVwf status ;Send W content to STATUS register 
         swapf w_temp,1 ;Swap w_temp 
         swapf w_temp,0 ;Swap w_temp and w content, restore w_temp content?         
         bcf intcon,1 
         retfie ;Return from interrupt, 

;****************8ms******************************** 
delay8 bcf intcon,5 
         bcf intcon,2 
         MOVlw D'15' 
         MOVwf tmr0 
loop1 btfss intcon,2 
         goto loop1 
           return 
;****************5ms******************************** 
delay5 bcf intcon,5 
         bcf intcon,2 
         MOVlw D'120' 
         MOVwf tmr0 
loop2 btfss intcon,2 
         goto loop2 
           return 
;****************1.3ms******************************* 
delay1 bcf intcon,5  
         bcf intcon,2 
         MOVlw D'240' 
         MOVwf tmr0 
loop3 btfss intcon,2 
         goto loop3 
         return 
;************* 
          end 

There are two possible reasons for the error code. 
One is that the header is not aligned well, and 
the other is that there is an error in data transmission, especially the timing error. The 
latter can be verified by software. 
The header is not well confirmed. It is best to send several more in a row according to the software regulations. Then use the shift method to determine whether there are multiple consecutive identical sub-headers and align the headers. For example, after 20 consecutive 1s and 0s are converted, it means that data is ready to be sent. Then wait for 1 0. After the transmission is completed, there is a header, such as 11110000. In this way, data can be received later. 
   
A I bought a universal remote control outside . It is made with pic16c57c, which means it has no interrupts. I really don’t understand how it is made. It has no decoding chip. Does anyone know? I am also doing this now. Can anyone give me a hint? Thank you. 

B This is very easy.   
Last time I used two PIC16C57Cs to make a small module for transmission and reception. Effective control, no garbled code, but there is a disadvantage that it will be interfered by other infrared products! !   
  
C Infrared reception   
uses external interrupts, plus timing, you can detect the code , very accurately. I use PIC16F72 chip.   
  

D I use infrared receiving tubes with two-stage amplification to see the output waveform of infrared, and use Changhong remote control as the signal source. On the oscilloscope, you have to hit 10ms to see the complete signal waveform, like a waveform after voltage stabilization. I read the relevant books and it says that the infrared signal is modulated on the 38k Hz signal. Why can't I see the waveform when I hit the oscilloscope on 50ns? In this case, there is no way to compile the program. I hope some experts can help me. Thank you.   
  

E You can use the input capture function in CCP. It is very useful. Read the relevant content of input capture carefully. If there is an event on the CCP pin (can be set to rising edge, falling edge or other methods), it is easy to  record
the content of TMR1. This is very accurate. Even if the interrupt response is slow, there is no problem. This function is the most appropriate for infrared remote control! ! 
  
F Reply to the principle of infrared timing reception.   
Use RB0 as interrupt (FIRST: RISING TRIG, SECOND: FALLING TRIG), and start TIMER2 timing (100US) counting at the same time. When the next interrupt comes, TIMER2 has 88 numbers, and 9MS is detected. The rest of the time, 
and so on. Note that the interrupt edge of RBO should be changed according to the timing. Based on this principle, it is easy to compile the code. 
There is another point worth noting; the attenuation of infrared signals is very severe, so you must consider the choice of its acceptance range.   
In fact, any method can be used. Leave enough margin in time when receiving data, which is good for correct reception of data.   


Keywords:PIC Reference address:Infrared remote control receiving program made by PIC

Previous article:pic16f876a infrared receiving and ERROR program
Next article:pic12C508 DTMF dialer

Recommended ReadingLatest update time:2024-11-17 11:57

PIC series microcontroller application design and examples
   1. Introduction    Today, as the application fields of   microcontrollers become increasingly widespread, applications in various fields have also put forward higher requirements for microcontroller manufacturers, hoping for faster speed, lower power consumption, smaller size, and cheaper price . And fewer periphe
[Microcontroller]
Introduction to PIC microcontroller reset system module
The reset function of the PIC16F87X series microcontrollers is well designed. According to the conditions and reasons that cause the internal reset of the microcontroller , the reset system of the PIC microcontroller can be divided into five modules for introduction: 1. Power-on reset Every t
[Microcontroller]
PIC microcontroller music player program
The following program needs two timer resources. It can be implemented by any PIC microcontroller with two timers. The MCU required for this example is MICROChip PIC16C62   INCLUDE "D:\PIC\P16XX.EQU"; this file can be found in the MICROCHIP CD   ; ******************************************************   #define BeepOu
[Microcontroller]
PIC microcontroller drives RT1602C program
P IC   microcontroller  drives RT1602C program RT1602C drives  UART serial port output, baud rate is 19200Key  scan:    key 1 controls LCD display status, receiving status or sending statusKey    2 loop controls UART to output sub-serial port  AD conversion functionUART  serial port receiving  interruptTIME1 timer in
[Microcontroller]
Development of air conditioning control system based on PIC16C72 single chip microcomputer
  Heat pump split wall-mounted air conditioners are increasingly being chosen by families for their superior performance, and their functions are changing with each passing day. The control system plays a key role in improving their functions. This article introduces a design method for an air conditioning control sys
[Microcontroller]
Development of air conditioning control system based on PIC16C72 single chip microcomputer
PIC16F877A PWM output program
//////////////////////////////////////// //In the PICC compiler master, debugging passed, PIC16F877A PWM signal output #include pic.h #define uchar unsigned char #define uint unsigned int __CONFIG(0x1832); void delay() { uint k; for(k=0;k 5000;k++);  } void main() { uchar k; T2CON=0X04; //Start timer 2 CCPR1L
[Microcontroller]
Conditions and reasons for PIC microcontroller reset system
The reset function of the PIC16F87X series microcontrollers is relatively well designed. The conditions and reasons that cause the internal reset of the microcontroller can be roughly summarized into the following five types   .   1. Power-on reset   Every time the microcontroller is powered on, the power-on reset cir
[Microcontroller]
Assembly language basics of microcontroller programming - PIC microcontroller assembly instructions
1. Basic format of the program First introduce two pseudo instructions: EQU - label assignment pseudo-instruction ORG ——Address definition directive After RESET, the instruction counter PC of PIC16C5X is set to all "1", so the reset addresses of several types of PIC16C5X chips are: PIC16C54/55: 1FFH PIC16C56: 3FFH PI
[Microcontroller]
Assembly language basics of microcontroller programming - PIC microcontroller assembly instructions
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号