e015030.PDF

(239 KB) Pobierz
GENERAL INTEREST
Major-Domo
a 16-channel microcontroller-driven switching clock
Design by H. Vos
The switching clock described here can control up to 16 channels and has
20 memories for individual switching times, each of which may apply to
multiple days of the week. This clock has a very easy to operate, 4-button
user interface. Monitoring of the outputs via an RS232 port is also possi-
ble. The ‘brains’ consist of an AT90S8515 from Atmel.
The circuit
An initial quick glance at Figure 1
makes it clear that a central place
has been reserved for the AT90S8515
from Atmel (IC1). The entire program
resides within the microcontroller.
The frequency of the microcontroller
clock is set to 3.6864 MHz, using X1.
This frequency permits exact baud
rates to be generated for the UART,
which is used for the serial commu-
nication with a terminal or PC.
The four control buttons S1-S4 for
the switching clock (a detailed
description of the operation follows
later) are directly connected to port
B of the controller. R5-R8 provide a
defined input level at the inputs of
port B when the pushbuttons are not
activated. The software takes care of
debouncing the pushbuttons.
The display consists of a standard
2 × 16 character LC-display, which is
connected directly to PA0-PA7 and
PC4, PC5, PC6. Port PA is used as a
bi-directional data bus. PC4, PC5
and PC6 are the control signals for
the display (RS, WR and E respec-
tively). Potentiometer R11 and resis-
tor R12 form a potential divider that
provides a bias voltage for the con-
trast control of the display. The
There exists no shortage of switching clocks.
Both ‘analogue’ and ‘digital’ (with LCD) mod-
els are available with widely varying fea-
tures. So, what are the merits of this design
that makes it deserve the light of day? Well,
the particular feature that separates this
clock from the masses, is that it does not con-
trol just one channel, but can be
expanded to no fewer than 16 chan-
nels. In addition, this clock has a ser-
ial interface, which enables every on
and off switching event for each
channel to be monitored on a PC
using, for example, HyperTerminal.
30
Elektor Electronics
5/2001
855736817.589.png 855736817.700.png 855736817.811.png 855736817.922.png
GENERAL INTEREST
+5V
IC6
+5V
LM7805
+5V
K5
C12
S1
S2
S3
S4
C8
C16
C9
C10
C11
100n
10µ
25V
100n
10µ
25V
100n
100n
D5
PLUS
MIN
SELECT
RETURN
40
1 N4001
1
2
3
4
5
6
7
8
21
22
23
PB0(T0)
PB1(T1)
PC0(A8)
PC1(A9)
+5V
PB2(AIN0)
PC2(A10)
24
PB3
PC3(A11)
25
26
27
28
K3
+5V
PB4(SS)
PC4(A12)
PC5(A13)
PC6(A14)
PC7(A15)
R5
R6
R7
R8
R12
PB5(MOSI)
PB6(MISO)
K4
PB7(SCK)
R16
R11
IC1
+5V
D6
RE1
30
9
+5V
ALE
RESET
AT90S8515
C5
10µ
D4
10
39
38
37
36
35
34
33
32
5 00
PD0(RXD)
PD1(TXD)
PA0(AD0)
PA1(AD1)
PA2(AD2)
PA3(AD3)
PA4(AD4)
PA5(AD5)
PA6(AD6)
PA7(AD7)
1N4001
11
C13
25V
12
13
14
15
PD2(INT0)
PD3(INT1)
2
K2
T3
100n
V+
1
R13
1k5
C1+
C6
16
PD4
PD5
1
IC4
16
6
3
10µ
25V
C1–
16
BC547B
2
13
12
PD6(WR)
R1IN
R1OUT
R2OUT
1
2
3
17
4
5
6
PD7(RD)
A0
P0
P1
P2
P3
P4
P5
P6
P7
7
8
9
R2IN
A1
3
14
11
X1
X2
HC16202NY
TP1
TP2
TP3
TP4
TP5
TP6
IC5
T1OUT
T2OUT
T1IN
T2IN
A2
20
19
18
8
7
10
C17
X1
7
9
4
4
C2+
C7
13
INT
9
10µ
25V
PCF
MAX232
15
C1
C2
10
11
12
8574P
5
5
10µ
25V
C2–
14
SCL
SDA
V-
15p
15p
15
6
C4
3.6864MHz
8
10µ
25V
D2
R9
120
R10
220
+5V
+5V
D1
+5V
D3
1N4148
BT1
2x
K1
R4
R3
1N4148
3
4
3V6
NiCd
RESET
2
5
SCL
SDA
SCL
SDA
1
6
+5V
+5V
T1
R1
3k3
C3
2x
R17
8
8
BC547B
8
18p
1
5
T2
SDA
OSC
R2
3k3
IC7
6
5
X2
SCL
SDA
SCL
1
5
2
7
IC2
IC3
6
A0
A1
A2
RESET
RESET
RESIN
SENSE
2
3
6
PCF8583
3
2
X24C04
TL7705
A0
OSC
R18
7
1
3
32,768kHz
REF
CT
7
WC
INT
C14
C15
4
4
4
120n
150n
000184 - 11
Figure 1. The switching clock is designed around the AT90S8515 microcontroller.
I 2 C
The common thread that runs through the
entire switching clock is the I 2 C bus. The I 2 C
bus requires three controller pins (the SDA
line is bidirectional). These pins are PD4, PD5
and PD6, where PD4 is used as SCL, and PD5
and PD6 are SDA-send and SDA-receive
respectively. Transistors T1 and T2 function
as (inverting) buffers for what ultimately
becomes the I 2 C bus. The controller software
generates the correct I 2 C bus logic levels.
This implementation does not permit the use
of the INT signal that some I 2 C devices pro-
desired contrast is adjusted with
potentiometer R11.
An integrated ‘supply voltage
supervisor’ (IC7) from Texas Instru-
ments was chosen to be the reset
signal source for the controller. This
TL7705 contains a ‘power-on-reset’
and a ‘brown-out’ circ uit. Th e IC has
a RESET as well as a RESET-output,
both of which are of the open collec-
tor type. R17 and R18 serve as pull-
up and pull-down resistors respec-
tively.
Capacitor C15 is the time defining
element for the reset pulse. Because
the AT90S8515 has a negative reset
input, pin 5 of IC7 is used as the
reset source.
The communications interface for
a PC or terminal is the well-known
MAX232 (IC4). Capacitors C4-C7 are
the external components that are
necessary for the internal DC/DC-
converter, which generates the
10 V power supply.
5/2001
Elektor Electronics
31
855736817.001.png 855736817.052.png 855736817.063.png 855736817.074.png 855736817.085.png 855736817.094.png 855736817.105.png 855736817.116.png 855736817.127.png 855736817.138.png 855736817.149.png 855736817.160.png 855736817.171.png 855736817.182.png 855736817.193.png 855736817.204.png 855736817.215.png 855736817.226.png 855736817.237.png 855736817.248.png 855736817.259.png 855736817.270.png 855736817.281.png 855736817.292.png 855736817.303.png 855736817.314.png 855736817.325.png 855736817.336.png 855736817.347.png 855736817.358.png 855736817.369.png 855736817.380.png 855736817.391.png 855736817.402.png 855736817.413.png 855736817.424.png 855736817.435.png 855736817.446.png 855736817.457.png 855736817.468.png 855736817.479.png 855736817.490.png 855736817.501.png 855736817.512.png 855736817.523.png 855736817.534.png 855736817.545.png 855736817.556.png 855736817.567.png 855736817.578.png 855736817.590.png 855736817.601.png 855736817.612.png 855736817.623.png 855736817.634.png 855736817.645.png 855736817.656.png 855736817.667.png 855736817.678.png 855736817.689.png 855736817.701.png 855736817.712.png 855736817.723.png 855736817.734.png 855736817.745.png 855736817.756.png 855736817.767.png 855736817.778.png 855736817.789.png 855736817.800.png 855736817.812.png 855736817.823.png 855736817.834.png 855736817.845.png 855736817.856.png 855736817.867.png 855736817.878.png 855736817.889.png 855736817.900.png 855736817.911.png 855736817.923.png 855736817.934.png 855736817.945.png 855736817.956.png 855736817.967.png 855736817.978.png 855736817.989.png 855736817.1000.png 855736817.1011.png 855736817.1022.png 855736817.002.png 855736817.013.png 855736817.024.png 855736817.035.png 855736817.044.png 855736817.047.png 855736817.048.png 855736817.049.png 855736817.050.png 855736817.051.png 855736817.053.png 855736817.054.png 855736817.055.png 855736817.056.png 855736817.057.png 855736817.058.png 855736817.059.png 855736817.060.png 855736817.061.png 855736817.062.png 855736817.064.png 855736817.065.png 855736817.066.png 855736817.067.png 855736817.068.png 855736817.069.png 855736817.070.png 855736817.071.png 855736817.072.png 855736817.073.png 855736817.075.png 855736817.076.png 855736817.077.png 855736817.078.png 855736817.079.png 855736817.080.png 855736817.081.png 855736817.082.png 855736817.083.png 855736817.084.png 855736817.086.png 855736817.087.png 855736817.088.png 855736817.089.png 855736817.090.png 855736817.091.png 855736817.092.png 855736817.093.png
 
