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.
Previous article:pic16f876a infrared receiving and ERROR program
Next article:pic12C508 DTMF dialer
Recommended ReadingLatest update time:2024-11-17 11:57
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- New breakthrough! Ultra-fast memory accelerates Intel Xeon 6-core processors
- New breakthrough! Ultra-fast memory accelerates Intel Xeon 6-core processors
- Consolidating vRAN sites onto a single server helps operators reduce total cost of ownership
- Consolidating vRAN sites onto a single server helps operators reduce total cost of ownership
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- 【CH549 Review】Part 2 Programming Tool Review
- Can UART1 and SPI of C8051F340 work at the same time?
- Summary of BQ78350-R1 FCC usage issues
- Showing Goods (3) - Antique Development Board
- What to do if the 6UL power supply voltage value is inaccurate
- Moto Bluetooth Headset HS810 Disassembly [Multiple Photos]
- 【NXP Rapid IoT Review】+⑦NXP Rapid IoT Review Summary
- Fluke and universities jointly build laboratories
- Can CAN bus load resistors be 0603 package chip resistors?
- MicroPython driver porting of LIS2MDL magnetic field sensor