e005012.pdf

(2076 KB) Pobierz
000026-UK RC5-sleep
AUDIO &VIDEO
RC5 Sleep Timer
Everything off!
Design by U. Reiser
The well-known ‘sleep’ function in clock radios and television sets switches
off the equipment after a preselected time. However, what good does it do
to put the television into standby mode while the stereo set or DVD player
that is connected to it remains unaffected? The sleep timer described here
sends standby codes to several RC5-compatible devices at the same time.
Function and operation
The circuit shown in Figure 1 allows you to
select the equipment that will be switched on
or off as well as the sleep time, which might
better be called the delay time. The sleep
timer is operated using four pushbutton
switches. The current state of the timer is
indicated by four LEDs, each of which corre-
sponds to 30 minutes of time delay.
In normal operation, these diodes
are enabled for only one second out
of every ten, in order to save energy.
When the ON button is pressed,
pin 4 (MCLR) is pulled from a high
level to a low level. This resets the
processor, which consequently
wakes from the sleep mode. After
the switch-on pulse, the series of
LEDs runs through all possible dis-
play states and finally remains in the
state corresponding to a delay of
two hours. The sleep time count-
down starts at this point.
The operating status indicator D6
is active as long as switch S4 is
pressed. The weaker the light from
this LED, the lower the battery volt-
age. Red LEDs should be used for D1
through D4, but D6 should be a
green or yellow LED. The higher
voltage drop of the latter type makes
it considerably easier to recognise a
drop in the battery voltage than with
the red LEDs used for the time scale
display.
Pressing the DOWN button (S1)
activates the LED scale, which
shows the current delay time for
slightly less than three seconds. If
this button is pressed for longer than
0.75 second, the delay time is
reduced by half an hour every 0.75
second. If it reaches the minimum
time, it jumps back to two hours.
When the DOWN button is released,
the time delay begins, and the dis-
play scale remains lit for another two
seconds.
Naturally, the sleep timer can con-
trol equipment only if it is pointed at
the infrared receiver(s) of equipment
in question. In order to ascertain the
12
Elektor Electronics
5/2000
138911234.037.png
AUDIO &VIDEO
best location for the sleep timer, you
can press the TEST button (S2),
which causes the selected standby
signals to be transmitted. This also
interrupts the sleep time counter.
Pressing the OFF button (S3) puts
the PIC controller into the sleep
mode (not to be confused with the
sleep delay time of the circuit!). At
first the display scale will show the
current delay time, and then it will
count down to zero at an interval of
0.3 second. Following this, the half-
hour LED blinks ten times at a rate
of 5.5 Hz, and the timer then
switches off.
Any desired combination of
equipment that should be switched
off by the sleep timer can be
selected using five jumpers. The
television set is always included in
the group to be switched off.
3V
D 5
C2
R7
R6
R1
100n
C1
K1
14
2 h
47µ
16V
10
9
6
RB0
RB1
RB2
RB3
RB4
MCLR
4
R3
1k
D1
8
7
7
*
IC1
0h5
6
5
8
D 6
R2
1k
4
3
9
18
D2
RA1
PIC16F84
-04/P
*
BT1
2
1
10
1
RA2
RA3
1 h
2
R4
1k
D3
2x 1V5
11
3
RB5
RB6
RB7
RA4
*
12
17
RA0
1h5
13
R5
1k
D4
OSC1
OSC2
*
16
15
5
X1
T1
R8
3k9
***
S2
S3
4MHz
*
BC547
DOWN
TEST
OFF
ON
*
see text
* voir texte
*
zie tekst
*
siehe Text
000026 - 11
Generating the RC5 codes
Figure 1. Circuit diagram of the RC5 sleep timer.
The RC5 signal is generated by
means of several timing loops that
set or clear RA0. Since the shortest
timing interval (one instruction time)
is 1 µs with a 4 MHz clock, the tim-
ing differs slightly from the RC5
standard. The times generated by
the PIC are marked on the timing
diagram shown in Figure 2 . Every
RC5 instruction consists of 14 bits. A
logic 1 (rising edge) is generated by
the calling CALL LO and then CALL
HI in sequence, while a logic 0
(falling edge) is generated by revers-
ing the calling sequence. Bits 6
through 10 form the device address.
In addition to the two Start bits, the
Control bit is always a logic 1. The
Control bit is used to distinguish
between multiple presses of a but-
ton (or contact bounce) and an optical
interruption of the light beam. It
changes its logical state each time a
button is pressed, for which reason
it is also called the toggle bit. How-
ever, since the equipment is
switched on by the ‘normal’ remote
control and switched off by the sleep
timer, it is not possible to correctly
specify the value of the Control bit in
the sleep timer. This does not hurt
anything, as long as the last instruc-
tion sent by the normal remote con-
trol unit was not ‘switch on from
standby’. Even in this case, the
chance of failure is only 50%, since
this only happens if the Control bit
was a 1 the last time it was sent. By
the way, this is also the reason why a
RC5 receiver sometimes cannot
recognise 11, 12 and so on when the
instruction comes from an adaptive
remote control unit.
000026-11 ), or as a ready-programmed PIC
(number 000026-41 ). The program flow is
shown in Figure 3 . The subroutine named
INITIALISATION sets the five bits of Port A
as outputs and the eight bits of Port B as
inputs, sets the prescaler ratio to 1:256 and
connects it in front of the RTCC. At the same
time, the pull-up resistors for all leads of
Port B are activated. Immediately after the
power supply is switched on or a reset
occurs, the routine POWER-ON-SELF-TEST
drives LEDs D1 through D4 sequentially for
0.3 s each. This process is intended to indi-
cate that the circuit is basically in good work-
Software description
The sleep timer is controlled by the
program SLEEP.ASM. This is avail-
able via the Internet from www.elek-
tor-electronics.co.uk , from our Read-
ers Services on a diskette (number
14 bits
25.074
ms
64 bits = 114.624 ms
11
111 011111000
1.791
ms
14 bits = 25.074 ms
1 t p = 7
µ
s
3 tp = 21
µ
s
32 x 4 tp = 896
µ
s
000026 - 12
Figure 2. Timing diagram of the RC5 signals generated by the PIC.
5/2000
Elektor Electronics
13
S1
S4
138911234.038.png 138911234.039.png 138911234.040.png 138911234.001.png 138911234.002.png 138911234.003.png 138911234.004.png 138911234.005.png
AUDIO &VIDEO
initialisation
on is extended by two seconds. If
this button is held for longer than
0.75 second, the program jumps to
the subroutine CHANGE-SLEEP-
TIME. This routine reduces the sleep
time by half an hour every 0.75 sec-
ond, or changes it from 0.5 hour to 2
hours. This process continues until
the DOWN button is released.
The TIMING routine, which is
located next and in two subsequent
places, decrements the counter that
controls switching the delay time
scale LEDs on and off. In addition, it
counts down the counters for the
seconds, minutes and half hours of
the overall running time. If the scale
power-on
selftest
set
start value
check
DOWN -sw
y
scale
on
> 0.7 s
DOWN -sw
y
change
sleep time
n
n
timing
check
TEST -sw
y
transmit
IR tv1
check
jp 1
n
check
jp 2
n
check
jp 3
n
check
jp 4
n
check
jp 5
n
n
y
y
y
y
y
transmit
IR vcr
transmit
IR sat
transmit
IR dvd
transmit
IR cd
transmit
IR combi
y
keys
off
timing
n
COMPONENTS LIST
check
OFF sw
y
clear
scale
flash
d1
sleep
Resistors:
R1 = 10
R2-R6 = 1k
n
R7 = 10k
R8 = 3k
timing
9
000026- 13
Capacitors:
C1 = 47µF 16V radial
C2 = 100nF
Figure 3. Flow chart of the RC5 sleep timer software.
ing order. The routine SET-START-VALUES
loads the starting values into a series of
counter registers that are used for blinking
the delay time scale at a 10-second interval
and for the 4 hour to half an hour time delay
process. After this comes the main program, in
the form of an endless loop consist-
ing of six other routines. The first
action is to poll the DOWN switch. If
it is set, the delay time scale is illu-
minated for two seconds. If the scale
is already on, the time that is stays
Semiconductors:
D1-D4 = low-current LED, red
D5 = low-current LED, green
D6 = LD271 or SFH485 with
reflector
T1 = BC547
IC1 = PIC16F84-04/P,
programmed, order code
000026-41
000026-1
Miscellaneous:
X1 = 4MHz ceramic resonator
(Conrad Electronic #50 31 69)
S1-S4 = miniature pushbutton, 1
make contact, 6 6 mm 2 for
board mounting (Conrad
Electronic #70 04 60, Bourns
#7906H-001-000, Farnell #535-
916)
10-way pinheader, plus up to 5
jumpers
Toko handheld transmitter case
(Conrad Electronics #52 43 44)
Battery holder for 2 ‘Micro’
batteries
PCB, order code 000026-1 *
Disk, order code 000026-11 *
* Price and ordering information
on the Readers Services pages
elsewhere in this issue.
D6
H2
(C) ELEKTOR
R1
T1
off
on
test
down
S3
S4
S2
S1
R6
R7
K1
R3
R4
R5
D1
D5
D4
IC1
D3
C2
D2
C1
000026-1
H4
X1
0
+
Figure 4. Circuit board track and component layouts for a circuit board that fits in the
recommended remote control enclosure.
Conrad Electronics are at
http://www.conrad-electronic.com
14
Elektor Electronics
5/2000
138911234.006.png 138911234.007.png 138911234.008.png 138911234.009.png 138911234.010.png 138911234.011.png 138911234.012.png 138911234.013.png 138911234.014.png 138911234.015.png 138911234.016.png 138911234.017.png 138911234.018.png 138911234.019.png 138911234.020.png 138911234.021.png 138911234.022.png 138911234.023.png 138911234.024.png 138911234.025.png 138911234.026.png 138911234.027.png 138911234.028.png 138911234.029.png 138911234.030.png 138911234.031.png 138911234.032.png 138911234.033.png 138911234.034.png 138911234.035.png
AUDIO &VIDEO
register has timed out, the program
generates the RC5 codes and the
processor finishes its job with a
Sleep instruction.
If the overall running time has not
timed out, the TEST button is next
polled. If it is pressed, the RC5 code
for TV1 is sent first. After this,
jumper JP1 is polled. The code for
VCR1 may then be send, depending
on the jumper setting. The same
process is repeated for the other four
jumpers.
The TEST routine can exit via the
KEYSOFF subroutine only after S2
has been released. This means that
only one infrared signal output can
occur each time the button is
pressed, which increases the life of
the batteries. The TIMING subrou-
tine is now executed once again.
The following routine, CHECK-
OFF-SWITCH, monitors the state of
the OFF switch S3. If this is pressed,
the delay time scale is visually
decreased from its present value to
0.5 hour, and LED D1 then blinks ten
times. After this the program stops
early with a Sleep instruction.
If the STOP button is not
pressed, the TIMING rou-
tine is executed once
again, and the program
then jumps back to testing
the DOWN button.
1.5 mA. The pulse code of the RC5
signal is amplified by transistor T1
and passed to the IR LED. Two 1.5-V
batteries are used as the power
source. According to the manufac-
turer, the PIC will work down to a
voltage of 2 V, but in our tests it still
worked at a voltage of 1.8 V. This
means that you can milk the very
last milliwatt-second out of the bat-
teries. With a supply voltage of 2.5 V,
the current consumption of the RC5
sleep timer is 1.22 mA with the scale
diodes on and 0.4 mA when they are
dark. In the PIC sleep mode, it is
only 30 µA.
Table 1. Equipment codes
Jp Device
1
VCR1 (video recorder 1)
2
CD (compact disc player)
3
DVD (compact video disc player)
4
SAT1 (satellite TV receiver 1)
5
Combi (stereo set)
mounting height of the pushbutton switches
should be adjusted to match the key caps.
Five holes must be drilled in the enclosure for
the 3-mm LEDs. Their mounting height is also
important. The 5-mm IR LED protrudes
through a hole at the top of the enclosure and
is connected to the circuit board by flexible
wire. In the lower part of the enclosure, there
is a battery compartment that can hold two
penlight cells (AAA) with a battery clip. You
can also use mignon cells (AA), but without
a clip.
Packaging
Although the printed circuit board
for the sleep timer shown in Figure
4 is one-sided, switches S1 through
S4 and LEDs D1 through D5 are
mounted on the copper side of the
board, so that that the controls and
indicators are all on one side of the
board. The remote control enclosure
suggested in the components list
already includes four key caps. The
(000026-1)
Hardware
With the use of a PIC
processor, the number of
components for the circuit
is kept to an absolute min-
imum. A 4-MHz resonator
with integrated capacitors
is used to control the clock
frequency of the processor.
The reset input of IC1 is
connected to the positive
supply line via resistor R7.
The ON button (S4) gener-
ates a processor reset. LED
D6 also receives its nega-
tive supply voltage via S4.
Buttons S1 through S3 and
all the jumpers (see Table
1 ) are connected to Port B,
which provides internal
pull-up resistors. The indi-
cator scale LEDs are driven
via RA1 through RA4. Red
low-current LEDs are used
to reduce the current to
5/2000
Elektor Electronics
15
138911234.036.png
Zgłoś jeśli naruszono regulamin