GENERAL INTEREST
H5
D6
R13
IC2
IC6
R8
R7
IC3
R6
C15
R5
C14
IC7
R12
R17
H7
Figure 2. The printed circuit board houses the entire circuit, including connectors, display and pushbuttons.
COMPONENTS LIST
Semiconductors:
D1,D2,D3 = 1N4148
D4 = LED, 3 mm, low current
D5,D6 = 1N4001
T1,T2,T3 = BC547B
IC1 = AT90S8515-8PC, programmed,
order code 000184-41
IC2 = PCF8583P
IC3 = 24C02
IC4 = MAX232
IC5 = PCF8574P
IC6 = 7805
IC7 = TL7705CP
S1-S4 = pushbutton, 1 make contact, e.g.,
D6-0 (ITT/Schadow)
Re1 = 5V reed relay, DIL case, 1 make
contact, e.g., Clare MSS21A05B
K1 = 6-way mini DIN socket, PCB mount
K2 = 9-way sub-D socket (female), angled
pins, PCB mount
K3 = 14-way SIL pinheader for connecting
LCD module
K4 = 2-way PCB terminal block, lead
pitch 5mm
K5 = mains adapter socket, PCB mount
LCD module, 2x16 characters, e.g., Sharp
type LM16A211
PCB, order code 000184-1 (see Readers
Services page and website)
Disk, contains hex file and source-code:
order code 000184-11
Resistors:
R1,R2 = 3k
3
R3,R4,R12,R13 = 1k
5
R5-R8 = 2k
2
R9 = 120
R10 = 220
R11 = 500
preset H
R16 = 390
R17,R18 = 10k
Capacitors:
C1,C2 = 15pF
C3 = 18pF
C4-C9,C17 = 10 µ F 25V radial
C10-C13,C16 = 100nF
C14 = 120nF
C15 = 150nF
Miscellaneous:
Bt1 = 3.6V NiCd battery with solder tags
X1 = 3.6864MHz quartz crystal
X2 = 32.768kHz quartz crystal
32
Elektor Electronics
5/2001
 
