fleeting quarter second of
sound, but it’s sufficient for
one strike of the bell. It’s
possible that the system can
get out of sync, for instance, if
a caboose is mistaken for an
approaching engine. Thus, the
software utilizes a 30 second
time-out to resynchronize
things. The exact way all of this
works is explained in the
source code that can be downloaded from the article link at
■ PHOTO 10.
■ PHOTO 11. A lesson learned the hard way was that pull-ups had
to be added to the port C inputs. Two leads on RN3 are
removed to prevent shorts, and the common lead is jumpered to +5V.
This crossing system has been successfully installed
on both HO and N scale layouts by several
members of my railroad club; so the bugs have been
worked out. A couple lessons were learned the hard
way. Don’t connect the PIC’s MCLR pin (which can
be reconfigured as an input) with a long cable
because it’s sensitive to electrostatic discharges
(ESD). Also, don’t assume while laying out traces on
the circuit board that you can arbitrarily reassign the
PIC’s I/O lines to untangle things. Unlike the PIC24,
the PIC16 only provides internal pull-ups on port A,
not on port C (refer to Photo 11).
The auxiliary (AUX) signal was added at the
request of a club member who wanted to have a
watchman raise a lantern. If you use an inductive
load on this signal, there should be a protection
diode (an ordinary diode connected backwards
across the coil) to suppress any back EMF. The
AUX connector also provides a regulated five volts.
If you really care about the “little people” on your
model railroad, you’ll protect them with this road
crossing signal! NV
■ FIGURE 3. Servo bracket.
PICBASIC PRO™ Compiler
Experimenter - $49.95
Silver Edition - $119.95
Gold Edition - $269.95
The industry-standard BASIC compiler for Microchip PIC® microcontrollers.
for Educational Institutions
PICBASIC™ Compiler (PBC)
Download a FREE trial version now.
www.melabs.com microEngineering Labs, Inc. 888-316-1753
PICBASIC and PICBASIC PRO are trademarks of Microchip Technology Inc. in the USA and other countries. PIC is a registered trademark of Microchip Technology Inc. in the USA and other countries.
October 2011 47