e99a050.pdf

(134 KB) Pobierz
138906022 UNPDF
GENERAL INTEREST
super loco decoder
EEDTS Pro
for use with virtually any make of locomotive
The super loco decoder (ESLD) described in this article provides a
worthwhile alternative for model railway enthusiasts who want to make
their locomotives digital at reasonable cost. One of the benefits of build-
ing it yourself is that the design can be adapted to virtually any make of
locomotive. Another is that the loco decoder provides several additional
facilities that complete
the digital control of
the model railway.
Brief specification
Suitable for two-rail and three-rail systems
Suitable for d.c. and a.c. motors
Four functions; one of which is suitable for use as a preset flashing light
Brightness of headlights presettable
Design by H J Prince
Frequency of flashing light presettable
Locomotive detection by infra-red LED
Storage of movement and function settings for indeterminate period in case
of power-down
INTRODUCTION
A glance at the brief specification
shows that the super loco decoder is
suitable for universal applications. It
may be used with virtually all current
model railway systems, since a large
number of functions may be selected at
will and to personal requirements.
Some of these are selected by software
via a personal computer and the con-
trol unit described in the June 1999
issue of this magazine. The decoder
may also be used as a stand-alone unit,
in which case the loco addresses are set
with the aid of a diode matrix. For this
purpose, 16 preprogrammed loco
addresses are stored in EEPROM.
145027 Motorola combination and con-
sists of nine trits . The transmitter
(145026) has nine inputs that recognize
three levels: high (10, low (0), and open
(x). This information is available in ser-
ial form at the output, so that the out-
put signal consists of nine trits. In the
Märklin system, four trits are used for
loco addressing, one for switching the
headlights (FO) on and off, and four
for the speed and direction of travel.
Each trit consists of two bits that
represent the three levels: 00; 01; 11,
that is, 0, x, and 1, respectively. This
gives a total of 18 bits—see Figure 1 .
In the old format, the function-0
bit and the data bits for speed are
used in binary form only. This means
that up to 2 4 =16 steps may be set:
one for standstill, one for reversing
the direction of travel, and 14 for the
speed. When the data bits are used in
trinary form, 3 4 =81 combinations are
possible. If this figure is reduced by
the 16 steps in the old format, 65
remain, more than sufficient to con-
trol new functions.
Space does not allow all the relevant
tables to be shown. Briefly, it comes
down to each trinary word of four trits
representing speed, direction of travel,
and the status of one of the function
outputs (on/off). All combinations are
stored in tabular form in the decoder
IC. Provided that they coincide with
the data sent by the Märklin con-
trollers, all actions will be performed
smoothly and error-free.
DESIGN
In all model railway designs, compact-
ness is a first requirement, and the
decoder therefore uses a Type
PIC16F84 microcontroller, IC 1 . This
Microdevice I/O controller provides 13
I/O connections, RAM, EPROM, and
EEPROM. Together with a small num-
ber of surface-mount devices (SMDs),
it is therefore eminently suitable for
building a complete and compact
decoder.
The circuit diagram of the decoder
OLD AND NEW FORMAT
To understand how it is possible to
obtain several new functions with the
current Motorola format, it is necessary
to reflect on the composition of the
original format.
In the original format, each data
word has its origin in the 145026/
50
Elektor Electronics
10/99
Compatible with old and new Märklin format
Loco address programmable via personal computer or diode matrix
Top speed presettable
Rate of acceleration and deceleration presettable
138906022.067.png
is shown in Figure 2 . Diodes D 1 –D 4 in a
bridge arrangement, make the polarity
of the track voltage independent of the
supply voltage
The supply voltage is applied to IC 1
via resistor R 5 and the base-emitter
junction of transistor T 1 . It is kept
steady by zener diode D 9 . When there
is track voltage available, a current
flows through the base-emitter junc-
tion of T 1 , so that the transistor is dri-
ven into saturation which makes pin 2
(RA3) of IC 1 high. In the absence of
track voltage, the potential across
capacitor C 3 drops below the zener
voltage (5.1 V), which causes T 1 to be
cut off, whereupon the input of IC 1
goes low. After a certain period of time,
the program executes a power-down
routine and writes the data as to speed,
direction of travel, and function infor-
mation into EEPROM.
The clock for IC 1 is provided by a
4-MHz ceramic resonator, X 1 . It may
also be by a small quartz crystal, but a
resonator is smaller and less expensive.
Moreover, when a resonator is used,
capacitors C 1 and C 2 may be omitted.
Track information is applied to an
interrupt input of IC 1 via resistor R 3 .
Outputs RB 1 –RB 7 control the head-
lights, four functions, and an infra-red
LED respectively. These function out-
puts, whose total current must not
exceed 1.5 A, are buffered by IC 2 .
Diodes D 5 –D 8 are optional; they
form a matrix that serves to set the
loco addresses when the decoder is
used as a stand-alone unit. Depending
on the number, placement and posi-
tion of the diodes they identify one of
the loco addresses in a table in EEP-
ROM. This makes it possible for 16
loco addresses to be set without the
aid of external software or electronic
circuitry. Each address in the table
may be reprogrammed, which will be
reverted to later.
If, in accordance with Table 1, a
diode is soldered in one of the posi-
tions marked ‘D’ on the PCB, the loco
address associated with that position is
actuated. A number of addresses are
used in the central control of the
Märklin system and these are therefore
easily set.
The engine control driver may be
adapted for use with d.c. or a.c.
motors. That for d.c. motors is shown
at the lefthand top of Figure 2. Dar-
lington transistors T 4 and T 5 , and resis-
tors R 9 and R 10 , are not needed when
Märklin series motors are used. The
two stator windings of these are linked
to terminals M 1 and M 2 , while the
common armature winding is con-
nected to terminal M 3 . Diodes D 10 and
D 11 are connected with
reverse polarity to
quench the counter-
e.m.f. of the motor:
their cathodes are
Table 1
Table 1. The loco
addresses may be set
with the aid of a diode
matrix.
loco no. loco address diode 5678
0
1
––––
1
2
–––D
2
3
––D–
posed on a carrier of about 38 kHz and
is received by a standard infra-red
decoder mounted adjacent to, or on,
the track. After the address has been
processed (also by a PIC), it is trans-
ferred to the EEDTS Pro control unit.
The same principle as in the return sig-
nallers in the EEDTS and Märklin S88
systems is used. This makes it possible
to determine train-dependent track
sections. This infra-red loco address
return signaller will be reverted to in
the next instalment.
The current through the infra-red
LED is limited by a 2.2 k
3
4
––DD
4
5
–D––
5
6
–D–D
6
7
–DD–
7
8
–DDD
8
10
D–––
9
19
D––D
10
20
D–D–
11
22
D–DD
12
24
DD––
series resis-
tor. It is clear that the value of this resis-
tor influences the maximum distance
at which the engine is detected by the
infra-red receiver. When the value is
1.0 k
13
30
DD–D
14
39
DDD–
15
40
DDDD
, the engine is detected at a dis-
tance of about one metre (just over
3 ft). The type of LED is immaterial:
dependent on its position and applica-
tion a 3 mm or 5 mm may be used.
linked to terminal M 3 .
When a standard d.c. motor is used,
T 4 , T 5 , R 9 , and R 10 are needed. The
motor is connected to terminals M 1
and M 2 . Bear in mind that the polarity
of the diodes is the opposite of that
when a Märklin series motor is used.
FIRMWARE *
The application in which the decoder
is used is not processor-friendly. Vary-
ing contacts of the wheels and tracks
cause frequent glitches and interrup-
tions in the supply voltage. Since this
creates a real risk of mishaps, it is nec-
essary to guarantee correct and unin-
terrupted execution of the program in
all circumstances. To this end, a num-
ber of important registers is tested reg-
ularly for consistent performance.
When something goes wrong, the pro-
gram is re-initialized and all registers
are reset. The program progression is
shown in Figure 3 : at the left the main
LOCO ADDRESS
RECOGNITION
As already stated in the first part of this
series of articles, it is essential for a reli-
able time table to know which train
enters a station and when. The present
loco decoder transmits a signal by
means of an infra-red LED (shown in
dashed lines at the right of Figure 2)
that has the same address as that set in
the decoder. This address is superim-
* Strictly speaking, firmware is system software held in read-only memory (ROM).
1
Figure 1. Representa-
tion of a trinary data
word.
Elektor Electronics
10/99
51
138906022.078.png 138906022.089.png
2
R9
R10
T4
T5
R1
D10
D11
M3
M1 M2
ACCOMMON
T1
1N4001
M1
M2
1N4001
D10
DC
DC
D11
AC
AC
2x
1N4001
D9
T2
T3
BC857C
C5
2x
MJD6039
T2
T3
*
47µ
16V
R12
R5
5V1
R7
R8
AC version
R7
R8
DC version
14
D 12
*
RA1
RA0
IR-LED
4
18
17
MCLR
RA0
RA1
RA1
RA0
9
R3
270k
DS
6
IC1
7
1
2
3
16
RB0
RB1
RB2
RB3
RB4
RB5
RB6
RB7
I1
I2
I3
I4
I5
I6
I7
O1
O2
O3
O4
O5
O6
O7
IR-LED
8
15
F1
F2
F3
F4
9
14
R
D3
D4
PIC16F84
1
10
4
5
13
IC2
RA2
RA3
2
11
12
ULN
3
12
6
7
11
2004
RA4
REV FUNCTION
FWR FUNCTION
B
13
10
D1
D2
OSC1
OSC2
D8
D7
D6
D5
GND
R11
R2
16
15
5
8
C4
R4
X1
4MHz
10µ
16V
Tant.
R6
C1
C2
*
22p
*
990071 - 12
Figure 2. Circuit diagram of the
super loco decoder. Expanding
the section around T 2 and T 3 with
T 4 , T 5 , R 9 , R 10 (see top lefthand)
renders the decoder suitable for
operation with d.c. engines.
flow, and at the right that of the inter-
rupt routine.
A hardware reset results in a re-ini-
tialization of a number of configuration
registers in IC 1 . At power-down, the
relevant registers are stored in the EEP-
ROM. This is followed by the program
testing a number of registers whether
they have retained the correct setting.
If there is a discrepancy, the program
starts afresh and all registers are re-ini-
tialized.
Subsequently, the timers that pro-
vide regular processes, such as the F4
flashing rate, rate of acceleration and
deceleration, repetition time of the pul-
sating engine drive, and the dimming
of the headlights, are readjusted where
necessary. A wait loop determines the
flow time of the main loop and there-
fore the repetition time of the various
software timers.
At power-down, the settings of
speed, direction, and function then
current are written into the EEPROM,
but note that this applies only to those
registers that have been altered during
the operating period. This arrange-
ment prevents unnecessary writing
into the EEPROM every time the track
3
Start
Interrupt
Init
registers
IRled-
burst on
NO
YES
Set
IR led
Set
Timer
Write speed and
function regs in
EEPROM
if not equal
Power
down
Y E S
Timer
interrupt
NO
YES
Read
databit
YES
NO
NO
Timeout
Check
config regs
Raildata IRQ
Update bit counter
Update word counter
Shift bit in
NO
Equal
YES
NO
All
done
YES
Set timers
F4 timer
Velocity timer
IR burst timer
Powerdown timer
Compare data
Wait
NO
Equal
YES
YES
Setup
address
NO
NO
Ten
times
YES
Loco address
diode matrix
Speed
Look-up table
Calculate data
Calculate data
Loco address
Look-up table
Write setup regs in
EEPROM if not equal
Set speed and
function regs
Function
Look-up table
Figure 3. Program flow
of the loco decoder: at
the left, the main flow;
at the right, the inter-
rupt routine.
Set timer
Return int.
990071-13
52
Elektor Electronics
10/99
22p
138906022.100.png 138906022.001.png 138906022.012.png 138906022.019.png 138906022.020.png 138906022.021.png 138906022.022.png 138906022.023.png 138906022.024.png 138906022.025.png 138906022.026.png 138906022.027.png
B
R
AC-version
DC-version
C4
1
990071-1
M1
M2
990071-1
R8
R8
C1
R11
X1
D9
R5
M2
C5
IC1
IC1
M3
M3
FWR
REV
D5
D6
D7
D8
D10
D10
F4
F3
F2
(C) ELEKTOR
(C) ELEKTOR
(C) ELEKTOR
M1
IR-Led
F1
Figure 4. Double-sided printed-circuit board for
the super loco decoder. The board has no provi-
sion for the infra-red LED and its series resistor.
Parts list
Resistors:
R 1 = 1.8 k *
R 2 , R 5 , R 7 –R 11 = 10 k
*
voltage is interrupted. This lengthens
the life of the EEPROM appreciably.
Interrupt routines are started by a
leading or trailing edge of the data on
the rails of pin 6 of IC 1 or of the integral
hardware timer. Dependent on the
actual situation, all bits are clocked in
or the infra-red LED is driven. When
two data words are received, they are
compared with each other. If they are
identical, and the address is 79, a set-
up routine is started. Here again, writ-
ing to the EEPROM only takes place
when necessary. If the address is iden-
tical to the loco address, all data bits are
passed on and the various functions of
the decoder set.
the board, place the relevant SMD
component in the correct position and
heat the tinned pad again. When the
component sinks into the solder,
remove the soldering iron. Do not
move the component during the cool-
ing of the tin. When the tin has cooled
(blowing helps), solder the other ter-
minal of the component into place in a
similar manner. If necessary, re-heat
the first solder joint to make the tin
flow smoothly.
Solder all components in this man-
ner, starting, as always, with the pas-
sive ones and ending with the ICs. If
desired, IC 1 may be placed in a suitable
socket. Use one with turned pins.
However, if a socket is not used, the
finished board is significantly thinner
and this may be a great advantage in
smaller locomotives. Pay good atten-
tion to the polarity of diodes D 10 and
D 11 .
For the convenience of constructors,
the components side of the a.c. and d.c.
versions are shown
separately in Figure 4 .
Note that on the a.c.
R 3 = 270 k
*
R 4 = 270
*
R 6 = 47 k
*
Capacitors:
C 1 , C 2 = 22 pF*
C 3 = 0.047 µF*
C 4 = 10 µF, 35 V*
C 5 = 47 µF, 10 V*
Semiconductors:
D 1 –D 4 , D 10 , D 11 = 1N4001*
D 5 –D 8 = LL4148*
D 9 = 5.1 V zener BZV55C*
D 12 = Infra-red LED LD261
T 1 = BC857C*
T 2 –T 5 = MJD6039*
Integrated circuits:
IC 1 = PIC16F84* (available pro-
grammed under Order No.
996523-1 —see Readers Services
toward the end of this issue)
IC 2 = ULN2004*
CONSTRUCTION
The decoder is best built on the dou-
ble-sided printed-circuit board shown
in Figure 4 . Building is not an easy job
for a beginner in electronic construc-
tion, since it involves surface-mount
components.
Using a soldering
iron with a small solder
tip, tin a single pad on
Miscellaneous:
X 1 = 4 MHz resonator (see text)
PC B Order no. 990071-1 (see Read-
ers Services toward the end of this
issue)
Figure 5. Auxiliary cir-
cuit intended for man-
ual adaptation of the
registers.
* Surface-mount version
20V
D1
5
1N4001
R1
R6
D2
T2
1N4001
S1
1
16
BD560
S2
Vdd
R2
22k
5
D5
11
R5
8...16V
6
C4
D6
S3
IC1
12
1n
7
D6
D7
MC
R3
10k
R4
10k
9
145026
13
S4
D8
T1
1N4001
10
D9
RS
15
GND
BC109
D3
S5
14
8
T2
1N4001
C1
D5
C3
S6
GND
220µ
25V
8V2
100µ
16V
BD560
R7
C2
20V
D4
220µ
25V
1N4001
990071-14
Elektor Electronics
10/99
53
138906022.028.png 138906022.029.png 138906022.030.png 138906022.031.png 138906022.032.png 138906022.033.png 138906022.034.png 138906022.035.png 138906022.036.png 138906022.037.png 138906022.038.png 138906022.039.png 138906022.040.png 138906022.041.png 138906022.042.png 138906022.043.png 138906022.044.png 138906022.045.png 138906022.046.png 138906022.047.png 138906022.048.png 138906022.049.png 138906022.050.png 138906022.051.png 138906022.052.png 138906022.053.png 138906022.054.png 138906022.055.png 138906022.056.png 138906022.057.png 138906022.058.png 138906022.059.png 138906022.060.png 138906022.061.png 138906022.062.png 138906022.063.png 138906022.064.png 138906022.065.png 138906022.066.png 138906022.068.png 138906022.069.png 138906022.070.png 138906022.071.png 138906022.072.png 138906022.073.png 138906022.074.png 138906022.075.png 138906022.076.png 138906022.077.png 138906022.079.png 138906022.080.png 138906022.081.png 138906022.082.png 138906022.083.png 138906022.084.png 138906022.085.png 138906022.086.png 138906022.087.png 138906022.088.png 138906022.090.png 138906022.091.png 138906022.092.png 138906022.093.png 138906022.094.png 138906022.095.png 138906022.096.png 138906022.097.png 138906022.098.png 138906022.099.png 138906022.101.png 138906022.102.png 138906022.103.png 138906022.104.png 138906022.105.png 138906022.106.png 138906022.107.png 138906022.108.png 138906022.109.png 138906022.110.png 138906022.002.png 138906022.003.png 138906022.004.png 138906022.005.png 138906022.006.png 138906022.007.png 138906022.008.png 138906022.009.png 138906022.010.png 138906022.011.png 138906022.013.png 138906022.014.png 138906022.015.png 138906022.016.png 138906022.017.png
Table 2. Programming
table for setting up the
decoder.
Table 2
Trit 98765
0
LLLL0
program loco address
1
MMM01
program maximum speed
2
AAA0X
program rate of acceleration/deceleration
version transistors T 4 and T 5 as well as
resistors R 9 and R 10 are not used, but
that two wire bridges are put in their
place. Connecting the motors has
already been described earlier.
In Märklin locomotives, the head-
lights and frontal signals are usually
interlinked at one side of the body of
the locomotive. This arrangement may
be kept for the present decoder. It
should be noted, however, that in the
case of two-rail operation the intensity
of the lights may be affected, depend-
ing on the polarity of the rails. It is,
therefore, better to supply the lamps
and other users connected to the func-
tion outputs from the +V terminal
(M 3 ).
Finally, note that no provision has
been made on the board for the infra-
red LED and associated resistor: these
should be mounted elsewhere. This
should, of course, be done in such a
manner that the diode points in the
direction of the infra-red decoder.
4
SSS11
program brightness of headlights
5
KKK1X
program flashing rate of function 4
loco addresses
data settings
LLLL
LLLL
MMM
AAA
SSS
KKK
0
0000*
40
1111
0
000
1
0001
41
111X
1
001
2
000X
42
11X0
2
00X
3
0010
43
11X1
3
010
4
0011
44
11XX
4
011
5
001X
45
1X00
5
01X
6
00X0
46
1X01
6
OX0
7
00X1
47
1X0X
7
0X1
8
00XX
48
1X10
8
0XX
9
0100
49
1X11
9
100
10
0101
50
1X1X
10
101
11
010X
51
1XX0
11
10X
12
0110
52
1XX1
12
110
13
0111
53
1XXX
13
111
SETTING UP
Five registers have been reserved in
the EEPROM to set the following
functions: the loco address, the maxi-
mum speed, the rate of acceleration
and deceleration, the brightness of the
headlights, and the flashing rate of
function 4.
The registers are set by a combina-
tion of data bits at loco address 79.
Since this applies to all loco decoders,
make sure that there is only one loco-
motive on the track, otherwise all loco-
motives are programmed with the
same settings. Possible loco addresses
and data settings are shown in Table 2 .
When trit 5 is 0, a loco address will
be programmed according to data trits
6–9. When trit 5 is x (01) or 1 (11), the
other registers can be programmed:
which ones depend on trit 6. All this is
arranged by the EEDTS Pro software.
Where stand-alone working is
wanted, the registers may be adapted
with the aid of the auxiliary circuit
shown in Figure 5 . This is based on a
Motorola 145026 (transmitter) that is
permanently set to address 79. There is
no ready-made printed-circuit board
for the auxiliary circuit, so this will
have to be built on a small piece of pro-
totyping board or similar.
The data trits can be set with five
miniature 3-position switches in accor-
dance with the codes shown in Table 2.
When the push-button switch is
pressed, the data appear at the output
in serial form and the loco decoder is
programmed with the set value. When
the loco address is being set, the value
14
011X
54
X000
14
11X
15
01X0
55
X001
15
1X0
16
01X1
56
X00X
16
1X1
17
01XX
57
X010
17
1XX
18
0X00
58
X011
18
X00
19
0X01
59
X01X
19
X01
20
0X0X
60
X0X0
20
X0X
21
0X10
61
X0X1
21
X10
22
0X11
62
X0XX
22
X11
23
0X1X
63
X100
23
X1X
24
0XX0
64
X101
24
XX0
25
0XX1
65
X10X
25
XX1
26
0XXX
66
X110
26
XXX
27
1000
67
X111
28
1001
68
X11X
29
100X
69
X1X0
30
1010
70
X1X1
31
1011
71
X1XX
32
101X
72
XX00
33
10X0
73
XX01
34
10X1
74
XX0X
35
10XX
75
XX10
36
1100
76
XX11
37
1101
77
XX1X
38
110X
78
XXX0
39
1110
79
XXX1
80
XXXX*
*) cannot be set on Märklin equipment
in the loco table is superseded by that
set with the diode matrix. In principle,
it is, therefore, possible to supersede all
values in the table by soldering all
diode combinations once.
The decoder may be supplied by
the ±20 V line from the EEDTS booster
amplifier or by a mains adaptor with a
secondary alternating voltage of
8–16 V.
[990071]
Elektor Electronics
10/99
55
138906022.018.png
Zgłoś jeśli naruszono regulamin