![background image](http://html2.mh-extra.com/html/rabbit/2000/2000_user-manual_3110256049.webp)
User’s Manual
43
4.1.1 Pulse Width Modulation to Reduce Relay Power
Typically relays need far less current to hold them closed than is needed to initially close
them. For example, if the driver is switched to a 75% duty cycle using pulse width modu-
lation after the initial period when the relay armature is picked, the holding current will be
approximately 75% of the full duty-cycle current and the power consumption will be
about 56% as great.
The pulse width modulation rate may be from 5 kHz to 20 kHz. If a periodic interrupt is
established that interrupts every 50 µs, then a 50% duty cycle could be set up for a 100 µs
period. A 25%, 50% or 75% duty cycle could operate on a 200 µs period. A 250 µs period
would allow duty cycles of 20%, 40%, 60% or 80%. The code for such an interrupt routine
might appear as follows.
push af ; 10
push hl
push de
ld hl,(ptr) ; 11 get pointer to location in array
ld a,(maskand) ; 9 get mask
and a,(hl) ; 5 get current output
ld e,a ; 2
ld a,(maskor) ; 9
or a,e ; 2
ioi ld (port),a ; 13 store in port
inc hl ; 2 point to next
ld a,(hl) ; 5 check for end of array
or a,a ; 2
jr nz,step2 ; 2
ld hl,(beginptr); 11 reset hl to start of array
step2:
ld (ptr),hl ; 13 save hl
pop de ;7
pop hl
pop af
reti ; 7 return from interrupt
; 153 clocks total worst case - 7.5 us at 20 MHz
This routine would take approximately 15% of the processor’s compute time assuming
50 µs between interrupts. This routine could be speeded up, but at the expense becoming
more complicated. Instead of "and" and "or" masks, a higher level routine could modify
the array directly, and the end of the array could be detected by testing a bit pattern in HL.
The higher level routine would have to suppress the interrupt while changing the bit pat-
tern in the array, or otherwise prevent erratic outputs while the array is being changed. If
the relay emits a whistle at the period of the modulation, the acoustic energy can be spread
out over the spectrum by periodically missing an "off" pulse, creating a phase shift of
180°. A faster routine that executes in two-thirds the time is shown below.
Summary of Contents for 2000
Page 1: ...Rabbit 2000 Microprocessor User s Manual 019 0069 041018 M...
Page 12: ...6 Rabbit 2000 Microprocessor...
Page 46: ...40 Rabbit 2000 Microprocessor...
Page 54: ...48 Rabbit 2000 Microprocessor...
Page 76: ...70 Rabbit 2000 Microprocessor...
Page 96: ...90 Rabbit 2000 Microprocessor...
Page 142: ...136 Rabbit 2000 Microprocessor...
Page 154: ...148 Rabbit 2000 Microprocessor...
Page 170: ...164 Rabbit 2000 Microprocessor...
Page 174: ...168 Rabbit 2000 Microprocessor...
Page 180: ...174 Rabbit 2000 Microprocessor...
Page 202: ...196 Rabbit 2000 Microprocessor...
Page 206: ...200 Rabbit 2000 Microprocessor...
Page 226: ......
Page 230: ...224 Rabbit 2000 Microprocessor...