The infrared remote control transmitter chip adopts PPM encoding. When the transmitter button is pressed, a set of 108ms encoding pulses will be emitted. The remote control encoding pulse consists of a preamble, an 8-bit user code, an 8-bit inverse code of the user code, an 8-bit operation code, and an 8-bit inverse code of the operation code. By checking the user code, each remote control can only control the action of one device, which can effectively prevent interference between multiple devices. The encoding must be followed by an inverse code to verify the correctness of the encoding reception, prevent misoperation, and enhance the reliability of the system. The preamble is the starting part of a remote control code, consisting of a 9ms low level (start code) and a 4.5ms high level (result code), which serves as a preparation pulse for receiving data. The combination of a pulse width of 0.56ms and a period of 1.12ms represents a binary "0"; the combination of a pulse width of 1.68ms and a period of 2.24ms represents a binary "1". If the key is pressed for more than 108ms and is not released, the next transmitted code (burst code) will only consist of the start code (9ms) and the end code (2.5ms).
The MCU uses the external interrupt INTI pin to connect to the signal line of the infrared receiver, and the interrupt mode is edge triggered. Timer 0 is used to calculate the interval of the interrupt to distinguish the leading code, binary "1", and "0" codes. The 8-bit operation code is extracted and displayed on the digital tube.
// The decoded value is in Im[2]. When IrOK=1, the decoding is valid.
/* 51 MCU infrared remote control decoding program*/
// Aim the remote control at the infrared receiver, press the remote control button, and the code of the corresponding button will be displayed on the first two digits of the digital tube
#include
#define uchar unsigned char
sbit dula=P2^6;
sbit wela=P2^7;
uchar code table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,
0x07,0x7f ,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
uchar f;
#define Imax 14000 //This is the value when the crystal is 11.0592,
#define Imin 8000 //If you use a crystal with other frequencies,
#define Inum1 1450 //You need to change the corresponding value.
#define Inum2 700
#define Inum3 3000
unsigned char Im[4]={0x00,0x00,0x00,0x00};
uchar show[2]={0,0};
unsigned long m,Tc;
unsigned char IrOK;
void delay(uchar i)
{
uchar j,k;
for(j=i;j>0;j--)
for(k=125;k>0;k--);
}
void display()
{
dula=0;
P0=table[show[0]];
dula=1;
dula=0;
wela=0;
P0=0xfe;
wela=1;
wela=0;
delay(5);
P0= table[show[1]];
dula=1;
dula=0;
P0=0xfd;
wela=1;
wela=0;
delay(5);
}
//External interrupt decoding program
void intersvr1(void) interrupt 2 using 1
{
Tc=TH0*256+TL0; //Extract interrupt time interval
TH0=0;
TL0=0; //Reset the timer interrupt
if((Tc>Imin)&&(Tc
m=0;
f=1;
return;
} //Find the start code
if(f==1)
{
if(Tc>Inum1&&Tc
Im[m/8]=Im[m/8]>>1|0x80; m++;
}
if(Tc>Inum2&&Tc
Im[m/8]=Im[m/8]>>1; m++; //Get code
}
if(m==32)
{
m=0;
f=0;
if(Im[2]==~Im[3])
{
IrOK=1;
}
else IrOK=0; //After the code is retrieved, determine whether the code is read correctly
}
//Prepare to read the next code
}
}
/*Demonstration main program*/
void main(void)
{
unsigned int a;
m=0;
f=0;
EA=1;
IT1=1;EX1=1;
TMOD=0x11;
TH0=0;TL0=0;
TR0=1;//ET0=1;
while(1)
{
if(IrOK==1)
{
show[1]=Im[2] & 0x0F; //Get the lower four bits of the key code
show[0]=Im[2] >> 4;
IrOK=0;
}
for(a=100;a>0;a--)
{
display();
}
}
}
Previous article:Improved float type liquid level meter based on MSP430F133 single chip microcomputer
Next article:Application example of AT88SC1604 card controlled by single chip microcomputer
- Popular Resources
- Popular amplifiers
- Molex leverages SAP solutions to drive smart supply chain collaboration
- Pickering Launches New Future-Proof PXIe Single-Slot Controller for High-Performance Test and Measurement Applications
- CGD and Qorvo to jointly revolutionize motor control solutions
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Nidec Intelligent Motion is the first to launch an electric clutch ECU for two-wheeled vehicles
- Bosch and Tsinghua University renew cooperation agreement on artificial intelligence research to jointly promote the development of artificial intelligence in the industrial field
- GigaDevice unveils new MCU products, deeply unlocking industrial application scenarios with diversified products and solutions
- Advantech: Investing in Edge AI Innovation to Drive an Intelligent Future
- CGD and QORVO will revolutionize motor control solutions
- 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
- 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!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Live Review: TI Ultrasonic Gas Flow Measurement Innovation Solution + CC13X2/CC26X2
- What a mess it is to have a 0.1uf capacitor with a problem {Complain about this here}
- PCB impedance control experience sharing
- Domestic sewage treatment online monitoring system
- Be careful when shopping on June 18: China Consumers Association warns consumers that so-called "quantum products" are "pseudo-technology"
- Getting Started with the ST SensorTile.box Sensor Kit (3) Expert Mode Experience
- Problem 2 of 7S3P battery pack
- Netizens are porting mpy to Nucleo-32
- LOTO arbitrary waveform generator SIG82 simulates the output of relay energization and disconnection signal waveforms for algorithm debugging
- For sale: 4412 development board