SlideShare ist ein Scribd-Unternehmen logo
1 von 20
Downloaden Sie, um offline zu lesen


      

                     ‫ﺍﻟﺘﺠﺎﺭﺏ ﺍﻟﻌﻤﻠﻴﺔ‬

                   

                          




                          




                   Programming
      Embedded Systems Microcontroller

You Can Practice Microcontroller Programming Easily Now!
      WALID BALID, Tuesday, December 15, 2009
                                                                              

Exp.10: Shift & Rotate Instructions                            


                                                                                        
                                                 Rotate Shift
                                                                                         




 
                                                                                         
Shift Right S6
                                                        Shift LeftS7
 S14 Rotate Right  S13
                                                                                         Rotate Right
                                                                                       
                                                .Jumper JP9 JP6
                                                                                                             

                      72                          
Practical Class 4                                                           Programming Microcontrollers

                                                                                    
                                                      
                                                             
  Shift var , Right/Left [, shift]
                                                             [, shift]
                                                             
Rotate var , Right/Left [, rotate]
                                                             [, shift]
                                                                                  
$regfile = "m128def.dat"
$crystal = 8000000                                                        
'---------------------
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
                                                           
Shift_r      Alias     Pine.4                                               
Shift_l      Alias     Pine.5
Rotat_r      Alias     Pine.6
Rotat_l      Alias     Pine.7

Config Portd = Output
Leds Alias Portd
Portd = &B00000001
'---------------------
Do
   Debounce Shift_r , 0 , Sr , Sub
   Debounce Shift_l , 0 , Sl , Sub
   Debounce Rotat_r , 0 , Rr , Sub           
   Debounce Rotat_l , 0 , Rl , Sub
Loop
End
'---------------------
Sr:
   If Leds > 1 Then Shift Leds , Right , 1
Return
'---------------------
Sl:
   If Leds < 128 Then Shift Leds , Left , 1
Return
'---------------------                                        
Rr:
   Rotate Leds , Right , 1
Return
'---------------------
Rl:
   Rotate Leds , Left , 1
Return
'---------------------


Faculty of Electrical and Electronic Eng.       73                   Automatic Control & Automation Dept.
                                                                          

      Exp.11: Get RC Value                                 


                                                                                          
                                                 
                                                                                           




 


                                                                                           
                 
                                            Getrc
                                                                                                               
                                                                                         
             SW2.Jumper JP14


                                                                                                               


                         74                         
Practical Class 4                                                     Programming Microcontrollers

                                                                               
                                              
                                            
                                                 pinx   y
        var = Getrc(pinx , y)
                                            
                                                             
                                                                                                  
                                                                           
$regfile = "m128def.dat"
$crystal = 8000000                                                  
'----------------------
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
'----------------------
Dim Rc_var As Word                                               
'----------------------
Cls : Cursor Off
Lcd "RC Val= "
Do
   Rc_var = Getrc(ping , 2)
   Locate 1 , 9                                               
   Lcd Rc_var
                                                                         
   Waitms 1000
   Locate 1 , 8 : Lcd Spc(7)
Loop

End

                                                                                                  




Faculty of Electrical and Electronic Eng.   75                 Automatic Control & Automation Dept.
                                                                          

      Exp.12: IR receiver, RC5-code                  RC5IR 


                                                                                          
            .RC5, RC5-ExtendedCLRM-2038S

                                                                                           




 
                                                                                           
                 
                                                                                     .RC5
                                                                                         
             SW2.Jumper JP18
                                                                                         


                          76                        
Practical Class 4                                                      Programming Microcontrollers

                                              
           Config        Rc5 = Pinb.7                IR
        Getrc5(address , Command)                        
                                                                            
$regfile = "m128def.dat"
$crystal = 8000000                                                   
'---------------------
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
'---------------------
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              TV
      Cls
       Lcd "Command is: " ; Command                  
      Waitms 50                                        
   End If
Return
'---------------------

                                                                                                  




Faculty of Electrical and Electronic Eng.   77                  Automatic Control & Automation Dept.
                                                                            

      Exp.13: IR transmi er, RC5-code                     RC5IR 


                                                                                            
                                                   RC5
                                                                                              




 
                                                                                              
      RC5,              
                                     RC5-Extended
                                                                                           
                SW2.Jumper JP17
                                                                                           
                                       
                                                           
                                                                
 Rc5send          Togbit , Address , Command
                                                                                 RC5OC1A
                            78                        
