2014 part 3 – DIY electronics

Where is my train?

Next sub-project: Where is my train? In other words: The feedback module from Uhlenbrock is not really compatible with Märklin M-track. To use the module I must either use magnets and reed switches or I must isolate one rail from the other in a section of track.

I do not think reed switches are easy to work with. And isolating a rail on M-track is impossible.

More surfing on the Internet. I ended up concluding that I have to choose between voltage sensors and current sensors. I chose current sensors, even though it means a little less voltage for the locomotives. I made the choice for these reasons:
1. My transformer has a high enough voltage and can provide plenty of current, so a little waste means nothing.
2. I could not find anywhere to buy the coils that are needed to build a voltage sensor.
3. I found a very cheap and easy way to build current sensors. And I even had all the needed components for a prototype, that worked fine right away.

I could maybe just switch the Uhlenbrock feedback module. There is an other model that is meant for 2-rail track, i.e. a module with built-in voltage or current sensors. But that is almost twice as expensive and it has only 8 input ports, whereas the 3-rail version has 16. So in effect, it is 4 times as expensive.

I could have gone all the way and built the entire feedback module myself. The LocoBOD project from SourceForge would probably work just as well and would easily be able to combine with my cheap current sensors.

But it is a bit of a mouthful to obtain and set up both a programmer for Atmel microcontrollers and a WinAVR development environment (as far as I understand, binary LocoNet code cannot be downloaded anywhere, because distributing it would violate Digitrax’s rights) in order to be able to compile the source code and download the generated binary to the micro controller. And with just a single module so far, and with a bigger urge to play with application code and to drive my trains than to play with micro controllers and embedded code, I am sticking to the 3-rail module from Uhlenbrock.

DIY electronics for current sensors, turnouts etc.:

Simultaneously with working on the feedback system, I also started to investigate how to build decoders for my turnouts and for the signals, that must also be part of my layout.

I got as far as an accessory decoder from OpenDCC for signals and Paco’s official website and his 4-servo decoder for turnouts. This lead to the next shopping round:

1. Micro servos meant for model planes (rc-netbutik.dk), but by me meant for turnouts and maybe some day to make a skater, a boat on a lake or a port in an engine house or something else that should move.
2. PIC programmer, PIC circuits, assorted capacitors and resistors, a larger amount of power diodes etc. – enough for both current sensors and a couple of decoders of each kind mentioned above. (reichelt.de)

I have combined current sensors and the Uhlenbrock feedback module on a veroboard:

Processed with Snapseed.
Uhlenbrock feedback and a lot of current sensors

Each individual current sensor is made from very few components. They seem to be very reliable. The capacitor shown below is not necessary, so I have not added it. It was meant to prevent bouncing. But there is a timer function built into the Uhlenbrock module, so that it does not clear the signal until the input has been stable for a configurable number of miliseconds. And that provides the exact same functionality:

Processed with Snapseed.
Diagram for a single current sensor

Pacos 4-servo dekoder was very easy to build. But you will not come far without a PIC programmer. And some decent soldering equipment, obviously. And a a reliable multi-meter. And a few other tools.

I have been building the decoder on a small piece of veroboard:

Processed with Snapseed.

Later experience shows that Paco may have saved a little too much on capacitors. One of my decoders has become unstable, i.e. CV values seems to change themselves and turnouts do not move as they should.

The decoder has therefore been upgraded with bigger capacitors. Paco suggests 100 uF between rectifier and 7805 voltage regulator and 100 nF on the other side of the regulator. I have changed that to 470 uF and 100 uF. And then I have added a third capacitor (100 nF) close to pin 1 on the PIC between pin 1 and ground.

JMRI – my first experience with PC software to control model trains

Now that I know where my trains are, I could get on with the software part. I decided to try JMRI. It is open source and there by kind of the DIY style.

My education as well as my profession is all about developing software. So I am pretty sure all is going to be well, even though my first experiences shows that it does not work just out of the box: The IB-COM interface/”driver” in JRMI does not reliably recieve status from my feedback module, and thereby I don’t know where my trains are anyway. And in addition, it cannot control the turnouts. But I have solved both problems and sent the corrections back to the JMRI community.

I have however not yet testet JRMI properly. I.e., I have no idea which additional problems that might pop up, before my trains are automated. But I have a feeling that there may be multiple problems hidden inside JRMI.

It is very difficult to read the documentation and thereby get an overview of JRMI. It al seems a bit – to put it nicely – half done. Just to get basic “hole through”, I had to (as already implied) to install a Java development environment including a debugger and then simply start an ordinary debugging of the software.

See also this page about my choice of software.

Summer break 2014:

Around the month of April and thereby the gardening season, I ran into a mechanical problem: I had built the servo decoders, but I could not mount the servos at my turnouts and make them work.

So no servo controlled turnouts.

Only greenhouse, lawn and tomatoes.

But decoder and servos work just fine, so I will make it work next fall.