855736817.095.png 855736817.096.png 855736817.097.png 855736817.098.png 855736817.099.png 855736817.100.png 855736817.101.png 855736817.102.png 855736817.103.png 855736817.104.png 855736817.106.png 855736817.107.png 855736817.108.png 855736817.109.png 855736817.110.png 855736817.111.png 855736817.112.png 855736817.113.png 855736817.114.png 855736817.115.png 855736817.117.png 855736817.118.png 855736817.119.png 855736817.120.png 855736817.121.png 855736817.122.png 855736817.123.png 855736817.124.png 855736817.125.png 855736817.126.png 855736817.128.png 855736817.129.png 855736817.130.png 855736817.131.png 855736817.132.png 855736817.133.png 855736817.134.png 855736817.135.png 855736817.136.png 855736817.137.png 855736817.139.png 855736817.140.png 855736817.141.png 855736817.142.png 855736817.143.png 855736817.144.png 855736817.145.png 855736817.146.png 855736817.147.png 855736817.148.png 855736817.150.png 855736817.151.png 855736817.152.png 855736817.153.png 855736817.154.png 855736817.155.png 855736817.156.png 855736817.157.png 855736817.158.png 855736817.159.png 855736817.161.png 855736817.162.png 855736817.163.png 855736817.164.png 855736817.165.png 855736817.166.png 855736817.167.png 855736817.168.png 855736817.169.png 855736817.170.png 855736817.172.png 855736817.173.png 855736817.174.png 855736817.175.png 855736817.176.png 855736817.177.png 855736817.178.png 855736817.179.png 855736817.180.png 855736817.181.png 855736817.183.png 855736817.184.png 855736817.185.png 855736817.186.png 855736817.187.png 855736817.188.png 855736817.189.png 855736817.190.png 855736817.191.png 855736817.192.png 855736817.194.png 855736817.195.png 855736817.196.png 855736817.197.png 855736817.198.png 855736817.199.png 855736817.200.png 855736817.201.png 855736817.202.png 855736817.203.png 855736817.205.png 855736817.206.png 855736817.207.png 855736817.208.png 855736817.209.png 855736817.210.png 855736817.211.png 855736817.212.png 855736817.213.png 855736817.214.png 855736817.216.png 855736817.217.png 855736817.218.png 855736817.219.png 855736817.220.png 855736817.221.png 855736817.222.png 855736817.223.png 855736817.224.png 855736817.225.png 855736817.227.png 855736817.228.png 855736817.229.png 855736817.230.png 855736817.231.png 855736817.232.png 855736817.233.png 855736817.234.png 855736817.235.png 855736817.236.png 855736817.238.png 855736817.239.png 855736817.240.png 855736817.241.png 855736817.242.png 855736817.243.png 855736817.244.png 855736817.245.png 855736817.246.png 855736817.247.png 855736817.249.png 855736817.250.png 855736817.251.png 855736817.252.png 855736817.253.png 855736817.254.png 855736817.255.png 855736817.256.png 855736817.257.png 855736817.258.png 855736817.260.png 855736817.261.png 855736817.262.png 855736817.263.png 855736817.264.png 855736817.265.png 855736817.266.png 855736817.267.png 855736817.268.png 855736817.269.png 855736817.271.png 855736817.272.png 855736817.273.png 855736817.274.png 855736817.275.png 855736817.276.png 855736817.277.png 855736817.278.png 855736817.279.png 855736817.280.png 855736817.282.png 855736817.283.png 855736817.284.png 855736817.285.png 855736817.286.png 855736817.287.png 855736817.288.png 855736817.289.png 855736817.290.png 855736817.291.png 855736817.293.png 855736817.294.png 855736817.295.png 855736817.296.png 855736817.297.png 855736817.298.png 855736817.299.png 855736817.300.png 855736817.301.png 855736817.302.png 855736817.304.png 855736817.305.png 855736817.306.png 855736817.307.png 855736817.308.png 855736817.309.png 855736817.310.png 855736817.311.png 855736817.312.png 855736817.313.png 855736817.315.png 855736817.316.png 855736817.317.png 855736817.318.png 855736817.319.png 855736817.320.png 855736817.321.png 855736817.322.png 855736817.323.png 855736817.324.png 855736817.326.png 855736817.327.png 855736817.328.png 855736817.329.png 855736817.330.png 855736817.331.png 855736817.332.png 855736817.333.png 855736817.334.png 855736817.335.png 855736817.337.png 855736817.338.png 855736817.339.png 855736817.340.png 855736817.341.png 855736817.342.png 855736817.343.png 855736817.344.png 855736817.345.png 855736817.346.png 855736817.348.png 855736817.349.png 855736817.350.png 855736817.351.png 855736817.352.png 855736817.353.png 855736817.354.png 855736817.355.png 855736817.356.png 855736817.357.png 855736817.359.png 855736817.360.png 855736817.361.png 855736817.362.png 855736817.363.png 855736817.364.png 855736817.365.png 855736817.366.png 855736817.367.png 855736817.368.png 855736817.370.png 855736817.371.png 855736817.372.png 855736817.373.png 855736817.374.png 855736817.375.png 855736817.376.png 855736817.377.png 855736817.378.png 855736817.379.png 855736817.381.png 855736817.382.png 855736817.383.png 855736817.384.png 855736817.385.png 855736817.386.png 855736817.387.png 855736817.388.png 855736817.389.png 855736817.390.png 855736817.392.png 855736817.393.png 855736817.394.png 855736817.395.png 855736817.396.png 855736817.397.png 855736817.398.png 855736817.399.png 855736817.400.png 855736817.401.png 855736817.403.png 855736817.404.png 855736817.405.png 855736817.406.png 855736817.407.png 855736817.408.png 855736817.409.png 855736817.410.png 855736817.411.png 855736817.412.png 855736817.414.png 855736817.415.png 855736817.416.png 855736817.417.png 855736817.418.png 855736817.419.png 855736817.420.png 855736817.421.png 855736817.422.png 855736817.423.png 855736817.425.png 855736817.426.png 855736817.427.png 855736817.428.png 855736817.429.png 855736817.430.png 855736817.431.png 855736817.432.png 855736817.433.png 855736817.434.png 855736817.436.png 855736817.437.png 855736817.438.png 855736817.439.png 855736817.440.png 855736817.441.png 855736817.442.png 855736817.443.png 855736817.444.png 855736817.445.png 855736817.447.png 855736817.448.png 855736817.449.png 855736817.450.png 855736817.451.png 855736817.452.png 855736817.453.png 855736817.454.png 855736817.455.png 855736817.456.png 855736817.458.png 855736817.459.png 855736817.460.png 855736817.461.png 855736817.462.png 855736817.463.png 855736817.464.png 855736817.465.png 855736817.466.png 855736817.467.png 855736817.469.png 855736817.470.png 855736817.471.png 855736817.472.png 855736817.473.png 855736817.474.png 855736817.475.png 855736817.476.png 855736817.477.png 855736817.478.png 855736817.480.png 855736817.481.png 855736817.482.png 855736817.483.png 855736817.484.png 855736817.485.png 855736817.486.png 855736817.487.png 855736817.488.png 855736817.489.png 855736817.491.png 855736817.492.png 855736817.493.png 855736817.494.png 855736817.495.png 855736817.496.png 855736817.497.png 855736817.498.png 855736817.499.png 855736817.500.png 855736817.502.png 855736817.503.png 855736817.504.png 855736817.505.png 855736817.506.png 855736817.507.png 855736817.508.png 855736817.509.png 855736817.510.png 855736817.511.png 855736817.513.png 855736817.514.png 855736817.515.png 855736817.516.png 855736817.517.png 855736817.518.png 855736817.519.png 855736817.520.png 855736817.521.png 855736817.522.png 855736817.524.png 855736817.525.png 855736817.526.png 855736817.527.png 855736817.528.png 855736817.529.png 855736817.530.png 855736817.531.png 855736817.532.png 855736817.533.png 855736817.535.png 855736817.536.png 855736817.537.png 855736817.538.png 855736817.539.png 855736817.540.png 855736817.541.png 855736817.542.png 855736817.543.png 855736817.544.png 855736817.546.png 855736817.547.png 855736817.548.png 855736817.549.png 855736817.550.png 855736817.551.png 855736817.552.png 855736817.553.png 855736817.554.png 855736817.555.png 855736817.557.png 855736817.558.png 855736817.559.png 855736817.560.png 855736817.561.png 855736817.562.png 855736817.563.png 855736817.564.png 855736817.565.png 855736817.566.png 855736817.568.png 855736817.569.png 855736817.570.png 855736817.571.png 855736817.572.png 855736817.573.png 855736817.574.png 855736817.575.png 855736817.576.png 855736817.577.png 855736817.579.png 855736817.580.png 855736817.581.png 855736817.582.png 855736817.583.png 855736817.584.png 855736817.585.png 855736817.586.png 855736817.587.png 855736817.588.png 855736817.591.png 855736817.592.png 855736817.593.png 855736817.594.png 855736817.595.png 855736817.596.png 855736817.597.png 855736817.598.png 855736817.599.png 855736817.600.png 855736817.602.png 855736817.603.png 855736817.604.png 855736817.605.png 855736817.606.png 855736817.607.png 855736817.608.png 855736817.609.png 855736817.610.png 855736817.611.png 855736817.613.png 855736817.614.png 855736817.615.png 855736817.616.png 855736817.617.png 855736817.618.png 855736817.619.png 855736817.620.png 855736817.621.png 855736817.622.png 855736817.624.png 855736817.625.png 855736817.626.png 855736817.627.png 855736817.628.png 855736817.629.png 855736817.630.png 855736817.631.png 855736817.632.png 855736817.633.png 855736817.635.png 855736817.636.png 855736817.637.png 855736817.638.png 855736817.639.png 855736817.640.png 855736817.641.png 855736817.642.png 855736817.643.png 855736817.644.png 855736817.646.png 855736817.647.png 855736817.648.png 855736817.649.png 855736817.650.png 855736817.651.png 855736817.652.png 855736817.653.png 855736817.654.png 855736817.655.png 855736817.657.png 855736817.658.png 855736817.659.png 855736817.660.png 855736817.661.png 855736817.662.png 855736817.663.png 855736817.664.png 855736817.665.png 855736817.666.png 855736817.668.png 855736817.669.png 855736817.670.png 855736817.671.png 855736817.672.png 855736817.673.png 855736817.674.png 855736817.675.png 855736817.676.png 855736817.677.png 855736817.679.png 855736817.680.png 855736817.681.png 855736817.682.png 855736817.683.png 855736817.684.png 855736817.685.png 855736817.686.png 855736817.687.png 855736817.688.png 855736817.690.png 855736817.691.png 855736817.692.png 855736817.693.png 855736817.694.png 855736817.695.png 855736817.696.png 855736817.697.png 855736817.698.png 855736817.699.png 855736817.702.png 855736817.703.png 855736817.704.png 855736817.705.png 855736817.706.png 855736817.707.png 855736817.708.png 855736817.709.png 855736817.710.png 855736817.711.png 855736817.713.png 855736817.714.png 855736817.715.png 855736817.716.png 855736817.717.png 855736817.718.png 855736817.719.png 855736817.720.png 855736817.721.png 855736817.722.png 855736817.724.png 855736817.725.png 855736817.726.png 855736817.727.png 855736817.728.png 855736817.729.png 855736817.730.png 855736817.731.png 855736817.732.png 855736817.733.png 855736817.735.png 855736817.736.png 855736817.737.png 855736817.738.png 855736817.739.png 855736817.740.png 855736817.741.png 855736817.742.png 855736817.743.png 855736817.744.png 855736817.746.png 855736817.747.png 855736817.748.png 855736817.749.png 855736817.750.png 855736817.751.png 855736817.752.png 855736817.753.png 855736817.754.png 855736817.755.png 855736817.757.png 855736817.758.png 855736817.759.png 855736817.760.png 855736817.761.png 855736817.762.png 855736817.763.png 855736817.764.png 855736817.765.png 855736817.766.png 855736817.768.png 855736817.769.png 855736817.770.png 855736817.771.png 855736817.772.png 855736817.773.png 855736817.774.png 855736817.775.png 855736817.776.png 855736817.777.png 855736817.779.png 855736817.780.png 855736817.781.png 855736817.782.png 855736817.783.png 855736817.784.png 855736817.785.png 855736817.786.png 855736817.787.png 855736817.788.png 855736817.790.png 855736817.791.png 855736817.792.png 855736817.793.png 855736817.794.png 855736817.795.png 855736817.796.png 855736817.797.png 855736817.798.png 855736817.799.png 855736817.801.png 855736817.802.png 855736817.803.png 855736817.804.png 855736817.805.png 855736817.806.png 855736817.807.png 855736817.808.png 855736817.809.png 855736817.810.png 855736817.813.png 855736817.814.png 855736817.815.png 855736817.816.png 855736817.817.png 855736817.818.png 855736817.819.png 855736817.820.png 855736817.821.png 855736817.822.png 855736817.824.png 855736817.825.png 855736817.826.png 855736817.827.png 855736817.828.png 855736817.829.png 855736817.830.png 855736817.831.png 855736817.832.png 855736817.833.png 855736817.835.png 855736817.836.png 855736817.837.png 855736817.838.png 855736817.839.png 855736817.840.png 855736817.841.png 855736817.842.png 855736817.843.png 855736817.844.png 855736817.846.png 855736817.847.png 855736817.848.png 855736817.849.png 855736817.850.png 855736817.851.png 855736817.852.png 855736817.853.png 855736817.854.png 855736817.855.png 855736817.857.png 855736817.858.png 855736817.859.png 855736817.860.png 855736817.861.png 855736817.862.png 855736817.863.png 855736817.864.png 855736817.865.png 855736817.866.png 855736817.868.png 855736817.869.png 855736817.870.png 855736817.871.png 855736817.872.png 855736817.873.png 855736817.874.png 855736817.875.png 855736817.876.png 855736817.877.png 855736817.879.png 855736817.880.png 855736817.881.png 855736817.882.png 855736817.883.png 855736817.884.png 855736817.885.png 855736817.886.png 855736817.887.png 855736817.888.png 855736817.890.png 855736817.891.png 855736817.892.png 855736817.893.png 855736817.894.png 855736817.895.png 855736817.896.png 855736817.897.png 855736817.898.png 855736817.899.png 855736817.901.png 855736817.902.png 855736817.903.png 855736817.904.png 855736817.905.png 855736817.906.png 855736817.907.png 855736817.908.png 855736817.909.png 855736817.910.png 855736817.912.png 855736817.913.png 855736817.914.png 855736817.915.png 855736817.916.png 855736817.917.png 855736817.918.png 855736817.919.png 855736817.920.png 855736817.921.png 855736817.924.png 855736817.925.png 855736817.926.png 855736817.927.png 855736817.928.png 855736817.929.png 855736817.930.png 855736817.931.png 855736817.932.png 855736817.933.png 855736817.935.png 855736817.936.png 855736817.937.png 855736817.938.png 855736817.939.png 855736817.940.png 855736817.941.png 855736817.942.png 855736817.943.png 855736817.944.png 855736817.946.png 855736817.947.png 855736817.948.png 855736817.949.png 855736817.950.png 855736817.951.png 855736817.952.png 855736817.953.png 855736817.954.png 855736817.955.png 855736817.957.png 855736817.958.png 855736817.959.png 855736817.960.png 855736817.961.png 855736817.962.png 855736817.963.png 855736817.964.png 855736817.965.png 855736817.966.png 855736817.968.png 855736817.969.png 855736817.970.png 855736817.971.png 855736817.972.png 855736817.973.png 855736817.974.png 855736817.975.png 855736817.976.png 855736817.977.png 855736817.979.png 855736817.980.png 855736817.981.png 855736817.982.png 855736817.983.png 855736817.984.png 855736817.985.png 855736817.986.png 855736817.987.png 855736817.988.png 855736817.990.png 855736817.991.png 855736817.992.png 855736817.993.png 855736817.994.png 855736817.995.png 855736817.996.png 855736817.997.png 855736817.998.png 855736817.999.png 855736817.1001.png 855736817.1002.png 855736817.1003.png 855736817.1004.png 855736817.1005.png 855736817.1006.png 855736817.1007.png 855736817.1008.png 855736817.1009.png 855736817.1010.png 855736817.1012.png 855736817.1013.png 855736817.1014.png 855736817.1015.png 855736817.1016.png 855736817.1017.png 855736817.1018.png 855736817.1019.png 855736817.1020.png 855736817.1021.png 855736817.1023.png 855736817.1024.png 855736817.1025.png 855736817.1026.png 855736817.1027.png 855736817.1028.png 855736817.1029.png 855736817.1030.png 855736817.1031.png 855736817.1032.png 855736817.003.png 855736817.004.png 855736817.005.png 855736817.006.png 855736817.007.png 855736817.008.png 855736817.009.png 855736817.010.png 855736817.011.png 855736817.012.png 855736817.014.png 855736817.015.png 855736817.016.png 855736817.017.png 855736817.018.png 855736817.019.png 855736817.020.png 855736817.021.png 855736817.022.png 855736817.023.png 855736817.025.png 855736817.026.png 855736817.027.png 855736817.028.png 855736817.029.png 855736817.030.png 855736817.031.png 855736817.032.png 855736817.033.png 855736817.034.png 855736817.036.png 855736817.037.png 855736817.038.png 855736817.039.png
 