Practical Class 4                                                     Programming Microcontrollers

                                                                           
$regfile = "m128def.dat"
$crystal = 8000000                                                  
'---------------------
Config Debounce = 200
                                                     
Config Pine.4 = Input
Porte.4 = 1
'---------------------
Dim Togbit As Byte , Command As Byte ,
Address As Byte
                                                                 
Command = 12                                                  
Togbit = 0
Address = 0
'---------------------
Do
                                                   
   Debounce Pine.4 , 0 , Pwr_cmd , Sub
Loop                                               OC1A pin 
                                                                         
End
'---------------------

Pwr_cmd:
   Rc5send Togbit , Address , Command            
   Waitms 200
Return                                                         
'-------------


                                                                                                  
                                  




Faculty of Electrical and Electronic Eng.   79                Automatic Control & Automation Dept.
                                                                                 

Appendix: Exp.12 and Exp.13                                            


                       RC5-code
                               Detailed Article about Remote Control and IR Module

What is infrared?                                                              

 950nm
                                                             



                          
               

               
               
                                                 

              

                                    Address
36KHZ 30KHZ – 60KHZ
36KHZ, 38KHZ38KHZ
 36~38
                  
          36KHZ, 38KHZ    

              

                           80                        
Practical Class 4                                                                   Programming Microcontrollers

              
  27uS     36KHZ         
                21




                                                                
                      1                                               2
                            

What is IR Transmiting pr ot ocol s?
                  t                                        
RC5 SIRCS NEC          
          Sony SAMSUNG JAPAN
                                                                                               Waveforms

RC5 Transmi ing protocols?                                                                   RC5
14       RC5      
1.728mS
                                                        130mS
                                             
                                                                       Address Length -
                                                              Command Length -
                                                                   Carrier Frequency  -
                                                                  Start Bit -
                                              High-Bit-Time"1" -
                                               Low-Bit-Time"0" -
                                                                   


Faculty of Electrical and Electronic Eng.                   81                Automatic Control & Automation Dept.
                                                                              

 
                                                   




                                  
 
 
                                                     
  27µs
 demodulator
 6432
 32 "0"
                                                32 x 27µs of silence27µs
  32 32 x 27µs of silence "1"
                                                                                        27µs




                           
                             |   +---|                                 |---+   |
                             |   |   |                                 |   |   |
                             |   |   |                                 |   |   |
                             |---+   |                                 |   +---|
                              <----->                                   <----->
                              1.7778ms                                 1.7778ms
                              Logic 1                                   Logic 0
                                                                                                               




 
                                   RC5

                          82                        
Practical Class 4                                                                   Programming Microcontrollers

                                               14BitsRC5
  Bit1   Bit2     Bit3      Bit4      Bit5 Bit6 Bit7 Bit8 Bit9 Bit10 Bit11 Bit12 Bit13 Bit14
   start bits   control                     Address                           Command
 Start Bits or AGC "Automatic Gain Control Bits1-2 -
                                    "1"
 Control Bit or Toggle Bit CHECK bitBit3 -
 
 –
 11
                                                                         
 Bits4-8 -
                             2^5=3232
                          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.                    83               Automatic Control & Automation Dept.
                                                                                        

 Bits9-14 -
 2^6=64  64
                                                        

                               COMMAND (in decimal)           DESCRIPTION of FUNCTION
                                       0-9            NUMERIC KEYS 0 - 9
                                       12             STANDBY
                                       13             MUTE
                                       14             PRESETS
                                       16             VOLUME UP
                                       17             VOLUME DOWN
                                       18             BRIGHTNESS +
                                       19             BRIGHTNESS -
                                       20             COLOR SATURATION +
                                       21             COLOR SATURATION -
                                       22             BASS UP
                                       23             BASS DOWN
                                       24             TREBLE +
                                       25             TREBLE -
                                       26             BALANCE RIGHT
                                       27             BALANCE LEFT
                                       48             PAUSE
                                       50             FAST REVERSE
                                       52             FAST FORWARD-
                                       53             PLAY
                                       54             STOP
                                       55             RECORD
                                       63             SYSTEM SELECT
                                       71             DIM LOCAL DISPLAY
                                       77             LINEAR FUNCTION (+)
                                       78             LINEAR FUNCTION (-)
                                       80             STEP UP
                                       81             STEP DOWN
                                       82             MENU ON
                                       83             MENU OFF
                                       84             DISPLAY A/V SYS STATUS
                                       85             STEP LEFT
                                       86             STEP RIGHT
                                       87             ACKNOWLEDGE
                                       88             PIP ON/OFF
                                       89             PIP SHIFT
                                       90             PIP MAIN SWAP
                                       91             STROBE ON/OFF
                                       92             MULTI STROBE
                                       93             MAIN FROZEN
                                       94             3/9 MULTI SCAN
                                       95             PIP SELECT
                                       96             MOSAIC MULTI PIP
                                       97             PICTURE DNR
                                       98             MAIN STORED
                                       99             PIP STROBE
                                       100            RECALL MAIN PICTURE
                                       101            PIP FREEZE
                                       102            PIP STEP UP
                                       103            PIP STEP DOWN
                                       118            SUB MODE
                                       119            OPTIONS BUS MODE
                                       123            CONNECT
                                       124            DISCONNECT




                             84                             
