Thursday 22 August 2019

N-Scale Model Train Layout - Full Arduino Control schematic

So here is where I am up to, with Arduino Mega controlling everything:

LED signals are powered by the Arduino directly at 5v, using 2 digital pins each, with Green one side and Red the other side wired to a single pin, switching both LEDs in each signal at the same time. Signals can also be wired to 4 digital pins for independent operation of red/green LEDs on both signals.

Points (turnings) need 9v to operate, so have a permanent supply and use a relay board triggered by 5v from the Arduino. The points only need a very short pulse of 9v to move the solenoids that operate them, so I added a function to turn the relay pin on, wait 100ms and turn it off again, which is used to trigger the points rather than leaving the pin/relay turned on constantly powering the solenoid.

Track is powered at 16v, using a DC motor-driver board controlled by the Arduino. Forward / reverse is controlled by switching polarity to the rails as usual. Speed and acceleration are controlled using PWM signals.

LDR (photocell) are used to trigger events on the track. They work by resisting more current when receiving light than when light is removed, so if placed between the rails, a train passing over above them will cut light to the LDR momentarily and the change in value can be recorded. If the current being allowed through the LDR suddenly increases then the Arduino will know a train has passed over it and can trigger events accordingly, like stop at a station or switch the signals and points so another train can pass.