Professional Documents
Culture Documents
You Can Practice Microcontroller Programming Easily Now!: Thursday, October 23, 2008
You Can Practice Microcontroller Programming Easily Now!: Thursday, October 23, 2008
ﺍﻟﺘﺠﺎﺭﺏ ﺍﻟﻌﻤﻠﻴﺔ
א א א
Programming
Embedded Systems Microcontroller
אא אא
א
Wאא
KERottateF אאEShiftF
אאא
Wא
Wאא
אF،EShifft RightFא S6 א
א
אS7אE
KEShift LeftftF א
אאא S14א ERotaate RightF א א S13 א
KERotate RigghtF
W
א
.Jumpper א JP9 JPP6א
אא
א 2
אאא
Practical Class 4 Programming Microcontrollers
Wאא
אא א
א א א
Shift var , Right/Left [, shift]
[, shift]אא
א א
Rotate var , Right/Left [, rotate]
[, shift]אא
Wאא
$regfile = "m128def.dat"
$crystal = 8000000 Kא
'---------------------
Config Pine.4 = Input
Config Pine.5 = Input
Config Pine.6 = Input
Config Pine.7 = Input
Pine.4 = 1 : Pine.5 = 1
Pine.6 = 1 : Pine.7 = 1
Faculty of Electrical and Electronic Eng.
3 Automatic Control & Automation Dept.
אא אא
א
Exxp.11: Get RC
R Value
אW א
א
Wאא
K
א א
אא
א
Wא
Wאא
א א א
א
KGetrc
G
אא
אאא
W
א
K
אSW22א .Jumper א JP114א
אא
א 4
אאא
Practical Class 4 Programming Microcontrollers
Wאא
אא א
אא
pinx אא y
var = Getrc(pinx , y)
אא
> אא
Wאא
$regfile = "m128def.dat"
$crystal = 8000000 Kא
'----------------------
Config Lcdpin = Pin , Db4 = Portc.4 ,
Db5 = Portc.5 , Db6 = Portc.6 , Db7 = אאאא
Portc.7 , E = Portc.2 , Rs = Portc.3
Config Lcd = 20 * 4 Kא
'----------------------
Dim Rc_var As Word
'---------------------- א
Cls : Cursor Off
Lcd "RC Val= "
Do
Rc_var = Getrc(ping , 2)
Locate 1 , 9
Lcd Rc_var Kאא
Waitms 1000
Locate 1 , 8 : Lcd Spc(7)
Loop
End
Faculty of Electrical and Electronic Eng.
5 Automatic Control & Automation Dept.
אא אא
א
Wאא
ded
.RC5, RC5-Extend
R א ECLRM-20038SF א
א
Wא
Wאא
א אא
א א א א
.RC5
א
W
א
אSW22א .Jumper א JP118א
K
Wאא
אא
א 6
אאא
Practical Class 4 Programming Microcontrollers
אא א
Config Rc5 = Pinb.7 IRאא
Getrc5(address , Command) אאאאא
Wאא
$regfile = "m128def.dat"
$crystal = 8000000 Kא
'---------------------
Config Lcdpin = Pin , Db4 = Portc.4 ,
Db5 = Portc.5 , Db6 = Portc.6 , Db7 = אאאא
Portc.7 , E = Portc.2 , Rs = Portc.3
Config Lcd = 20 * 4 Kא
'---------------------
Config Rc5 = Pinb.7
'--------------------- אאא
Dim Address As Byte , Command As Byte א
Enable Interrupts
'--------------------- אא
Cls
Do
Gosub Remote_control
Loop אאאא
'--------------------- אאאאא
Remote_control:
Getrc5(address , Command)
If Address = 0 Then
Command = Command And &B01111111 Wא
Cls TVאאאא
Lcd "Command is: " ; Command
Waitms 50 א
End If
Return Kאאאא
'---------------------
Faculty of Electrical and Electronic Eng.
7 Automatic Control & Automation Dept.
אא אא
א
Wאא
KRC5 אא
א
א
Wא
Wאא
RCC5,
א
א א א
א
K
א
KRC5-Extended
W
א
K
אSW22א .Jumper א JP117א
Wאא
W
א
אא א
א א אא א
Rcc5send T
Togbit , Address
s , Command
RCC5אOCC1A
אא
א 8
אאא
Practical Class 4 Programming Microcontrollers
Wאא
$regfile = "m128def.dat"
$crystal = 8000000 Kא
'---------------------
Config Debounce = 200
Command = 12 א
Togbit = 0
Address = 0 א
'---------------------
Do
Debounce Pine.4 , 0 , Pwr_cmd , Sub
Loop
אאא
End Kא OC1A pin א
'---------------------
Pwr_cmd:
Rc5send Togbit , Address , Command
Waitms 200
Return אאאאא
'\-------------\
Kאא
Faculty of Electrical and Electronic Eng.
9 Automatic Control & Automation Dept.
אא אא
א
RC5--codeאאא א
Detailed Article
A aboutt Remote Control
C and IR Module
W is infraared?
What ؟אא
א
אא
Kאא
א
950nm
אא
9
אא
א
א
Kאא
א
אא
،
א
אא
א
Kאא
א
אאאא
א
،
، א
א ،
א א
א א
Kאא،א
א
א
W
אאא
،א
אא
א
א א
א א
א
א
،
א א ،אא ،
א
אא
א א
א
א א
א
א
KEAddress
A F א א
א،א
36KHZאאא
30KHZ
Z – 60KHZ א אא
א
א
36KHZ, 38KH
HZ
אאא
א
KE338KHZFא
א
36~388
אא
א
א
א
א
K
،אאא
א ، 366KHZ, 38KH
אאא א HZ
אא،
א
אא
אאא
א
אא
אא א
א אא
א
א
אא
א 10
אאא
Pra
actical Class 4
4 Prrogramming M
Microcontrolllers
א K
א א
א א ، א
א אא
א
277uS
،36KHZ
3
א א
K2
א
אאאK1
אא
א
1
א 2
א
אאא
Kא אאא
W is IR Transmittin
What T ng protocolss? ؟אאאא
א
،RC5
R ،SIRCCS ،NEC W
،א אEF א א
א
א KSonyy ،SAMSU
UNG ،JAPAAN
KEWaveform
msF
RCC5 Transm
mitting protoocols? RC55א
14
א RC5
R
א
1.728m
אא، mS
אא
א
K א1300mS
א א
Wא
אאא
א
אא
KEAdddress LengthhFאא -
KECommand
C L
Length א -
F
KECarrieer Frequenccy Fא -
KEStart BiitF אא -
KEHigh-BBit-TimeF"1" א א -
KELow-BBit-TimeF"0" א א -
Kא
א
אא
،، W
א
א
א،
אא אאאא K א
Facculty of Electrrical and Electtronic Eng.
11 Automatiic Control & A
Automation Dept.
אא אא
א
אאא،
אא،
א
אא
K א
א
،
אאא
א
א
א
،אא
אא
،
אאא
א،אא
א
אא
א،
א
K
א
א،
אא 277µs
א
א
אא
א،א
אאא
א EdemodulattorFאא
א
64،א
32
3
אא
32א א "0" K
K32 x 27µs of silence
27µss
322 322 x 27µs of silence ،אא
"1"
K27µs
| +---| |---+ |
| | | | | |
| | | | | |
|---+ | | +---|
<-----> <----->
1.7778ms 1.7778ms
Logic 1 Logic 0
RC
C5א
א
אא
א 12
אאא
Practical Class 4 Programming Microcontrollers
Wאא14BitsRC5
Bit1 Bit2 Bit3 Bit4 Bit5 Bit6 Bit7 Bit8 Bit9 Bit10 Bit11 Bit12 Bit13 Bit14
start bits control Address Command
אEStart Bits or AGC "Automatic Gain Control?Fאא WBits1-2 -
KאאאK"1"א
אאא،EControl Bit or Toggle BitF CHECK bitאWBit3 -
אאאKאאאא
،אאא –אאא
אא11אאאאאא
Kאא
אאאא،אאWBits4-8 -
WאאE2^5=32F32،א
SYSTEM ADDRESS EQUIPMENT
0 TV SET 1
1 TV SET 2
2 VIDEOTEXT
3 EXPANSION FOR TV 1 AND 2
4 LASER VIDEO PLAYER
5 VIDEO RECORDER 1 (VCR 1)
6 VIDEO RECORDER 2 (VCR 2)
7 RESERVED
8 SAT 1
9 EXPANSION FOR VCR 1 OR 2
10 SAT 2
11 RESERVED
12 CD VIDEO
13 RESERVED
14 CD PHOTO
15 RESERVED
16 AUDIO PREAMPLIFIER 1
17 RECEIVER / TUNER
18 TAPE / CASSETE RECORDER
19 AUDIO PREAMPLIFIER 2
20 CD
21 AUDIO RACK
22 AUDIO SAT RECEIVER
23 DCC RECORDER
24 RESERVED
25 RESERVED
26 WRITABLE CD
26‐31 RESERVED
Faculty of Electrical and Electronic Eng.
13 Automatic Control & Automation Dept.
אא אא
א
COMMAND (in decimal) DESSCRIPTION of FFUNCTION
0‐9 NUMERIC KEYS 0 ‐
K 9
12 STANDBY
13 MUTE
14 PRESETS
16 VOLUME UP P
17 VOLUME DO OWN
18 BRIGHTNES SS +
19 BRIGHTNES SS ‐
20 COLOR SATTURATION +
21 COLOR SATTURATION ‐
22 BASS UP
23 BASS DOWN N
24 TREBLE +
25 TREBLE ‐
26 BALANCE RRIGHT
27 BALANCE LLEFT
48 PAUSE
50 FAST REVERSE
52 FAST FORWWARD‐
53 PLAY
54 STOP
55 RECORD
63 SYSTEM SELECT
71 DIM LOCALL DISPLAY
77 LINEAR FUN NCTION (+)
78 LINEAR FUN NCTION (‐)
80 STEP UP
81 STEP DOWN N
82 MENU ON
83 MENU OFF
84 DISPLAY A//V SYS STATUSS
85 STEP LEFT
86 STEP RIGHT T
87 ACKNOWLE EDGE
88 PIP ON/OFF F
89 PIP SHIFT
90 PIP MAIN SWWAP
91 STROBE ONN/OFF
92 MULTI STROBE
93 MAIN FROZ ZEN
94 3/9 MULTI SCAN
95 PIP SELECT
T
96 MOSAIC MU ULTI PIP
97 PICTURE DN NR
98 MAIN STORRED
99 PIP STROBE E
100
0 RECALL MA AIN PICTURE
101
1 PIP FREEZEE
102
2 PIP STEP UPP
103
3 PIP STEP DOOWN
118
8 SUB MODE
119
9 OPTIONS BU US MODE
123
3 CONNECT
124
4 DISCONNEC CT
אא
א 14
אאא
Practical Class 4 Programming Microcontrollers
CLRM-2038S IR Module CLRM-2038Sאאא
WאאאאCLRM-2038Sאאא
Kאאא J1
KPCMאאא J2
Kאאא J3
Kאאאא J4
K2.7V~5.5Vא א J5
KTTL, CMOSאאא J6
KNEC code,RC5 codeא J7
K38KHZא J8
Faculty of Electrical and Electronic Eng.
15 Automatic Control & Automation Dept.
אא אא
א
K12m א J9
J10
Wאאאא
•
KEOpticaal switchF
CR, CD, MD, DVD, ettcWא •
KAudio, TV, VC
Air-connditioner, Fan, CATV, etcWא• א
KCLRM--2038Sאא
אא
א
אא
א 16
אאא
Practical Class 4 Programming Microcontrollers
IRSAT Remote Control IRSATא
Wאא
IRSAT RC5 TV Remote Control with 33 KeysW• א
China (mainland) Wא •
AA x 2Wא •
10 metersWא •
K3μ AWStandby current •
17x4.7x2.5cmW• א
IRSAT Remote Control Key Commands IRSATאא
אאא אאא
Wאא
Faculty of Electrical and Electronic Eng.
17 Automatic Control & Automation Dept.
אא אא
א
COMMAN
ND (in Hex) DESCRIPTTION of FUNC
CTION
0
0‐9 NUMEERIC KEYS 0 ‐‐ 9
1
12
1
13
1
14
1
16 VOLLUME UP
1
17 VOLUME DOWN
1
18
1
19
2
20
2
21
22
2 BASS UP
2
23 BA
ASS DOWN
2
24
2
25
2
26
2
27
4
48
5
50
52
5 F1
5
53 F2
5
54 F3
5
55 F4
6
63
7
71
אא
א 18
אאא
Practical Class 4 Programming Microcontrollers
WBascom-AVRאא
א א א א RC5 א א
Kא
Timer1 א א RC5SEND א א א
Kא
$regfile = "m8def.dat" ' specify the used micro
$crystal = 4000000 ' used crystal frequency
Do
Waitms 200
Rc5send Togbit , Address , Command
Loop
End
RC5 Receiver RC5אא
Wאאא
Wאאאאאאא
KBascom-AVRאא
א א א א RC5 א א
Kא
א Timer0אא getrc5אאא
K
Faculty of Electrical and Electronic Eng.
19 Automatic Control & Automation Dept.
אא אא
א
$r
regfile = "m8def.da
at" ' speci
ify the us
sed micro
$c
crystal = 4000000 ' used crystal frequency
f
$b
baud = 19200 ' use b
baud rate
$l
lib "mcsby
yte.lbx"
Co
onfig Rc5 = Pind.2 ' pin
n we want to use fo
or the rec
ceiver inp
put
En
nable Inte
errupts ' ena
able the interrupt
i s
Di
im Address
s As Byte , Command
d As Byte 'rese
erve space
e for variables
Pr
rint "Wait
ting for RC5..."
R
Do
o
Getrc5(ad
ddress , Command)
C ' che
eck if a key
k on the
e remote is
i pressed
d
If Addres
ss = 0 The
en 'we check
c for the TV ad
ddress and
d that is
Comman
nd = Comma
and And &B
B01111111 'clea
ar the tog
ggle bit (
(bit7)
Print Address ; " " ; Command
C
End If
Lo
oop
En
nd
אא
א 20
אאא