Practical Class 4                                                                Programming Microcontrollers

Interfacing IR Receiver to uC.                                             IR 
      uPuC
 "0"=On | "1" = off–  1
                            "1"inactivity  2
  3
              
                                                                            14
  4

4.752mS
1.728mS
                                                                       




                                                   
CLRM-2038S IR Module                                             CLRM-2038S
       CLRM-2038S
                                              1
                                            PCM  2
                                                               3
                                                 4
                                               2.7V~5.5V  5
                                                  TTL, CMOS  6
                                                             NEC code,RC5 code  7
                                                                             38KHZ  8
Faculty of Electrical and Electronic Eng.               85                 Automatic Control & Automation Dept.
                                                                                 

                                                                               12m  9
                                                                  10
                                                                        Optical switch ·
                             Audio, TV, VCR, CD, MD, DVD, etc ·
                                          Air-conditioner, Fan, CATV, etc ·




      Pins Confg. & Int ernal D agram
              i               i                                       CLRM-2038S
                                                          CLRM-2038S




 
                                                                                                                      
                                      CLRM-2038S




                                                                     
                                                                                       
                                   86                      
Practical Class 4                                                                Programming Microcontrollers

Rc5 receiver interface                                               
4.7uF

                                                                                                   
                                                                                                            




 
                                                        
IRSAT Remote Control                                                                   IRSAT
                                                                                            
                                             IRSAT RC5 TV Remote Control with 33 Keys ·
                                                                    China (mainland)  ·
                                                                           AA x 2 ·
                                                                         10 meters ·
                                                                         3μ AStandby current ·
                                                                            17x4.7x2.5cm ·
                                                                                                            
IRSAT Remote Control Key Commands                                       IRSAT
 
                                                     




Faculty of Electrical and Electronic Eng.                    87            Automatic Control & Automation Dept.
                                                                    

      COMMAND (in Hex)            DESCRIPTION of FUNCTION
           0-9                       NUMERIC KEYS 0 - 9
           12
           13
           14
           16                          VOLUME UP
           17                         VOLUME DOWN
               18

               19
               20

               21

               22                        BASS UP
               23                       BASS DOWN
               24

               25

               26

               27

               48

               50
               52                            F1
               53                            F2
               54                            F3
               55                            F4
               63
               71



 RC5 Sender                                                           RC5
 OC1(A)




                      

                  88                     
Practical Class 4                                                            Programming Microcontrollers


                                                                 Bascom-AVR
        RC5      
                                                                                               
  Timer1     RC5SEND     
                                                                                  
$regfile = "m8def.dat"                                   ' specify the used micro
$crystal = 4000000                                       ' used crystal frequency

Dim Togbit As Byte , Command As Byte , Address As Byte

Command = 12                                             ' power on off
Togbit = 0                                               ' make it 0 or 32 to set the toggle bit
Address = 0

