This is only a preview of the March 1994 issue of Silicon Chip. You can view 34 of the 96 pages in the full issue, including the advertisments. For full access, purchase the issue for $10.00 or subscribe for access to the latest issues. Items relevant to "Build A 50W Audio Amplifier Module":
Articles in this series:
Items relevant to "Level Crossing Detector For Model Railways":
Items relevant to "Switching Regulators Made Simple":
Items relevant to "Voice Activated Switch For FM Microphones":
Articles in this series:
Items relevant to "Build A Simple LED Chaser":
Items relevant to "Computer Bits":
Articles in this series:
Articles in this series:
|
Level crossing detector
for model railways
Add realism to your model train layout with
this level crossing circuitry. It will detect the
approach of a train, monitor its passing &
provide an output to control circuitry to flash
lights & sound a synthesised bell.
By JOHN CLARKE
Most model train enthusiasts will
want to include at least one level
crossing on their layout. Such a feature increases the realism since it is
so commonplace on real railways and
the effect is heightened if you have a
convincing sound and lights display.
This month we are presenting the
level crossing detector circuitry and
this will be followed next month with
an accompany
ing sound and lights
module. This will flash the lights at a
similar rate to the real live units and
38 Silicon Chip
will even go so far as to simulate the
distinctive ding ding of the bell, right
down to the random variation in the
bell ringing which is so characteristic
of level crossing bells.
The train detector circuit is suitable
for both single and double track crossings and it also caters for situations
where there are points to a siding in
the track immediately before or after
the crossing. This is often the case in
rural areas.
The circuit is designed to detect
the train as it approaches the crossing
and start the lights and sound module.
When the train has passed through the
crossing, the lights and sound module
is turned off. Two train sensors are
required, one before the crossing and
one after. They will need to be placed
sufficiently far from the crossing to
simulate realism. This will depend
on the size of the layout, the length
of trains being run and the operating
speeds.
The sensors are Hall Effect devices
measuring 4.5 x 4.5 x 1.5mm and are
placed directly between the sleepers of
the train track. With typical ballasted
track, they will be virtually invisible.
They provide a signal in the presence
of a magnetic field. At least two magnets must be concealed under each
train, one under the leading locomotive and one under the last wagon at
the end of the train. We expect that
constructors will want to fit all their lo-
ROAD
LIGHTS
1A 2A
TRACK
SENSOR
A
SENSOR
B
1B 2B
LIGHTS
MAGNET
MAGNET
REAR
CARRIAGE
Fig.1a (left): this diagram
shows the general
arrangement of a railway
crossing with the sensors in
place. Each sensor is placed
at a realistic distance away
from the intersection so
that the crossing lights will
provide sufficient warning
of an approaching train. If
the crossing also includes
points, as shown in Fig.1b, a
third sensor is required.
MIDDLE
CARRIAGE(S)
ENGINE
Fig 1a
SENSOR
C
LIGHTS
ROAD
SENSOR
B
SENSOR
A
LIGHTS
Fig 1b
comotives and guards’ vans (cabooses)
with magnets, as well as any wagons
with end-of-train flashers.
The circuitry is designed to count up
to 15 magnets per train which should
give a lot of versatility in how each
train is made up. This will cater for
double, triple and quadruple heading
of locomotives. If the number of cars
with magnets in a train exceeds 15, the
circuit may briefly interrupt the sound
and lights module while the train is
passing through the crossing but this
is unlikely to be noticed.
Fig.1 shows the general arrangement
of a railway crossing with the sensors
in place. Each sensor is placed at a
realistic distance away from the intersection so that the crossing lights
will provide sufficient warning of an
approaching train. If the crossing also
includes points as shown in Fig.1b, a
third sensor is required. Note that the
level crossing detector will operate for
A single PC board accommodates all the parts for the level crossing detector,
except for the magnets & track sensors.
trains travelling in either direction. If
there are two tracks, then two separate
train detector circuits will be required
and their outputs are connected in
parallel.
How it works
Fig.2 shows the block diagram
of the level crossing train detector.
This shows three Hall effect sensors
which detect the magnets under the
train. The output from sensor A is
amplified by op amp IC1a and then
fed to a window comparator comprising IC2a & IC2b. Upon detection of
a magnet by the sensor, the window
comparator clocks the DOWN input
of counter IC3.
Sensor B and sensor C, connected
to op amp IC1b, are in parallel so that
either sensor can detect the presence
of a magnet. IC1b drives a window
comparator comprising IC2c and IC2d
which clocks the UP input of counter
IC3.
In effect, IC3 counts down the pulses
from the first sensor and counts up
those from the second sensor. As soon
as the count of IC3 changes from zero
(either up or down), zero detector circuit IC4 goes low, to turn on the sound
and lights module.
March 1994 39
RESET
AMPLIFIER
IC1a
COMPARATOR
IC2a,b
SENSOR
A
COUNT DOWN
COUNTER
IC3
SENSOR
B
SENSOR
C
'0'
DETECTOR
OUTPUT
IC4
COUNT UP
IC1b
IC2c,d
Fig.2: the Level Crossing Train Detector uses Hall Effect sensors to detect
magnets mounted under the train. The outputs from the Hall effect sensors are
amplified & fed to two window comparators (IC2a,b & IC2c,d) which clock UP/
DOWN counter IC3. IC3 in turn drives zero detector stage IC4.
Initially, IC3 is set to zero when
power is first ap
plied. As soon as
a train is detected by sensor A, IC3
counts down by one and the zero detector switches to activate the sound
and lights module. As each train magnet passes over sensor A, IC3 counts
down by one. When the train passes
over sensor B, IC3 counts up by one
for each train magnet until the train
has passed.
Since the number of magnets which
pass over sensor A must equal the
number of magnets which pass over
sensor B, IC3 will ultimately count
back to zero and this will switch off
the sound and lights module. In the
unlikely event that there is some problem, there is a manual reset switch for
the counter to be set back to zero.
Now let’s have a look at the complete
circuit for the train detector which is
shown in Fig.3.
The Hall effect sensors, A, B and C,
are powered from 5V and provide an
output voltage at their pin 3 which
is about half supply. When the south
pole of a magnet is brought near the
labelled side of the sensor, the output
swings high while for a north pole the
output will swing low. Note that these
Hall effect sensors are linear types
without logic output circuitry. They
have been specified because they have
higher sensitivity.
The sensors are AC-coupled to the
following amplifier circuits, IC1a for
sensor A and IC1b for the B and C
sensors. Trimpots VR1, VR2 & VR3
provide facility to adjust the gain of
the amplifier for each sensor so that
the magnets can be detected reliably.
The 0.1µF capacitors across the
1MΩ feedback resistors for IC1a and
IC1b reduce the amount of noise at the
amplifier outputs and prevent false
triggering of the following comparator
stages. IC1a and IC1b are biased at half
supply by the 10kΩ voltage divider
network at pins 3 & 5.
As mentioned above, IC2a and IC2b
comprise a window comparator. This
is so-named because it has two voltage thresholds, the upper at +2.92V
(pin 9) and the lower at +2.22V (pin
12). IC2a & IC2b have open-collector
outputs and these are connected together and to a common 3.3kΩ pullup
resistor. So when ever the commoned
inputs at pins 8 & 11 are within the
window, both com
parator outputs
are high.
However, when the inputs are pull
ed above +2.92V or below +2.22V, the
commoned comparator output goes
low and the negative transition is
coupled to the COUNT DOWN input
of IC3 (pin 4) via a 330pF capacitor.
Both the upper and lower thresholds
of the comparators have hysteresis,
as set by 100kΩ resistors to pins 9
& 11. Thus, when the voltage at the
output of IC1a goes above the 2.92V
threshold of IC2a, IC2a’s output goes
low. The 100kΩ resistor between pins
9 & 14 pulls pin 9 down to +2.72V so
that IC1a’s output must go below this
2.72V threshold before IC2a’s output
can go high again. This provides about
200mV of hysteresis.
Similarly, when the output of IC1a
goes below the +2.22V threshold of
IC2b, its output goes low and the
100kΩ resistor between pins 13 & 11
pulls the voltage at pin 11 down by a
further 200mV. This again provides
200mV of hysteresis.
Thus the commoned output of
IC2a and IC2b goes low whenever the
output of IC1a goes above +2.92V or
below +2.22V.
The window comparator comprising IC2c and IC2d works in exactly
the same fashion. It drives the COUNT
UP input of IC3 via a 330pF capacitor.
Diodes D2 and D3 protect the count
inputs of IC3 by clamping them to
0.6V above the 5V line, each time the
window comparator outputs go high.
IC3 is an up/down 4-bit binary
counter which has a maximum count
of 16. It is reset by a power-on reset
provided by the 10µF capacitor and
The position of the train is sensed by using two or more
Hall effect sensors to detect magnets mounted in wagons
at either end. The Hall effect sensors are mounted under
the track, flush with the sleepers (see above).
40 Silicon Chip
+5V
3.3k
100k
0.1
8.2k
0.1
+2.92V
1M
1
2
47
3 BP
VR1
100k
2
3
SENSOR A
UGN3503U
9
8
7
1
IC1a
LM358
100W
D2
1N4148
3
IC2a
LM339
2.2k
14
LOAD
4 COUNT
DOWN
100k
2.7k
13
IC2b
RESET
S1
12
+5V
14
COUNT
UP
12 3
10k
8
CLEAR
100k
C
E
VIEWED FROM
BELOW
10k
10
8.2k
B
5
+5V
10
+2.92V
2
VR2
100k
0.1
SENSOR B
UGN3503U
2
7
100
47
3 BP
SENSOR C
UGN3503U
D3
1N4148
7
6
QC
QD
3
6
7
12
9
8
14
IC2c
2.2k
10
IC4b
4.7k
6
5
4
330pF
10k
D1
1N4004
5
+2.22V
VR3
100k
4
Q1
BC548
B
C
OUTPUT
E
2.7k
IC2d
+5V
IC4c
1
100k
1M
+5V
1
6
IC1b
QA
2
11
5
47
3 BP
1
100k
8.2k
+5V
B QB
IC4a 13
4071 7
3.3k
1
9
D
IC3
40193
11
LABEL SIDE
10
C
+5V
+2.22V 12
15
A
4.7k
4
11
16
330pF
2
180
0.5W
+5V
12V
INPUT
1000
16VW
ZD1
5.1V
400mW
470
16VW
8.2k
LEVEL CROSSING TRAIN DETECTOR
USED ONLY FOR SWITCHED
TRACK LAYOUTS
Fig.3: the complete circuit for the Level Crossing Train Detector. When a sensor
detects a train magnet, the output from its corresponding window detector goes
low & clocks IC3 (the UP/DOWN counter). OR gates IC4a-4c detect the zero state
& drive Q1 for all other counts.
100kΩ resistor at the clear input (pin
14). Switch S1, connected to the Clear
input at pin 14, allows the counter to
be reset at any time.
The binary outputs of IC3 are monitored by 2-input OR gates IC4a and
IC4b. These have a high output when
any input is high. IC4a and IC4b are
in turn monitored by OR gate IC4c.
Its output goes high whenever any of
the outputs of IC3 are high. Thus, the
output of IC4c is low only when IC3
is reset or at “0”. IC4a drives transistor
Q1 via a 10kΩ resistor.
So let’s now recap on how the circuit works. The Hall effect sensors
detect magnets under locomotives and
carriages in the train as it passes. The
magnets are counted up as the train
passes over the first sensor and count
ed down as they pass over the second
sensor. The OR gate zero detector at
the output of IC3 then determines
whether the sound and lights module
is turned on or off.
Power is derived from a 12V supply
via a 180Ω resistor and is regulated using 5.1V zener diode ZD1. D1 protects
against reverse polarity connection
and also provides isolation from ripple
on the 12V supply which is decoupled
using a 1000µF capacitor.
Construction
The train detector is constructed on
a PC board measuring 140 x 79mm and
coded 15203931. We used PC mounting terminal blocks for all external
connections but PC stakes could be
used as a cheaper alternative.
Begin construction by checking the
boards for any broken tracks or shorts
on the copper pattern. Repair any
faults that you do find, then install
the resistors, link, PC stakes (if used)
and ICs. Note that IC2 is oriented differently to the other ICs. Now install
the transistor, zener diode and diodes,
making sure that they are oriented
correctly.
The trimpots and capacitors can be
mounted now but take care with the
orientation of the electrolytic capacitors. The 47µF bipolar electrolytics
can be mounted either way around.
Finally, if you are using terminal
blocks, mount these as well.
Note that if you need to use a third
sensor for points, you must install
trimpot VR3 and its associated 47µF
bipolar capacitor.
March 1994 41
ZD1
2
2.2k
3.3k
100k
2.7k
100k
100k
10k
2.2k
1
IC4
4071
+12V
GND
GND
+
1
3.3k
47uF
BP
D1
330pF
8.2k
8.2k
2
100
1
D2
4.7k
3
1
100k
VR2
IC2
LM339
2.7k
1
IC1
LM358
0.1
2
D3
TO S1
IC3
40193
330pF
8.2k
1
100
1M
0.1
10k
47uF
BP
3
SENSOR A
470uF
VR3
1
SENSOR B
8.2k
10uF
100k
SENSOR C
47uF
BP
4.7k
3
1M
0.1
10k
OPTIONAL PARALLEL
INPUT
Q1
SUPPLY
OUTPUT
1000uF
VR1
180
10uF
Fig.4: install the parts on the PC board exactly as shown here & note that IC2
faces in the opposite direction to the other ICs.
Once the PC board has been assembled, it is ready for testing. Temporarily connect the Hall Effect sensors
(sensor A and sensor B) and switch S1.
To see whether the output transistor
Q1 is switching correctly, you will
need a LED connected in series with
a 2.2kΩ resistor from the collector to
the +5V supply. You will also need to
connect up the power supply inputs
(the +12V and GND terminals).
Note that the power for the PC
boards should be obtained from a 12V
DC supply. If you built the Walkaround
Throttle described in April & May 1988
or the infrared controller described
in April, May & June 1992, you won’t
need a separate supply as this facility
is already provided.
Before applying power, check that
you have your multimeter ready to
measure the DC voltages on the PC
board. Set all trimpots to midway
initially, then apply power and check
that the voltage across ZD1 is close to
+5V. If not, switch off and find the fault
before applying power again.
With power on, you can bring a
magnet near one of the Hall sensors.
The LED associated with Q1 should
then light up.
If all is operating satisfactorily, you
can install the sensors beneath the
track. We recommend that the wires
for each sensor be bent at right angles
and passed through holes on the lay-
Fig.5: check your PC
board against this fullsize etching pattern
before mounting any of
the parts.
RESISTOR COLOUR CODES
❏
❏
❏
❏
❏
❏
❏
❏
❏
❏
❏
No.
2
5
3
4
2
2
2
2
1
2
42 Silicon Chip
Value
1MΩ
100kΩ
10kΩ
8.2kΩ
4.7kΩ
3.3kΩ
2.7kΩ
2.2kΩ
180Ω 0.5W
100Ω
4-Band Code (1%)
brown black green brown
brown black yellow brown
brown black orange brown
grey red red brown
yellow violet red brown
orange orange red brown
red violet red brown
red red red brown
brown grey brown brown
brown black brown brown
5-Band Code (1%)
brown black black yellow brown
brown black black orange brown
brown black black red brown
grey red black brown brown
yellow violet black brown brown
orange orange black brown brown
red violet black brown brown
red red black brown brown
brown grey black black brown
brown black black black brown
This photograph shows how a magnet can be mounted on the bottom of a wagon.
out. The sensors can be mounted flush
with the sleepers and can be mounted
with the label side up or down.
Magnets can be attached to the
underside of your locomo
tives and
carriages using glue or a screw and
nut. For best results, try to mount all
the magnets so that they are about the
same height above the track. For some
locomotives, there is very little room
to mount a magnet on the underside.
In some diesels, it should be possible
to fit a magnet inside the fuel tank in
place of the bottom sheet steel weight.
In steam locomotive models, it
may generally be easier to mount the
magnet underneath the tender wagon.
We used magnets from a variety of
sources, including those supplied with
cheap magnetic door catches. These
can be cut down in size by firstly scoring a line where the break is required,
then clamping the magnet in a vyce
and breaking it at the score with a
hammer. Use safety goggles when doing this, by the way. The magnets can
be mounted with either their north or
south poles facing down.
Trimpots VR1 and VR2 for sensor
A and sensor B (and VR3 for sensor
C) will require adjustment for best
results. To do this, connect your multimeter between ground and pin 1 of
IC3 on the train detector PC board. Run
the locomotive and carriages over the
sensor and adjust the associated trimpot so that the multimeter goes from a
low to a high or from a high to a low
once for each passing magnet. If the
gain is too high (ie, the trimpot is too
far anticlockwise), then the multimeter
will go high or low several times per
passing magnet. If the gain is too low
(ie, the trimpot is too far clockwise),
the multimeter may not change from
PARTS LIST
1 PC board, code 15203931, 140
x 79mm
2 6-way PC mount terminal blocks
1 momentary contact pushbutton
switch (S1)
Magnets (minimum 2 per train),
Tandy 64-1875 or salvage from
magnetic door catches
1 20mm length of 0.8mm tinned
copper wire
2 100kΩ horizontal trimpots
(VR1,VR2)
Semiconductors
1 LM358 dual op amp (IC1)
1 LM339 quad comparator (IC2)
1 40193, 74HC193 up/down
counter (IC3)
1 4071 quad 2-input OR gate (IC4)
2 UGN3503U linear Hall effect
sensors (sensors A & B)
1 BC548 NPN transistor (Q1)
1 1N4004 1A diode (D1)
2 1N4148 diodes (D2,D3)
1 5.1V 400mW zener diode (ZD1)
Capacitors
1 1000µF 16VW electrolytic
1 470µF 16VW electrolytic
2 47µF 50V bipolar electrolytic
low to high or high to low.
Some final adjustments may be necessary once the PC boards have been
incorporated in your train layout , so
allow access to the trimpots during
installation.
These final adjustments will have
to wait until the Sound and Lights
2 10µF 16VW electrolytic
3 0.1µF MKT polyester
2 330pF MKT polyester
Resistors (1%, 0.25W)
2 1MΩ
2 3.3kΩ
5 100kΩ
2 2.7kΩ
3 10kΩ
2 2.2kΩ
4 8.2kΩ
1 180Ω 0.5W
2 4.7kΩ
2 100Ω
Extras for switched track layout
1 3-way PC mount terminal block
1 UGN3503U Hall effect sensor
(sensor C)
1 47µF bipolar electrolytic
capacitor
1 100kΩ horizontal trimpot (VR3)
Parts availability
A kit of parts for this project should
be available from Dick Smith Elec
tronics, Jaycar Electronics and Al
tronics. The UGN3503U Hall Effect
sensors are available separately
from Farnell Electronics, phone (02)
645 8888. Magnets are available
from Tandy Electronics or can be
salvaged from the magnetic door
catches sold in hardware stores.
Module is built and involve running
trains over the level crossing at various
speeds. If any sensor fails to operate
reliably, it’s simply a matter of adjusting its associated trimpot. The reset
switch will come in handy during
these adjustments should the circuit
SC
malfunction.
March 1994 43
|