Thursday, 1 December 2022

Backscene and Signalling (1)

 Big news today - we have a back scene. This is important because, once I have buildings, etc. on the layout, I won't be able to turn it upside down to install any more electrics/electronics. The back scene means that I can balance the layout on it and have clear, supported, access to the underneath.

The back scene is made from my usual 5mm foam core. Unfortunately, it does warp a bit when exposed to acrylic paints but it will be securely stuck using hot glue. There are three boards. I used school acrylic paints in blue, white and black. I mixed the the white and blue with little blue and put that on at the lowest level. I then increased the blue for another  two stages to get an idea of the normal sky. I have to say that I didn't put enough blue in the first layer but it's too late now. Once all this was dry, I painted some white clouds on using a stipple brush. This was followed with a white/black mix to get the normal grey underside of the clouds.  I think that it does the job, especially as I am not an artist. (You can right click and see a bigger version of any image).




OK, so now down to some interesting electronics. This is still being built so you won't see it working yet.

I am arranging to put a protective signal on the exit road to the staging. When at the Warley show over the weekend I bought a Berko two aspect signal. Silly really as it is a UK style signal. I should have waited and bought an Atlas one but there we are. Maybe I will replace it. The idea is that when a train gets to the end of the staging it will trip the signal feed to go from green to red. This will happen when the loco moves into the last element of the staging road so about 8" from the end. At the same time, the track power to the whole line will be removed so, should any loco pass the red, it will stop. When the loco and train are  removed, the power will come on and the signal will revert to green.

The stuff that makes this happen is as follows:

An Arduino Uno (eventually, a Nano)
A light sensitive diode
A 5V Relay interface for Arduino
A signal - this time it is a two colour light - red and green.

The idea is that the track is isolated at that 8" distance from the end. The track at that point is fed from the relay.  The Arduino sketch (program) loops around continuously and checks the output of the light sensitive diode. Anything under 1000 as seen by the Arduino indicates that the light above the diode is being blocked. If that happens, the track current is stopped and the signal set to red. Over 1000, the power is restored and the signal turns green.

The sketch looks like this.

// Project Control Staging Track and Signal
int LED = 13; //define LED digital pin 13
int relay = 11; //define relay digital pin 11
int val = 0; //define the voltage value of photo diode in digital pin 0
int state = 1; //state of light sent. diode 1 = ON 1 = OFF

void setup(){
pinMode(LED,OUTPUT); // Configure LED as output mode
pinMode(relay,OUTPUT); // Configure relay as output mode
Serial.begin(9600); //Configure baud rate 9600
}

void turnOff() // power off to track and signal to red
{
if( state = 1 ) {digitalWrite(relay,LOW); // turn relay off
state = 0; // note state as off
}
}

void turnOn() // power on to track and signal to green
{
if( state = 0) {digitalWrite(relay,HIGH); // turn relay on
state = 1; // note state as on
}
}


void loop(){
val = analogRead(0); // Read voltage value ranging from 0 -1023
Serial.println(val); // read voltage value from serial monitor
if(val<1000){ // If lower than 1000, turn off LED
turnOff();
}else{ // Otherwise turn on LED
turnOn();
} // delay for 10ms
}


I think that if you start at the loop and follow that even a non-programmer can follow what is going on.

I am waiting for the last little bits to build the actual setup so that will be the content of the next blog entry.