Remote Control DEMO KIT User`s Guide

Remote Control DEMO KIT User¢s Guide
Remote Control DEMO KIT User¢s Guide
Introduction
This DEMO KIT is a set of Infrared transmitter and receiver wherein NEC Infrared format code is
implemented, refer to Figure 1 below. The receiver part receives and decodes the keypad commands and changes the display mode per function keys. This User¢s Guide describes mainly the
receiver functions.
MCUs
The HT48RA0-1 is used in the transmitter part and the HT48R10A-1 is used in the receiver part.
Code Format
This DEMO KIT employs the NEC format code.
fr= 1 0 8 m s
fr= 1 0 8 m s
N E C
9 m s
F o rm a t C o d e
9 m s
4 .5 m s
S 0 S 1 S 2 S 3 S 4 S 5 S 6 S 7 S 0 S 1 S 2 S 3 S 4 S 5 S 6 S 7 D 0 D 1 D 2 D 3 D 4 D 5 D 6 D 7 D 0 D 1 D 2 D 3 D 4 D 5 D 6 D 7
L e a d C o d e
C u s to m
C o d e
8 D a ta C o d e
8 D a ta C o d e
2 .5 m s
R e p e a t C o d e
B it " 0 "
B it " 1 "
0 .5 6 m s
0 .5 6 m s
1 .1 2 5 m s
2 .2 5 m s
Figure 1. NEC Format Code
1
Remote Control DEMO KIT User¢s Guide
DEMO KIT Outline
The DEMO KIT consists of a remote control transmitter part (left) and a receiver part (right) as
shown in the figure below.
Figure 2. DEMO KIT Outline
Usage
Power Supply
The power supply to both the transmitter and receiver part could come from any of the three
sources: 3 battery cells, a 9-volt battery or a 9-volt DC power supply. Choose the power supply
and the correct switch settings on the DEMO KIT, see Figure 3 below.
Main Power Switch
Power Selection Switch
9V Battery Supply
9V Power Jack
Figure 3. Power Supply Switches
2
Remote Control DEMO KIT User¢s Guide
Note
Power Selection Switch:
3 Battery Cells: 4. 5V
9-volt Battery: 5V
9-volt DC Power Supply: Not valid
Getting Started
Turn on the main switch first and then select the receiver display mode by pressing the S3~S6
while the S7~S10 are reserved for future use, see Figure 4 below.
Valid Selection
Key
DS66, Valid Decode Indicator
Figure 4. Display Mode Selection Keys
Display Modes
The display area is an 8´8 LED array, see Figure 5 below.
Figure 5. LED Display Array
3
Remote Control DEMO KIT User¢s Guide
The available display modes are:
· Mode 1:
Press Key S3. The LED corresponding to the emitter key position will light up, as shown in Figure 5, when the S21 switch of the emitter is pressed.
· Mode 2:
Press Key S4. The LED with the mirror position to the emitter key array will light up.
· Mode 3:
Press Key S5. Display the CUSTOM CODE alternately at a 1sec rate with the lower byte code
underlined. In this DEMO KIT, the CUSTOM CODE is 2C48H, so it will display 2C first and then
48 (underlined), alternately every 1sec.
· Mode 4:
Press Key S6. Display the corresponding key DATA CODE, lighted 50 is shown in Figure 7.
Note
If mode 3 is selected, after the first time the valid code is received, the DEMO KIT will display the
CUSTOM CODE continuously until the display mode is changed and a valid code is received.
Note that to determine whether a valid code is received or not, users can only tell it by the light
flash of the DS66.
Figure 6. Display Custom Code
Figure 7. Display Data Code
4
Remote Control DEMO KIT User¢s Guide
On the receiver part of the DEMO KIT, there are two special LEDs, DS65 and DS66. The DS65
LED flashing is controlled by the hardware circuit whenever there is Infrared signal detected at the
sensor. Refer to the circuit diagram of the receiver part. The DS66 LED illumination is controlled by
the MCU if the code is valid, otherwise, the DS66 LED remains off, see Figure 8 below.
DS66
DS65
Figure 8. Two special LEDs
After the receiver display mode setting is completed, user can start to use the DEMO KIT.
5
Remote Control DEMO KIT User¢s Guide
Flowchart (Receiver Part)
The whole program consists of the main procedure and the TMR interrupt service routines. There
are 4 interrupt service routines, namely, Custom Code Display Refreshing, Keying Debounce,
LED Matrix Scanning and Infrared Decoding.
· Main program of receiver
S T A R T
In itia l
C a ll F U N C 3 _ D A T A O U T
S e t T M R
C le a r F U N C 3 _ O K _ B IT
S ta rt T M R
O K _ F G = 1 ?
Y
C a ll R E C E IV E R _ IN IT IA L
C le a r L E D _ S C A N N IN G
C le a r W D T
In itia l M P 0 a n d T E M P [1 ]
F U N C 3 _ F G = 1 ?
N
C a ll th e s u b r o u tin e o f S c a n L E D
M A T R IX a c c o r d in g to th e r e s u lt o f
S c a n n in g th e k e y m a tr ix
Y
· TMR interrupt subroutine
E n te r in T M R in te r r p u t
S a v e A C C
a n d s ta tu s
1 . R e fu r b is h d is p la y in g
C U S T O M C O D E
2 . K e y D E B O U N C E
3 . S c a n L E D
M A T R IX
4 . R e c e iv e a n d d e c o d e
S W IP
R e tu rn
6
N
Remote Control DEMO KIT User¢s Guide
1. Refurbish displaying custom code
T IM E _ C N T [0 ] d e c re a s e 1
N
T IM E _ C N T [0 ]= 0 ?
Y
T IM E _ C N T [0 ]= 5 0
T IM E _ C N T [1 ] d e c re a s e 1
N
T IM E _ C N T [1 ]= 0 ?
Y
T IM E _ C N T [0 ]= 5 0
T IM E _ C N T [1 ]= 2 0 0
R e v e rs e T IM E _ F G
K e y D E B O U N C E
2. Key debounce
K e y d e b o u n c e
Y
Y
N
K E Y _ S T A T U S = 1 ?
D E B O U N C E _ C N T = 0 ?
N
K E Y _ R O W = 0 ?
Y
N
S e t K E Y _ S T A T U S
Y
Y
M o v e K E Y _ S C A N _ B U F [1 ]
toK E Y _ S C A N _ R E S
N
L E D _ L IN E = K E Y _
S C A N _ B U F [0 ]?
K E Y _ S T A T U S = 1 ?
N
D E B O U N C E _ C N T = 2 0 H
D E B O U N C E _ C N T = 0 ?
C le a r K E Y _ S T A T U S
S e t K E Y _ P R E S S
Y
C le a r K E Y _ P R E S S
D E B O U N C E _ C N T = 2 0 H
D E B O U N C E _ C N T
d e c re a s e 1
D E B O U N C E _ C N T
d e c re a s e 1
L E D
7
M A T R IX S c a n
N
Remote Control DEMO KIT User¢s Guide
3. Scan LED matrix
R e c y c le le ft K E Y _ S C A N _ B U F [1 ]
M P 0 in c r e a s e 1
N
L E D _ S C A N N IN G = 0
Y
Y
N
T E M P [1 ] d e c re a s e 1
a n d th e r e s u lt= 0
C le a r L E D _ S C A N N IN G
K E Y _ S C A N _ B U F [1 ]
= S Y N C _ C O D E ?
Y
M o v e th e a d d re s s o f D A T A [0 ] to M P 0
S e t L E D _ S C A N N IN G
T E M P [1 ]= 8
S e t a ll th e p in s o f L E D _ L IN E
M o v e D a ta to L E D _ R O W
L E D _ R O W = 0 F F H
b y R 0
M o v e K E Y _ S C A N _ B U F [1 ] to
L E D _ L IN E
M o v e K E Y _ S C A N _ B U F [1 ] to
L E D _ L IN E
R e c e iv e a n d d e c o d e s w ip
8
N
Remote Control DEMO KIT User¢s Guide
4. Receive and decode SWIP
D e la y to c le a r O K B IT
Y
Y
J M P
N
R E C E IV E R P IN = 0 ?
Y
N
S T A T U S _ F G = 1 ?
H _ T O _ L
J M P
H _ T O _ L
L _ T O _ L
J M P
L _ T O _ L
N
S T O P _ F G = 1 ?
N
S T O P _ F G = 0 ?
Y
S T A T U S _ F G = 1 ?
H _ T O _ H
J M P
E x it T M R in te r r u p t
L _ T O _ H
H _ T O _ H
L _ T O _ H
In c re a s e H I_ C O U N T
S T O P _ F G = 1 ?
Y
C le a r S T A T U S _ F G
N
Y
N
In c re a s e L O _ C O U N T
Z = 1 ?
Z = 1 ?
H I_ C O U N T d e c re a s e 1
N
C le a r S T O P _ F G
Y
N
M o v e L O _ C O U N T to
L O _ C O U N T _ S A V E
S e t S T A T U S _ F G
Y
L O _ C O U N T
D e c re a s e
C le a r L O _ C O U N T
M o v e H I_ C O U N T to
H I_ C O U N T _ S A V E
N
D A T A _ IN _ F G = 0 ?
Y
D A T A _ IN _ F G = 1 ?
Y
H I_ C O U N T < = H I_
M A X D U R A T IO N ?
N
B
N
7 0 < L O _ C O U N T < 1 1 0
B
Y
B IT C O U N T E R = 3 2
Y
N
E x it T M R in te r r u p t
H I_ C O U N T - L O _
C O U N T _ S A V E > 4 ?
Y
E x it T M R in te r r u p t
S to re 1
S to re 0
N
H I_ C O U N T < = 3 2 ?
B
B
Y
B IT C O U N T E R
d e c r e a s e 1 , a n d th e r e s u lt= 0
N
C le a r R E C E IV E R _ C O D E
Y
S e t R E P E A T _ F G
S T O P _ F G
C le a r D IV _ F G
S e t S T O P _ F G
A re C U S T O M C O D E
a n d D A T A r ig h t
a n d O K B IT
a n d
C le a r H I_ C O U N T
a n d L O _ C O U N T
O K C O U N T [0 ]= 0 A H ,
O K C O U N T [1 ]= 0 B 0 H
C le a r H I_ C O U N T _ S A V E a n d
L O _ C O U N T _ S A V E
N
Y
S e t O K _ F G
N
O K B IT = 1 ?
Y
D A T A _ IN _ F G = 1 ?
Y
Y
S e t D A T A _ IN _ F G
Y
D IV _ F G = 1 ?
N
E x it T M R in te r r u p t
N
3 2 < H I_ C O U N T < 6 0
N
C le a r H I_ C O U N T
S e t D IV _ F G
E x it T M R in te r r u p t
N
E x it T M R in te r r u p t
C le a r fla g s
B
O K C O U N T [0 ]= 0 A H ,
O K C O U N T [1 ]= 0 B 0 H
E x it T M R in te r r u p t
E x it T M R in te r r u p t
9
L O _ C O U N T < = L O _
M A X D U R A T IO N ?
N
Y
E x it T M R in te r r u p t
B
Remote Control DEMO KIT User¢s Guide
Circuit Diagram
Emitter Part
10
Remote Control DEMO KIT User¢s Guide
Receiver Part
11