HT6221 Remote Control Chip Introduction[Copy link]
HT6221 Remote Control Chip Introduction
1. Features
*
Operating voltage: 1.8V~3.5V
* Dout
output 38KHz
*
Minimum transmission word:
one word
*
One 455KHz
ceramic or crystal
* 16
-bit address code
* 8
-bit data code
* ppm
code mode
*
Maximum active keys HT6221: 32
keys
HT6222: 64
keys
2. Applications
*
TV and video recorder controller
*
Burglar alarm system
*
Fire alarm system
*
Door controller
*
Car alarm system
*
Security system
*
Other remote control systems
3. Overview
HT6221/HT6222
can encode 16
-bit address code and 8-
bit data code, HT6221/HT6222
includes 32
keys (K1 K32)
and 64
keys (K1 K64)
4.
Pin diagram
-20 DIP/SOP
HT6221
HT6222
-24 DIP/SOP
7 DOUT
output
serial data output pin, 38KHz
transmission frequency
8 VDD
input 1.8V 3.5V
9 DT
input
most significant data bit (DT)
code setting
10 X2
output 455KHz
oscillator output
11 X1
input 455KHz
oscillator input
12 VSS
input
ground
13 LED
output
transmit output
14 21 C8 C1
input/
output
keyboard column control
22 AIN
input
low 8
-bit address code input
23 24 R1 R2
input
keyboard row control,
high level valid
7. Internal connection application circuit
II Code characteristics
1 HT6221 Key code formation
When a key is pressed for more than 36ms,
the oscillator activates the chip.
If the key is pressed and the delay is about 108ms,
the 108ms
transmit code consists of a start code 9ms,
a result code 4.5ms, a
low 8
-bit address code
9ms~18ms, and
a high 8-
bit address code 9ms~18ms. ,8
-bit data code 9ms~18ms
and the inverse code of this 8-
bit
data 9ms~18ms. If the key is pressed for more than 108ms and is not released, the next transmitted code will only consist of the start code 9ms
and the end code 2.5ms. 2. The code format is based on the received code. The received code is the reverse of the transmitted code. Definition of single-send code format and continuous code format. Note : Code width algorithm. The shortest width of the 16-bit address code is 1.12 16=18ms. The longest width of the 16-bit address code is 2.24ms 16=36ms. It is easy to know that the width and width of the 8 -bit data code and its 8- bit inverse code are unchanged. 1.12ms+2.24ms 8=27ms. The width of the 32 -bit code is 18ms+27ms ~(36ms+27ms) 3. Decoding method and software description 0 0.56ms data period(1.12ms) 1 0.56ms data period(2.24ms) 2.5ms 9ms 32 (4.5ms~63ms) (A0~A15+D0~D7+D0~D7) 4.5ms The key to 9ms decoding is how to identify 0 and 1. From the definition of the bit, we can find that 0 and 1 both start with a low level of 0.56ms. The difference is that the width of the high level is different. 0 is 0.56ms, 1
1.68ms,
so
we must distinguish 0
and 1 according to the width of the high level.
If the delay starts
after 0.56ms of low level , if the level read is low after 0.56ms , it means that the bit is 0, otherwise it is 1. For reliability the delay must be longer than 0.56ms but not more than 1.12ms, otherwise if the bit is 0 , the next bit of high level is read . Therefore, 1.12ms+0.56ms/2= 0.84ms is the most reliable. Generally, 0.84ms or so can be taken. 2 According to the format of the code, we should wait for 9ms of start code and 4.5ms of result code to complete before reading the code. 3 From the above two points, we can get the flowchart of the decoding program. In this way, only ordinary codes are received. To obtain standard key values, code recognition and code conversion must be performed . The following is the subroutine for obtaining standard values from code reception. KREM is connected to the I/O ports 1AH, 1BH, 1CH, 1DH of the receiving head. There are 4 consecutive units for storing codes. YAO_KONG: CLR EA JNB KREM, REMOT1 SJMP REM_BAK KREM is usually high level, so when KREM=1 , it means no key is pressed, and it should return to REMOT1: JNB KREM,$ wait for 9ms start code to be sent. MOV R2,#32 32 means the code is 32 bits in total, and 24 bits can also be sent. KREM =0 Y 9ms 6ms, N Y 6ms 0.9ms (), 32 N The received 24- bit code will not include the inverse code of the data code ;----------------------------------------- Code reception BYTE1: MOV R3,#250 BYTE2: MUL AB The delay is about 6ms, which can be slightly longer or shorter , but not less than 4.5ms and not too long. Too long will affect the program running speed when pressed continuously. JNB KREM,BYTE3; DJNZ R3,BYTE2; Since the result code is 4.5ms, if it is less than 4.5ms and the result code is not sent, the read code value will be wrong ˝ BYTE3: JNB KREM,$ ; Wait for high level to ensure the consistent starting point of each bit ˝ ;----------------------------------------------- MOV R3,#150 DJNZ R3,$ ; Delay 0.9ms delay range is 0.56ms~1.12ms ;---------------------------------------- MOV C,KREM MOV R3,#4 MOV R0 ,#1DH BYTE4: MOV A,@R0 RLC A MOV @R0,A DEC R0 DJNZ R3,BYTE4 DJNZ R2,BYTE1 ; So far, the 32 -bit code has been received and stored in 1AH~1DH, which are the low 8- bit address code, the high 8- bit address code, the 8 -bit data code, and the 8- bit data inverse code ;---------------------------------------------------- ˝ ; Code recognition MOV A,1AH XRL A,#03 ;3 is the value of the low 8 bits of the address , and different remote controls have different address values JNZ REM_BAK MOV A,1BH XRL A,#0FCH ;FCH is the value of the high 8 bits of the address JNZ REM_BAK MOV A,1CH
CPL A
XRL A,1DH
If the address code is incorrect or the two units of the received data code
are not reversed, it is considered an error code.
This program will treat it as if no key was pressed.
table The values in the table are the codes of the corresponding keys on the panel.
For different remote controls,
the values in the table should be changed accordingly
TAB_REMOT:
DB 00H
; VCD DVD AUX TUNER ST/M TSV-4 6
DB 0C0H, 0D0H, 0E8H, 0F0H, 0E0H, 0C8H
; UP DOWN FM/AM MEMORY A/B 11
DB 00H, 20H, 48H, 68H, 58H
; 1 2 3 4 5 6 17
DB 0D8H, 0F8H, 40H, 60H, 50H, 70H
; AUTO VOL+ VOL- MUTE 21
DB 28H , 10H , 30H , 78H ;
=
... After
YA0_KONG
returns,
the value in the accumulator is
the standard key value.
If A=0
, it will not be processed.
Possible reasons
include whether a key is pressed
, the wrong code, or the operation of
the remote control
The delay in the program is
based on the 4MHz crystal oscillator.
If a different crystal oscillator is used,
just change the
corresponding value
to meet the delay time in the comments.
4
From the above decoding process, it is not difficult to find that the values 1AH~1DH decoded
for the continuous code are all 0FFH. So if the software needs to process the combo, we only need to determine whether 1AH~1DH are all 0FFH before code recognition. If so , there is a combo phenomenon. In this way, a combo flag is created and then returned . According to this flag and the key value read last time, the corresponding combo operation can be performed until the key is released. The combo flag is cleared . The specific operation is as follows: Insert MOV A,1AH ANL A,1BH ANL A,1CH ANL A,1DH XRL A,#0FFH JNZ DAN_JI SETB FLAG_LIANJI before code recognition; Create combo flag SJMP END_YK DAN_JI: NOP In addition, the last few instructions of the subroutine are changed to REM_BAK0: MOV A,R2 SJMP END_YK0 REM_BAK: CLRA END_YK0: CLR FLAG_LIANJI ; Clear combo flag END_YK: SETB EA RET 4. Application Examples Readers may ask, as long as the remote control code is solved, what are the advantages of converting it to 1~n standard values? After reading the simple examples below, it is not difficult to find that it has the following advantages. In the application system, the instruments with remote controls generally have buttons , and the two have the same functions. After converting to standard values , the remote control button transfer table can be reused with the keyboard transfer table, which can save a certain amount of space. HT622 1/2 can support up to 32 or 64 buttons. Generally, the system only uses a part of them, which may make the remote control button code irregular. In order to deal with such codes, software personnel either try to find out the rules of those codes that are irregular through complex algorithms, or simply arrange them in a row without caring about so many.
A lot of CJNE A #DATA NEXT
command judgments
make the key value judgment tedious and lengthy. The above
method is clear and easy to use. For different remote controls, this program only needs to change the code conversion table, which is very beneficial for re-development.