GENERAL INTEREST
vide. Also, no other masters may be
connected to this I 2 C-bus. The con-
troller software supports single-mas-
ter operation only!
The I 2 C bus is available externally
through connector K1. This allows
additional switching modules to be
connected. The real-time clock (RTC)
functionality is provided by a
PCF8583P (IC2). This IC contains all
the circuitry for a complete clock and
calendar. X2 and C3 are required for
the correct functioning of the oscilla-
tor.
While mains power is switched
on, the RTC is powered via D1.
Simultaneously, NiCd battery Bt1 is
then charged via D3 and R10. During
periods when the mains is not avail-
able, Bt1 provides the power supply
to the RTC via D2 and R9. This
ensures that the clock continues to
run and that the date and time are
properly maintained. Diode D1 pre-
vents the remainder of the circuitry
from being inadvertently powered
by the NiCd battery.
IC3 is a 256-byte EEPROM, which
is used to store the switching times.
IC5 is a switching unit whose
address lines A0, A1 and A2 are con-
nected to ground, which causes this
unit to have the lowest address. LED
D4 indicates the switch state of
Relay Re1. The relay contact is
closed when D4 is on. The contact
itself may be used freely.
Software
The software for the switching clock is written entirely in AVR Studio, which can be
obtained from the Atmel website. The software consists of seven modules: SKLOK.ASM,
DATADEF.ASM, DIVFUNC.ASM, I2CFUNC.ASM, MENU.ASM, 8583SET.ASM and SWK-
LOK.ASM. The latter is the main module. This has to be indicated as such in the project-
manager of AVR-Studio. The source code has been liberally commented and has been kept
as simple as possible. It is, however, impossible to discuss the details of the software in its
entirety.
On start up, the list of switching times is read from the EEPROM. Every switching event
consists of five bytes (hours, minutes, days, status/channel, 2’s complement of the previous
four bytes). When the fifth byte is correct it is assumed the previous bytes contain valid
data. Reading from the EEPROM continues until an invalid 2’s complement value is
retrieved. All these values are copied to an array and stored in the SRAM of the controller.
(To reduce the I 2 C activity on the bus.) The main loop of the software compares the times
in the array with the time in the RTC. If one or more array entries match, then the corre-
sponding I/O module is set to the desired state. These status changes are also passed on to
the RS232 port of the microcontroller. Whenever a change is made to the switching time,
both the array, as well as the contents of the EEPROM, are updated.
Finally, a brief description of the functionality of each module:
SKLOK.ASM is the main module. This details all the interrupt vectors, program variables
and data definitions. It also contains the main loop of the program.
DATADEF.ASM contains all the text strings, which may be shown on the display. These
strings may be translated to another language. The length of the text must remain
exactly the same (adding extra spaces if necessary), and every string has to be termi-
nated with a ‘00’. The software uses this to test for ‘end of string’.
DIVFUNC.ASM contains the routines that are called from various modules.
The file I2CFUNC.ASM contains all the routines that are required for controlling the I 2 C-
bus. This software does not support the multi-master protocol. The microcontroller is
in this case the only master. This version of software does not support interrupts either.
The software is, however, perfectly adequate for most applications.
The file MENU.ASM is self- explanatory. This module is called from the main module and
it in turn calls the underlying program modules. The design is such that is easy to add
menu options.
8583SET.ASM is one of the modules that is called from within the menu. This controls all
the programming of the RTC. For details refer to the data sheet of the PCF8583.
SWKLOK.ASM is also called from the menu. This module takes care of the initial entering
or changing of the switching times.
Practical matters
An ordinary 9 V mains adapter con-
nected to K5 will suffice to power the
switching clock. There are no partic-
ular requirements since voltage reg-
ulator IC6 will provide a stabilised
5V.
Figure 2 shows the printed circuit
board that has been designed for the
switching clock. Although the circuit
contains rather a large number of
ICs, we have been able to keep the
size of the PCB down, as you can
see. There are no difficult details
associated with the construction of
this circuit. If you build it according
to the parts list everything will, in all
likelihood, go smoothly. Because the
various connectors and four push-
buttons are fitted directly on the PCB
there is almost nothing required
externally.
As already indicated on the
schematic, the PCB contains only a
single relay stage (T3, Re1). Of
course, the other outputs of IC5
(TP1-TP7) can each be connected to
an external relay stage. For details
regarding the operation of the I 2 C-
bus and the various components you
are referred to the ‘I 2 C Peripherals’
data book from Philips (order number
9397 750 00306). When connecting
I/O modules a considerable distance
away from the switching clock, it is
necessary to buffer the I 2 C bus using
an 82B715 I 2 C Bus Booster (refer to
the June 1994 issue of Elektor Elec-
tronics , for example).
The programmed controller, the
printed circuit board as well as a
diskette with both the hex file and
source code may be purchased from
Elektor Electronics . The latter two may also
be downloaded from our web site at
www.elektor-electronics.co.uk .
Operation
The four pushbuttons S1-S4 have the follow-
ing functions: Return, Select, Down and Up.
After switching the clock on, the display
always indicates the time and date which is
read from the RTC:
Time: 14:44:59
We 11 Oct 2000
By pushing the Select button, the switching
clock menu becomes available. This menu
offers the following choices:
- ‘RTC-setting’
5/2001
Elektor Electronics
33
855736817.040.png 855736817.041.png 855736817.042.png
 
