VTech Alphabert s Magic Readport User Manual Page 66

  • Download
  • Add to my manuals
  • Print
  • Page
    / 80
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 65
Lab Manual of Microcontroller & Interfacing Page 66
pulses decreases when we press the switch SW2. This will control speed of the motor. Transistor
acts as a switch which becomes ON when port pin P1.1 is set and becomes OFF when port pin
P1.1 is reset.
Program:
ORG 00h
SJMP START
ORG 03h
INC B ; Increase R7 to increase width of pulse
RETI
ORG 13h
DEC B ;Decrease R7 to decrease width of pulse
RETI
START: MOV IE,#85h ; Enable external interrupt 0 and 1
SETB IT0 ; Negative edge triggered interrupt
SETB IT1 ;Negative edge triggered interrupt
CLR P1.1 ; Make P1.1 output pin
MOV B,#80h ; Initial speed
next: SETB P1.0
ACALL ON_delay ; Call delay for ON time
CLR P1.0 ; Complement P1.0 to generate square wave
ACALL OFF_delay ; Call delay for OFF time
SJMP next
OFF_delay:
MOV R4,#00h
L1: DJNZ R4, L1
RET
ON_delay:
MOV R7,B ; Load count value from register B
L3: MOV R6,#0FFh
L2: DJNZ R6, L2 ; Decrement R6 until it becomes zero
DJNZ R7,L3
NOP ; No operation
RET ; Return to main routine
END
Optical isolation:
It is better to use opto-isolator between motor circuit and microcontroller because it will
protect microcontroller from EMI created by the motor brushes. If motor voltage rating is higher
than the voltage used for microcontroller then opto-isolator prevents damage to the
microcontroller by providing optical isolation. If there is any fault in motor circuit or power
supply, microcontroller is safe. Modified circuit using optoisolator is shown below:
Page view 65
1 2 ... 61 62 63 64 65 66 67 68 69 70 71 ... 79 80

Comments to this Manuals

No comments