Location and Automation
I've fitted an L&B open wagon with various experimental circuits. This includes a location device, sound and eventually a camera.
I've looked at various ways of impementing location detection. Ideally GPS would have been good but it isn't accurate enough at this scale. There is also magnets and Infra-Red which is commercially available for LGB type layouts. I've tried magnets, with two sensors either side of the wagon and that sort of works but in the end I decided to opt for RFID (radio frequency identification) contactless cards.
There are two main types of contactless cards Those that operate at 125kHz are used in security and access control. Those that operate at 13.5Mhz are used in banking and concession bus passes. I've tried both but have chosen 125kHz because of the greater range and the aerial is easier to hide.
The cards (painted and hidden with ballast) are placed under the track and the card reader is located in the wagon with the coil underneath. As the wagon passes over the card it will register the card number and from this the location will be known. The cards can be read at a distance up to 3cms but because the train is moving, the coil has to be placed closer than this to give time for the card to be powered and to transmit it's serial number.
The location id will be sent as an MQTT message for any other device to see. The hand-held controller and PC controller will display the named location and locos will use it for automatic operation.
The components within the wagon are:
PCB containing Wemos D1 mini microcontroller, step-up regulator and Dfplayer sound chip
RDM6300 125Khz control board
Lithium battery and associated charing/protection circuitry
The automation schedule is programmed using a simple code. This is downloaded from a textfile on the Raspberry Pi when the loco is switched on, so it can be easily changed. A future option will enable the hand-held controller to select from a number of different schedules.
Each line of the schedule contains the following:
location id, mode, speed, stop time, options (in binary for clarity), acceleration/de-acceleration (milliseconds per speed unit) and points
mode = 1 (normal), 2 (timed stop), 3 (random timed stop)
options are not used, n/u, n/u, n/u, token, whistle, lamp on, direction (0=forward, 1=reverse)
0, 2, 8, 10, 00000010, 400, 0 // Auto start initial settings: wait 10 seconds, then speed = 8, lamp on, acc = 400
1, 1, 14, 0, 00000110, 400, 0 // normal, speed = 14, lamp on, whistle, forward, acc = 400,
16, 1, 16, 0, 00000010, 200, 0 // normal, speed = 16, lamp on, forward, acc = 200,
20, 1, 10, 0, 00000010, 200, 0 // normal, speed = 10, lamp on, forward, acc = 200,
66, 2, 9, 40, 00000000, 400, 0 // timed stop, stop for 40 seconds, then speed = 9, lamp off, forward, acc = 400
72, 1, 12, 0, 00000010, 400, 0 // normal, speed = 12, lamp on, forward, acc = 400
0 // Repeat from second entry
The points field is for future use. The loco will send the points field as a message at each location. The ESP8266 controlling the points will receive this message and adjust the points accordingly.
The token option is again for future use. I'm looking forward to implementing this.
Following widespread testing, I've realised that using a wagon for location is much easier than installing it in each loco. The coil assembly is also less noticeable under a wagon. The wagon will eventually be covered so that the electronics aren't visible and I am also going to include the circuitry in a coach.
Here's a video of a loco under automatic control on an extension that is currently under construction. There are 3 cards on this section, the one on the curve slows the loco as it approaches the station and one at the station brings the loco to a halt. The loco will start again after the appropriate delay.
Must stop hummimg when I take a video!