GENERAL INTEREST
day). By pressing the +- and –-but-
tons you can choose to switch on a
particular day, every day of the
week, working days only or week-
end only. An underscore (‘_’) indi-
cates that the switching event is
inactive on that particular day.
Once the correct days have been
selected we have to choose which
output (Channel) has to be switched
and whether it has to be turned on
or off. Channel 0 means relay Re1,
Channels 1-7 are found on P1-P7 of
IC5. Channels 8-15 are only available
if an additional PCF8574P is con-
nected to the I 2 C bus.
fied or whether there is a problem
with the I 2 C bus, for example.
- ‘Switch clock’
- ‘Module list’
- ‘Manual’
Manual
This makes it possible to switch a
channel on or off manually, bypass-
ing the timer.
The display indicates the same
thing as the switching clock chan-
nel/status setting. An asterisk indi-
cates whether the module is present
or not.
Using the Up- and Down-buttons one of the
four options can be selected. The chosen
option is entered by pressing the Select
button.
Setting the RTC
After selecting the RTC setting, you have to
successively enter the hours (24-hour clock),
minutes, month, day of the month, day of the
week, and year.
Use the Up and Down buttons to set the
correct value. Pushing the Select button takes
you to the next field. Once all the values have
been entered you are returned to the menu.
Serial connection
The switching clock can be con-
nected to a PC using a standard 9-
way cable; a terminal program such
as HyperTerminal in Windows may
then be used to keep a log of switch-
ing activity. Whenever an output
changes state, the clock will send a
line of text to the PC, indicating the
time of day, name of the day (2 char-
acters), the date, channel number and
the new state of the channel. The ser-
ial port on the PC has to be set as fol-
lows: 9600 baud, 8 bits, no parity, 1
stop bit, no flow control.
Module list
The main intention for this menu
option is to display which (switch-
ing) modules are present on the I 2 C
bus. The display may indicate the
following:
Switching Times
The clock can store up to 20 different switch-
ing times. When adjusting the switching
times, the number of the event (0-19) is dis-
played in the top right hand corner.
Shown below ‘Time:’ is the actual time
when the switching action will occur. Fol-
lowing that, indicated with asterisks, is/are
the day(s) for which this action is planned
(MTWTFSS = Monday, Tuesday through Sun-
8574 *———
8574A ————
This may come in useful to check if
all the modules are properly identi-
(000184-1)
34
Elektor Electronics
5/2001
855736817.043.png 855736817.045.png 855736817.046.png
Zgłoś jeśli naruszono regulamin