Photo on the left shows a 3-aspect signal (GREEN-AMBER-RED) while signal on right is 2-aspect (GREEN-RED). Currently the signals indicate the points/switches/turnout at the top of the photo are set for the mainline train as opposed to trains from the yards.
The model train projects on this site can be sub-divided into
1. The sensors
2. The train signals
3. Using multiple sensors to control the signals.
4. Transmitting information to the outside world.
The sensors pages LDR_Sensor_Class and IR_Sensor_Class generate a signal train_over_sensor( ) that will be used by the projects in this folder to control model train signals.
Using multiple sensors and transmitting information are in the folder Model Trains
With signals there are many possible combinations/alternatives:
Lines from Micro-controller Purpose
1 Drive a single signal. For example a RED signal.
If desired a NOT gate could be used to drive a GREEN signal.
2 Two aspect signal where one line drives RED the other GREEN
Three aspect signal where one line drives RED the other GREEN
- External logic drives AMBER when both RED AND GREEN inactive.
3 Three aspect signal where one line drives RED, a second AMBER and a third GREEN
As shown above there are 4 possible combinations.
In addition as illustrated in the "test" across the LEDs come in two forms:
(i) designs where the control line pulls the line low to activate the signal, and
(ii) designs where the control line pulls the line high to activate the signal.
There are now 8 possible variations/combinations for the signal.
My solution is to define two signal classes Signals2_Class and Signals3_Class. Signals2_Class will be for 2 aspect signals with either one or two arguments. Signals3_Class will be for 3 aspect signals with either one or two arguments.
The polarity will be defined in the begin( ) routine.
Signals2_Class: Develops a class that will handle RED-GREEN signals - both polarities
Signals3_Class: Develops a class that will handle RED-AMBER-GREEN signals - both polarities
Signals3_Serial_Class Duplicates Signals3_Class but with external serial to parallel converter.
LDR_Signals3_Class: Program demonstrates inheriting LDR_Sensor_Class and Signals3_Class to control signals
LDR_Signals3_Array: Program an array of instances of LDR_Signals3_Class to control signals
Single_Track_Class: Program controls trains trying to enter a single section of track.
1. Micro-controller input pins. Parallel or serial. LDR_Sensor_Class and IR_Sensor_Class assume one pin per sensor and generate signal train_over_sensor( ); LDR_Serial_Sensors_Class can be used for serial inputs - generates signal train_over_sensor( sensor ) where sensor is bit of sensor of interest.
2. Choice of Micro-controller: Availability, tools. Probably all micro-controllers have the performance. Arduino UNO and NANO and ESP8266 readily available. Arduino IDE can be used for program development. The ESP8266 requires an enhancement to IDE (readily available)
3. Type of signals - As discussed earlier 2 or 3 aspect signals and positive or negative signals. For most examples, eg Signals3_Class the default is positive 3 aspect signals.
4. Signal Control: Signals2_Class and Signals3_Class will go RED on an input - when the input is removed they will go AMBER then GREEN with a 5 second delay. Options are available to vary the delays. Programs with "RAG" Red-Amber-Green included in their name control signals individually.
5. Micro-controller output pins. Parallel or Serial. Most example programs assume parallel output. For serial output see Signal3_Serial_Class.
6. External Logic: Most examples are for signals with one pin for red, one for amber and one for green. Programs have options to allow for external logic to generate the amber signal from red and green.
The Model_Trains page contains projects where the signal is controlled by multiple inputs.