Interface Analysis
My solution to the problem has resulted in 2 processors to control/monitor the hardware directed by a laptop. This has resulted in 18 things to control and 60 sensors to monitor. Adding the "may have" signals there are an additional 60 56 semaphore signals and 4 tri-color signals to control
- Control
- 4 trains.
- 12 switches/turnouts.
- 2 relays to reverse polarity on two sections of track.
- Monitor
- 32 IR sensors imbedded into the track to detect the trains in the 16 blocks of track.
- 4 IR sensors imbedded in the staging yard to detect parked trains.
- 24 sensors, part of Wabbits, to reflect cleared/thrown/unknown state of the 12 switches.
- Control the aspect of signals
- 56 52 semaphores on 28 26 dual headed poles.
- 4 semaphores on 4 single headed poles.
- 12 LEDs in 4 tri-color LED signals in the staging yard.
Unrelated to solving the problem we have added 6 4 LEDs to monitor communications between the four three computers in the system. Added a controlled fan to the Raspberry Pi 4 (3) and two 16X16 LED displays.
- Traffic monitor
- 2 LEDs between the Arduino (2) and Raspberry Pi (3).
- 2 LEDs between the Raspberry Pi (3) and Laptop (4).
- Fan Control
- 1 push button to control fan mode Auto/Manual and On/Off in the manual mode.
- 1 PWM output to control the fan.
- Display
- On two 16X16 LED arrays:
- 64 Signal aspect. 60 semaphore signals (56 on layout + 4 there is not room for on the layout) plus 4 tri-color LEDs.
- Fan status and relative processor temperature. (5 step temperature ladder + 3 status lights.)
- On 3.5" DSI touch screen:
- Randomize path assignment/selection.
- Display path/train assignment during run.
The Arduino Mega (2) IO pins were quickly used up controlling the Arduino Motor Shield to develop the DCC signals, monitoring the 36 sensors embedded in the track and controlling 2 relays reversing the signal to two track blocks. The Arduino uses the DCC signal to control the 4 trains and the 12 switches/turnouts.
The first Raspberry Pi 4 (3) uses 24 25 of the 28 GPIO pins:
- 2 GPIO pins, I2C, (Inter-Integrated Circuit), interface, to control 4 PWM add-on boards providing:.
- 60 56 PWM outputs to control servos for the semaphores.
- 1 PWM output to control the fan.
- (3 7 PWM outputs not used.)
- Added IO Pi HAT which provides 32 IO pins and 4 interrupt pins. 24 of the IO pins are used to monitor the state of the 12 turnouts and 4 are used to control LEDs reflecting computer traffic. 3 of the interrupt pins are connected to RPi GPIO pins.
- 12 GPIO pins controlling the 12 LEDs in the 4 tri-color or dwarf signals
- 1 GPIO pin for the fan control push button.
- 5 GPIO pins, SPI0 interface, to control the two 16X16 Unicorn HAT HD displaying signal aspects.
- 3 GPIO pins, inputs to monitor 3 interrupts from the IO Pi board.
- 2 GPIO pins, one output - run LED, one input - shutdown button.
The second Raspberry Pi 3B+ (3A) uses 26 of the 28 GPIO pins:
- 24 pins to monitor the two states of the 12 switches
- 2 pins to control :LEDs reflecting computer traffic.
The Laptop provides the user interface to the system, controls the process by sending commands to the three two micro-processors and receiving status from the three two processors.