Page 1 of 1

Shelf Layout

Posted: Wed Apr 08, 2020 9:03 pm
by oliverwhorwood
Bits ordered up for my first T-Gauge layout, the imaginary station of Sellyhurst on the line of Woodham-Barnford to be assembled on a 120cm x 25cm shelf.
This will initially include a 3 unit Southern class 377 on 20m chassis with DCC control including white and red switchable lights. Oneway points at either end so train travels back on left track and an electric point for the siding. This will all be connected up to a motor shield and Arduino Uno including DCC, points control and magnetic positioning sensing. Stickers will be printed off for the body shells using texture pictures from a 3d model found online (attached for interest).

The extention to the track will use all existing sections of track exluding one 6mm straight. This will have a loop circuit round the back of the shelf using flexitrack at a 10cm radius (will have to experiement and see if this is too tight). Plus an extra siding, and two extra platforms with electric points and another 3 unit 377.

First implementation:
shelf v1.jpg
Extension for later date:
shelf ext.jpg
Southern class 377 livery

Re: Shelf Layout

Posted: Thu Apr 09, 2020 12:27 pm
by gbtrains

that will look very cool on as a shelf display whilst running the 377's around.

Have fun in building.
Let us know how it goes for DCC control's :D


Re: Shelf Layout

Posted: Fri Apr 17, 2020 10:57 am
by oliverwhorwood
Changed the design slightly to try and replicate the real station of Sittingbourne in Kent. This has a service from Swale - Sittingbourne on Class 375/3 Southeastern. Three platforms and one siding. Managed to get the motorised chassis up and running using Arduino PWM at 122.55 Hz.

Has anyone got any tips on how to make the one-way turnouts more reliable?

The new layout:
shelf ext.jpg
Sittingbourne Map.png

Re: Shelf Layout

Posted: Sat Apr 18, 2020 11:27 am
by mattd10
Looking great! Are you just using the outputs from the arduino or going via a motor shield? Looks like its running well!

Re: Shelf Layout

Posted: Sat Apr 18, 2020 5:35 pm
by oliverwhorwood
Thanks Mattd10! Just going straight from the Arduino for this test and making sure to keep the average output below 4.5V. It's running well on straights, however need to replace the one-way turnouts with motorised as they are no good when shunting unpowered (non-magnetic) chassis's through and follow the thrown direction instead of straight on so derails.

Re: Shelf Layout

Posted: Sat Apr 18, 2020 7:49 pm
by sidneylopsides
Oh of course, I had only looked at DIY DCC for larger scales previously, and it hadn't clicked that you could run it directly. The voltages and current are low enough for the output pins, and I found an old Uno in a box the other day.

Your layout is looking great so far, the smoothness of the stop in that video is impressive.

Re: Shelf Layout

Posted: Mon Apr 20, 2020 1:37 pm
by oliverwhorwood
Hi sidneylopsides, thanks! Straight from Arduino is fine for PWM direct control. For DCC you actually require a motor shield as the voltage for this is 13V ish. A board based on the L298N is perfect for this, available on eBay for around £4. A 15V power supply is needed as the board uses about 2V.
F93HPKMID2XEAO7.LARGE.jpg (61.22 KiB) Viewed 2232 times
This has two inputs for direction control and the Arduino outputs the DCC PWM on one pin. Therefore a transistor in NOT gate configuration (one component) is needed to control the board.

For the sensors I am using Hall effect sensors which measure the magnetic field strength of the magnets under the chassis. These go through a comparator to send a signal when the threshold (set by potentiometer) is met.

For turnout control, two pins on the Arduino are used, one for each motor direction. With slight modification of the DCC++ code, this can trigger a pulse of 0.3s on either of these pins to throw and close.

Re: Shelf Layout

Posted: Thu May 14, 2020 1:30 pm
by sidneylopsides
Any chance you could share what code you used for your Arduino?
Is it just a basic PWM control sketch?

I was thinking about DCC, couldn't we simplify things by removing the 13V stuff? We're using a 5V base station and a 5V motor, and the only reason to use higher voltage is because larger scales use it as standard. Attiny 85 function decoders can be made with basic boards, so something like an ATTiny could be used directly with PWM to the motor from a pin, like your Arduino demo above.

Re: Shelf Layout

Posted: Thu May 14, 2020 4:26 pm
by oliverwhorwood
PWM and DCC are two seperate things.

DCC requires a decoder in the locomotive which decodes the 13V voltage on the rail and outputs 5V PWM to the motor. The voltage is actually AC but as a square wave - hence the seperate motor driver. Note the benefit of DCC is that multiple locos can be run on the same track whereas direct PWM will move all locos on that isolated section of rail.

PWM can be used to directly power the motor using a voltage of up to 4.5V. Note that most ATMega and Attiny controllers will output a max of 5V so care is needed not to supply the load (motor) with too much voltage.

Re: Shelf Layout

Posted: Thu May 14, 2020 4:35 pm
by oliverwhorwood
void setup() {
// put your setup code here, to run once:
TCCR2B = TCCR2B & B11111000 | B00000110; // set timer 2 divisor to 128 for PWM frequency of 245.10 Hz


void loop() {
// put your main code here, to run repeatedly:

int pot = analogRead(A0);
int pwm = map(pot,0,1023,0,255);