Do
   Waitms 200
   Rc5send Togbit , Address , Command
Loop

End


RC5 Receiver                                                              RC5
                                                                               
            




                                      
                                                                                                        
                                                                 Bascom-AVR
        RC5      
                                                                                             
 Timer0 getrc5
                                                                                                    
                                                                                                        
Faculty of Electrical and Electronic Eng.           89                 Automatic Control & Automation Dept.
                                                                

$regfile = "m8def.dat"                                      ' specify the used micro
$crystal = 4000000                                          ' used crystal frequency
$baud = 19200                                               ' use baud rate
$lib "mcsbyte.lbx"

Config Rc5 = Pind.2                        ' pin we want to use for the receiver input

Enable Interrupts                          ' enable the interrupts
Dim Address As Byte , Command As Byte      'reserve space for variables

Print "Waiting for RC5..."

Do
  Getrc5(address , Command)                ' check if a key on the remote is pressed

  If Address = 0 Then                      'we check for the TV address and that is
     Command = Command And &B01111111      'clear the toggle bit (bit7)
     Print Address ; " " ; Command
  End If
Loop
End




                                Red: AGC pulses (ON)
                               Blue: Check bit (flipping)
                                 White: Address (00)
                                  Green: Command




               90                   

Weitere ähnliche Inhalte

Andere mochten auch

Embedded System Microcontroller Interactive Course using BASCOM-AVR -Lecture7
Embedded System Microcontroller Interactive Course using BASCOM-AVR -Lecture7Embedded System Microcontroller Interactive Course using BASCOM-AVR -Lecture7
Embedded System Microcontroller Interactive Course using BASCOM-AVR -Lecture7AL-AWAIL for Electronic Engineering
 
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture6
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture6Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture6
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture6AL-AWAIL for Electronic Engineering
 
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture9
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture9Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture9
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture9AL-AWAIL for Electronic Engineering
 
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture11
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture11Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture11
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture11AL-AWAIL for Electronic Engineering
 
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture10
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture10Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture10
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture10AL-AWAIL for Electronic Engineering
 
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture...
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture...Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture...
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture...AL-AWAIL for Electronic Engineering
 
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture12
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture12Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture12
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture12AL-AWAIL for Electronic Engineering
 
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture8
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture8Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture8
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture8AL-AWAIL for Electronic Engineering
 
Embedded System Microcontroller Interactive Course using BASCOM-AVR -Lecture5
Embedded System Microcontroller Interactive Course using BASCOM-AVR -Lecture5Embedded System Microcontroller Interactive Course using BASCOM-AVR -Lecture5
Embedded System Microcontroller Interactive Course using BASCOM-AVR -Lecture5AL-AWAIL for Electronic Engineering
 

Andere mochten auch (9)

Embedded System Microcontroller Interactive Course using BASCOM-AVR -Lecture7
Embedded System Microcontroller Interactive Course using BASCOM-AVR -Lecture7Embedded System Microcontroller Interactive Course using BASCOM-AVR -Lecture7
Embedded System Microcontroller Interactive Course using BASCOM-AVR -Lecture7
 
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture6
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture6Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture6
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture6
 
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture9
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture9Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture9
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture9
 
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture11
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture11Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture11
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture11
 
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture10
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture10Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture10
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture10
 
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture...
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture...Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture...
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture...
 
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture12
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture12Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture12
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture12
 
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture8
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture8Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture8
Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture8
 
Embedded System Microcontroller Interactive Course using BASCOM-AVR -Lecture5
Embedded System Microcontroller Interactive Course using BASCOM-AVR -Lecture5Embedded System Microcontroller Interactive Course using BASCOM-AVR -Lecture5
Embedded System Microcontroller Interactive Course using BASCOM-AVR -Lecture5
 

Ähnlich wie Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture4

Automatic light project
Automatic light projectAutomatic light project
Automatic light projectkspece0928
 
2.3 sequantial logic circuit
2.3 sequantial logic circuit2.3 sequantial logic circuit
2.3 sequantial logic circuitWan Afirah
 
netfilter and iptables
netfilter and iptablesnetfilter and iptables
netfilter and iptablesKernel TLV
 
