Model Train Speedometer V2
Introduction: Model Train Speedometer V2
UPDATED Software: Now supports speed in Miles per hour (MPH) or Kilometres per hour (KPH)
This project started off being based on an Arduino UNO. And it worded ok, I found the software published on the internet. For example https://forum.arduino.cc/t/model-railroad-speedome...
This is actually version 2 using a smaller PCB and PIC chip. It works in exactly the same way as V1, except this version now supports MPH and KPH.
I wanted to make the device smaller, neater and if possible to improve the software. With this version you can program different GUAGE (OO, HO, O, N, Z) using a press switch. You can select pre-set distances between the sensors (30cm, 50cm, 75cm or 100cm). With the 30cm version it's easier to make a "portable" version to use on your layout in different locations etc.
Why choose a PIC? Well mainly I had some left over from another project! But also they are very cheap by comparison with an Arduino and not too difficult to program.
My other main motivation was to produce one of my first PCB designs for many years! I have a kit with all the parts ready to go, or a ready made version. If you want one look on Ebay for "Model train speedometer"
The PCB has changed very slightly over time, so some of the pictures may not be an exact match.
Supplies
Your going to need
A PCB for the project or strip board to suite. A Gerber file containing the PCB design can be found here along with the other files you need to program the PIC chip.
https://github.com/coopzone-dc/Train-Speedo-V2-fil...
A PIC 16F18445 (it has been tested on other chips in the same series, they all worked ok. Make sure it's pin compatible with the PCB design if you use a PCB.)
Some method of programming the PIC chip. 936
I used two methods both work ok.
1 Was the official SNAP debugger from microchip,
2 Was an Arduino project, https://github.com/jaromir-sukuba/a-p-prog
2x Infrared sensor boards (sold mainly as Arduino collision detectors on Ebay).
LED display, either a re-cycled TM1651 display from a Gotek Drive, many on Ebay - where people have upgraded these devices and have left over displays. Or you can use the 4 digit TM1637 normally sold as 4digit Arduino Display. Only the first 3 digits are used in this project, the 4th remains blank.
SPDP pcb mounted switch (only required if you want to change the GUAGE/Sensor Distance used to calculate the speed)
Resistor 1k 1/4 watt OPTIONAL, not used yet but for future expansion.
LED 3mm any colour OPTIONAL, not used yet but for future expansion.
2.54mm headers, to enable the use of Dupont connectors, you can just solder the wires in place if you prefer.
A Standard DC 2.1mm x 5.5mm Power Socket
1n4002 diode.
LM1117 5.0v regulator, You can use the 3.3v but it will not work with the add-on Hall effect sensors very well.
2x 100uf - 47uf 25v electrolytic capacitors, exact value not critical.
3x 100nf 50v ceramic capacitors.
Step 1: Assemble the Board
1, Starting with Voltage regulator, this is the only SMD (surface mount device), the good news is it's quite a large device and is a very easy to solder. As with most SMD parts the trick is having three hands, one to hold the part in place, one for the solder and the last for the soldering iron. What you don't have three hands? No problem! I suggest you use either a clothes peg to hold it or just some sticky tape to hold it in place. The photo above is from a slightly different board, but it's the same idea.
2, Next the resistor R1, it's a normal through hole device, like all the others. Solder in place and trim the leads.
3, I suggest the LED next. Make sure you get it the right way round. The Short lead (K) goes in the hole furthest away from the resistor.
4, Next the IN4002, D1, diode. Make sure the K (white line matches the PCB).
5, Now the capacitors, the 100nf (104) can go either way round. 611