The Folding Board Project Back to the BMRC Home Page


Based on the Winter Wonderland board, construct a new board the folds for easy transport and has a PIC controlled system incorporating a game for children.

A PDF of this build log can be downloaded here.





00 Gauge Track


Enough to make two loops on the board including a siding loop

00 Gauge Points, Left Hand


A single 00 Gauge point, left hand

00 Gauge Points, Right Hand


A single 00 Gauge point, right hand

Hornby Point Motors


R8014 - Point Motor and R8015 - Point Motor Housing (Adaptor Base)

9-way D-Type Plug


Command connector for the Board and extension cable

9-way D-Type Socket


Command connector for the control box and extension cable

6-way DIN Plug


Power connector wired to the Dual Power Controller

6-way DIN Socket


Power connector mounted to the Board

Black ABS Box 2x3x2


Box to contain the four control switches

Red Push-to-Make Switches


Two red control switches for Start-Stop and Loop Isolate

Black Push-to-Make Switches


Two black control switches for Siding-Park and Siding-Release

9-way D-Type Hood


Hood for each end of the extension cable

25-way D-Type Plug


Underside board connector to transfer power and points over the fold

25-way D-Type Socket


Underside board connector to transfer power and points over the fold

25-way D-Type Hood


Hood for each of the underside connectors



PIC IO Dev Board


Power Jack (2.1mm)

1 Order Code: HH60Q



Red Wire

10m Order Code: FA33L

Blue Wire

10m Order Code: FA27E

Black Wire

10m Order Code: FA26D

12VDC Regulator Board




Maplin Part #

TS7812CZ Regulator


Order Code: QL32K

100nF Polyester Capacitor


Order Code: N43CJ

100uF Electrolytic Capacitor


Order Code: KQ70M

4700uF Electrolytic Capacitor


Order Code: AT24B

1N4001S Diode


Order Code: QL73Q

1K0 1/8W Resistor


Order Code: M1K

5mm Red LED


Order Code: WL27E

Two terminal PCB mount block


Order Code: RH80B

Train controller


Hornby R8012 HM 2000 Dual Power Controller

Table 1: Bill of materials

Part One - Hardware

Building the board

The most complicated part of the construction is making the folding base board. The board must be light and flexible to be hinged, but sufficiently sturdy to mount the track and control electronics. The decision was made to design the board to make it easy to fold, transport and erect with the electronics being fitted later.

Laying the track

Lay the track onto the board so that the following layout is created.

Fitting the Electronics

The electronics can now be fitted to the board in the following order
1: Control Board and sockets
2: Point Motors
3: Power Transfer connector
4: Control Connectors
5: Wiring runs

Control Board and sockets

The PIC-IO-Board, CDU and point switches (Darlington Pair open collector) were all wired to a piece of hardboard sheeting and tested in isolation. This was done to aid construction and to ensure that testing was made easier. The figure below shows the components mounted. Once tested the Control Board is then inserted into the Folding board. It was decided to place the Control Board in one corner of the board to simplify wiring. The figure below shows the Control Board mounted.

Point Motors

The holes for the points were made and then wired to the board. The figure below shows one of the points. The other point is mounted in a similar manner.

Power Transfer connector

The power Transfer connector was then wired and connected to the board using block connectors so as to not tension the wires. The two figures below shows how the Transfer connector is wired.

Control connectors

The connectors to bring power and allow the control box to be connected are then fitted to the board. The figure below shows how the power (6-way DIN) and command (9-way D-Type) is mounted. The Velcro to the right of the D-Type is used to hold the control box when not used.

Wiring runs

The points, track power, Transfer connectors and control board are then wired together. The two figures below show the complete wiring looms.

Part Two - Software


The control software has been written in Microchip C using the MPLAB IDE ( and is modularised into components:-
main.c: This file contains the main track control algorithms.
track.c: This file contains the routines to control the board.
usart.c: This file contains the routines to communicate via the RS232 port.
track.h: This file contains the function headers and constant defines for track.c.
usart.h: This file contains the function headers and constant defines for usart.c.

The compile source code from the above five files is included in Appendix A as hex code ready for programming into a PIC16F628A using an appropriate programmer. The software was programmed to the PIC16F628A using the Microchip PIC Start Plus ( as this is what the Author already had.

This is however a legacy product and Microchip recommend using the PICkit 2 Starter Kit ( instead.


The software has been tested using a PIC16 Simulator ( prior to being installed in the test track.

The majority of the testing has been done on the Test Track board with the RS232 debug output connected to a laptop via an RS232 to USB converter running HyperTerminal under Windows XP Home SP3.

This document was last modified: .