Java SE 7、そしてJava SE 8
Java SE 7、そしてJava SE 8Java SE 7、そしてJava SE 8
Java SE 7、そしてJava SE 8Yuichi Sakuraba
 
Day4 Lab
Day4 LabDay4 Lab
Day4 LabRon Liu
 
Twin wheeler modified for arduino simplified serial protocol to sabertooth v21
Twin wheeler modified for arduino simplified serial protocol to sabertooth v21Twin wheeler modified for arduino simplified serial protocol to sabertooth v21
Twin wheeler modified for arduino simplified serial protocol to sabertooth v21josnihmurni2907
 
Example MVS Console Interface
Example MVS Console InterfaceExample MVS Console Interface
Example MVS Console InterfaceDavid Young
 

Ähnlich wie Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture4 (8)

Automatic light project
Automatic light projectAutomatic light project
Automatic light project
 
2.3 sequantial logic circuit
2.3 sequantial logic circuit2.3 sequantial logic circuit
2.3 sequantial logic circuit
 
netfilter and iptables
netfilter and iptablesnetfilter and iptables
netfilter and iptables
 
Java SE 7、そしてJava SE 8
Java SE 7、そしてJava SE 8Java SE 7、そしてJava SE 8
Java SE 7、そしてJava SE 8
 
Day4 Lab
Day4 LabDay4 Lab
Day4 Lab
 
Twin wheeler modified for arduino simplified serial protocol to sabertooth v21
Twin wheeler modified for arduino simplified serial protocol to sabertooth v21Twin wheeler modified for arduino simplified serial protocol to sabertooth v21
Twin wheeler modified for arduino simplified serial protocol to sabertooth v21
 
Example MVS Console Interface
Example MVS Console InterfaceExample MVS Console Interface
Example MVS Console Interface
 
PhD thesis defense
PhD thesis defensePhD thesis defense
PhD thesis defense
 

Kürzlich hochgeladen

fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Shubhangi Sonawane
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docxPoojaSen20
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docxPoojaSen20
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin ClassesCeline George
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...KokoStevan
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.MateoGardella
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfChris Hunter
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 

Kürzlich hochgeladen (20)

fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 

Embedded System Microcontroller Interactive Course using BASCOM-AVR - Lecture4

  • 1.    ‫ﺍﻟﺘﺠﺎﺭﺏ ﺍﻟﻌﻤﻠﻴﺔ‬     Programming Embedded Systems Microcontroller You Can Practice Microcontroller Programming Easily Now! WALID BALID, Tuesday, December 15, 2009
  • 2.     Exp.10: Shift & Rotate Instructions      Rotate Shift       Shift Right S6  Shift LeftS7  S14 Rotate Right  S13  Rotate Right    .Jumper JP9 JP6    72 
  • 3. Practical Class 4 Programming Microcontrollers                  Shift var , Right/Left [, shift]  [, shift]          Rotate var , Right/Left [, rotate]  [, shift]   $regfile = "m128def.dat" $crystal = 8000000   '--------------------- 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  Shift_r Alias Pine.4   Shift_l Alias Pine.5 Rotat_r Alias Pine.6 Rotat_l Alias Pine.7 Config Portd = Output Leds Alias Portd Portd = &B00000001 '--------------------- Do Debounce Shift_r , 0 , Sr , Sub Debounce Shift_l , 0 , Sl , Sub Debounce Rotat_r , 0 , Rr , Sub   Debounce Rotat_l , 0 , Rl , Sub Loop End '--------------------- Sr: If Leds > 1 Then Shift Leds , Right , 1 Return '--------------------- Sl: If Leds < 128 Then Shift Leds , Left , 1 Return '---------------------   Rr: Rotate Leds , Right , 1 Return '--------------------- Rl: Rotate Leds , Left , 1 Return '--------------------- Faculty of Electrical and Electronic Eng. 73 Automatic Control & Automation Dept.
  • 4.     Exp.11: Get RC Value                              Getrc      SW2.Jumper JP14    74 
  • 5. Practical Class 4 Programming Microcontrollers               pinx   y  var = Getrc(pinx , y)        $regfile = "m128def.dat" $crystal = 8000000   '---------------------- 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 '---------------------- Dim Rc_var As Word   '---------------------- Cls : Cursor Off Lcd "RC Val= " Do Rc_var = Getrc(ping , 2) Locate 1 , 9   Lcd Rc_var   Waitms 1000 Locate 1 , 8 : Lcd Spc(7) Loop End   Faculty of Electrical and Electronic Eng. 75 Automatic Control & Automation Dept.
  • 6.     Exp.12: IR receiver, RC5-code  RC5IR    .RC5, RC5-ExtendedCLRM-2038S                       .RC5    SW2.Jumper JP18    76 
  • 7. Practical Class 4 Programming Microcontrollers        Config Rc5 = Pinb.7 IR Getrc5(address , Command)     $regfile = "m128def.dat" $crystal = 8000000   '--------------------- 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 '--------------------- 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  TV Cls Lcd "Command is: " ; Command  Waitms 50   End If Return '---------------------   Faculty of Electrical and Electronic Eng. 77 Automatic Control & Automation Dept.
  • 8.     Exp.13: IR transmi er, RC5-code  RC5IR     RC5       RC5,                RC5-Extended   SW2.Jumper JP17                    Rc5send Togbit , Address , Command RC5OC1A  78 
  • 9. Practical Class 4 Programming Microcontrollers   $regfile = "m128def.dat" $crystal = 8000000   '--------------------- Config Debounce = 200   Config Pine.4 = Input Porte.4 = 1 '--------------------- Dim Togbit As Byte , Command As Byte , Address As Byte   Command = 12   Togbit = 0 Address = 0 '--------------------- Do  Debounce Pine.4 , 0 , Pwr_cmd , Sub Loop   OC1A pin    End '--------------------- Pwr_cmd: Rc5send Togbit , Address , Command  Waitms 200 Return   '-------------     Faculty of Electrical and Electronic Eng. 79 Automatic Control & Automation Dept.
  • 10.     Appendix: Exp.12 and Exp.13   RC5-code Detailed Article about Remote Control and IR Module What is infrared?     950nm                                                                          Address 36KHZ 30KHZ – 60KHZ 36KHZ, 38KHZ38KHZ  36~38             36KHZ, 38KHZ                      80 
  • 11. Practical Class 4 Programming Microcontrollers                  27uS     36KHZ           21      1  2   What is IR Transmiting pr ot ocol s? t    RC5 SIRCS NEC                     Sony SAMSUNG JAPAN  Waveforms RC5 Transmi ing protocols? RC5 14       RC5       1.728mS  130mS   Address Length - Command Length - Carrier Frequency  - Start Bit - High-Bit-Time"1" - Low-Bit-Time"0" -    Faculty of Electrical and Electronic Eng. 81 Automatic Control & Automation Dept.
  • 12.               27µs demodulator 6432 32 "0"  32 x 27µs of silence27µs  32 32 x 27µs of silence "1"  27µs   | +---| |---+ | | | | | | | | | | | | | |---+ | | +---| <-----> <-----> 1.7778ms 1.7778ms Logic 1 Logic 0      RC5  82 
  • 13. Practical Class 4 Programming Microcontrollers  14BitsRC5   Bit1   Bit2 Bit3 Bit4 Bit5 Bit6 Bit7 Bit8 Bit9 Bit10 Bit11 Bit12 Bit13 Bit14   start bits   control   Address   Command Start Bits or AGC "Automatic Gain Control Bits1-2 - "1" Control Bit or Toggle Bit CHECK bitBit3 -  – 11  Bits4-8 - 2^5=3232 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. 83 Automatic Control & Automation Dept.
  • 14.      Bits9-14 -  2^6=64  64  COMMAND (in decimal) DESCRIPTION of FUNCTION 0-9 NUMERIC KEYS 0 - 9 12 STANDBY 13 MUTE 14 PRESETS 16 VOLUME UP 17 VOLUME DOWN 18 BRIGHTNESS + 19 BRIGHTNESS - 20 COLOR SATURATION + 21 COLOR SATURATION - 22 BASS UP 23 BASS DOWN 24 TREBLE + 25 TREBLE - 26 BALANCE RIGHT 27 BALANCE LEFT 48 PAUSE 50 FAST REVERSE 52 FAST FORWARD- 53 PLAY 54 STOP 55 RECORD 63 SYSTEM SELECT 71 DIM LOCAL DISPLAY 77 LINEAR FUNCTION (+) 78 LINEAR FUNCTION (-) 80 STEP UP 81 STEP DOWN 82 MENU ON 83 MENU OFF 84 DISPLAY A/V SYS STATUS 85 STEP LEFT 86 STEP RIGHT 87 ACKNOWLEDGE 88 PIP ON/OFF 89 PIP SHIFT 90 PIP MAIN SWAP 91 STROBE ON/OFF 92 MULTI STROBE 93 MAIN FROZEN 94 3/9 MULTI SCAN 95 PIP SELECT 96 MOSAIC MULTI PIP 97 PICTURE DNR 98 MAIN STORED 99 PIP STROBE 100 RECALL MAIN PICTURE 101 PIP FREEZE 102 PIP STEP UP 103 PIP STEP DOWN 118 SUB MODE 119 OPTIONS BUS MODE 123 CONNECT 124 DISCONNECT  84 
  • 15. Practical Class 4 Programming Microcontrollers Interfacing IR Receiver to uC. IR   uPuC "0"=On | "1" = off–  1 "1"inactivity  2   3                14   4  4.752mS 1.728mS    CLRM-2038S IR Module CLRM-2038S  CLRM-2038S   1 PCM  2   3   4 2.7V~5.5V  5 TTL, CMOS  6 NEC code,RC5 code  7 38KHZ  8 Faculty of Electrical and Electronic Eng. 85 Automatic Control & Automation Dept.
  • 16.     12m  9   10 Optical switch · Audio, TV, VCR, CD, MD, DVD, etc · Air-conditioner, Fan, CATV, etc · Pins Confg. & Int ernal D agram i i   CLRM-2038S CLRM-2038S      CLRM-2038S         86 
  • 17. Practical Class 4 Programming Microcontrollers Rc5 receiver interface  4.7uF          IRSAT Remote Control   IRSAT   IRSAT RC5 TV Remote Control with 33 Keys ·   China (mainland)  · AA x 2 · 10 meters · 3μ AStandby current · 17x4.7x2.5cm ·   IRSAT Remote Control Key Commands   IRSAT    Faculty of Electrical and Electronic Eng. 87 Automatic Control & Automation Dept.
  • 18.     COMMAND (in Hex) DESCRIPTION of FUNCTION 0-9 NUMERIC KEYS 0 - 9 12 13 14 16 VOLUME UP 17 VOLUME DOWN 18 19 20 21 22 BASS UP 23 BASS DOWN 24 25 26 27 48 50 52 F1 53 F2 54 F3 55 F4 63 71 RC5 Sender   RC5  OC1(A)    88 
  • 19. Practical Class 4 Programming Microcontrollers  Bascom-AVR         RC5           Timer1     RC5SEND        $regfile = "m8def.dat" ' specify the used micro $crystal = 4000000 ' used crystal frequency Dim Togbit As Byte , Command As Byte , Address As Byte Command = 12 ' power on off Togbit = 0 ' make it 0 or 32 to set the toggle bit Address = 0 Do Waitms 200 Rc5send Togbit , Address , Command Loop End RC5 Receiver   RC5          Bascom-AVR         RC5          Timer0 getrc5     Faculty of Electrical and Electronic Eng. 89 Automatic Control & Automation Dept.
  • 20.     $regfile = "m8def.dat" ' specify the used micro $crystal = 4000000 ' used crystal frequency $baud = 19200 ' use baud rate $lib "mcsbyte.lbx" Config Rc5 = Pind.2 ' pin we want to use for the receiver input Enable Interrupts ' enable the interrupts Dim Address As Byte , Command As Byte 'reserve space for variables Print "Waiting for RC5..." Do Getrc5(address , Command) ' check if a key on the remote is pressed If Address = 0 Then 'we check for the TV address and that is Command = Command And &B01111111 'clear the toggle bit (bit7) Print Address ; " " ; Command End If Loop End Red: AGC pulses (ON) Blue: Check bit (flipping) White: Address (00) Green: Command  90 