- Turnouts have three states: 1) Not in use/committed, 2) Clear, 3) Thrown. If a turnout is clear or thrown then it is in use by a train and a second train needing that turnout is blocked. When a loco is at the end of a block about to enter a turnout, if the turnout is not in use it is "set" to block other locos or it is blocked. The turnout is released in the next cycle.
- Signals Because turnouts not in use are in an unknown condition, both the mainline signal (top) and turnout signal (bottom) are Clear (Green). Of course, when the turnout is in use the signal for one of the two paths through the turn must be Stop (Red). This is why in the simulator idle or stopped state there are so many GREEN signals.
- Turnouts have six states: 1) In transit to Clear, 2) In transit to Thrown, 3) Clear, 4) Thrown, 5) Clear & in use, 6) Thrown & in use. Having chosen to use slow motion motors to move turnouts, there is a ~2 second time delay from one state (clear or thrown) to the other. Otherwise, the hardware is clear or thrown being in use or not. When a loco enters a block (is at the first sensor) headed towards a turnout, there are three possible conditions:
- The turnout(s) is in the state needed and not in use (state 3 or 4).
- The turnout state is changed to "in use" (state 5 or 6)
- The loco proceeds to the second sensor
- When the loco reaches the second sensor, the turnout state is checked and the loco proceeds through the turnout
- The turnout state is changed back to state 3 or 4.
- The turnout(s) is not in the state needed and not in use (state 3 or 4).
- Command is sent to change turnout(s), timer set, and state is set to in transit (state 1 or 2).
- The loco proceeds to the second sensor
- When the timer expires, the turnout state is set to 5 or 6
- When the loco reaches the second sensor, the turnout state is checked:
- If the turnout is still in transit (state 1 or 2) the loco stops and waits for the state to change
- When the state is in the needed position the loco proceeds
- The turnout state is changed to the new state, unused (state 3 or 4)
- The turnout(s) is in transit or in use (states 1 or 2 or state 5 or 6)
- The loco stops at the first sensor and waits for the turnout to become state 3 or 4
- See the two processes above.
- Signals I am implementing an Automatic Block Signal (ABS) setup, sort-of. There are 16 control blocks for the track with a signal mast at each end or 32 polls. In all cases the semaphore on the top of the mast/poll is for the mainline path/track and the bottom semaphore is for a divergent path. The aspect (position) of a semaphore (or color of the signal) reflects the status of the next two blocks of track and any switches before those two blocks. In four cases there is not a divergent path (within two blocks of track) so there is no lower semaphore on the mast. This sounds good but really only works for the mainline signals and 20 of the 28 divergent signals. In four cases the divergent path has two possible second blocks, and in four cases there are two possible first blocks and one or two second blocks depending on the path.
At the beginning and end of each run, one section of track is designated as the "parking lot" with four parking places, one for each train. The exit for each parking place is controlled by a dwarf signal lights when the parking lot is active. When the parking lot is not active the dwarf signal lights are turned off and the section of track is controlled by semaphores at each end.
- Mainline Signals The 32 mainline signals (colored) are set based on the state of next two control blocks and any switches/turnouts before those blocks of track. For example, the aspect of the single signal near the upper-right depends on the state of the switch to the right (red) and the next two blocks of track (red). The four red signals on the "X" in the middle treat the crossover (the box) as a switch. For example, the aspect of the signal on the lower-right of the crossover depends on 1) if the crossover is committed, 2) if either of the two blocks of track in green are occupied and 3) the state of the two switches shown in red. Similarly the four yellow signals on the "X" depend on the two switches and the next two blocks on the inter-loop.
- Divergent Signals The aspect of 20 divergent signals (colored) are also set based on the state of the next two blocks of track and any switches before those blocks. Note a switch before the first or second block must, by definition, divert the loco to an alternate path. For example, the aspect of the yellow signal (top-center) depends on the state of the three switches to the right (red) and the next two blocks of track (red). Notice that the second switch diverts the loco from the mainline (inter-loop). As above, the aspect of the four red signals on the "X" depend on the crossover.
- Other Divergent Signals There are two sets of four divergent signals that cannot be handled as cleanly as all the other semaphores signals above. Except for these eight signals, an engineer can look at the signal(s) on the mast he is approaching and know the status of the next two blocks of track he wants to travel. Look at the red signal on the left going clockwise as an example. Going through the first block (green) into the two thrown switches all is well until reaching the third switch by the "Red X". Which of the two red blocks is the second block of track depends on the state of the "Red X switch." The four green signals present more uncertainty. Using the "green" signal at the lower-left as an example. Taking the divergent path through the first and second switch we reach the third switch by the question mark. If this switch is thrown the two green blocks are reach. However, if the question mark switch is clear, the blue block is reach and the switch by the stop sign determines which of the two green block is second block. The two semaphores on the mast cannot describe the state of all these paths.
- Dwarf Parking Lot Signal Lights The four dwarf signal lights (green) "control" movement at the beginning and end of a run, when this section of track is the Parking Lot. Each signal controls the exit of a short block of track, a parking place for one of the locos. In the beginning the three aspects of each signal reflects the status of the two blocks to the left of the signal. At the end, when the locos are being parked, the signals control movement within the parking lot and in this case the signal on the left is of course red. When this area is not being used as a parking lot, these four signals are turned off and this section of track is treated as a single block.
With the exception of the eight divergent signals identified above, the following algorithm is use for other 56 signals. There are one to four steps to determine the aspect of a signal.
- First set of switches. The state of the switch(s) between the current block and the next block of track is checked or the availability of the crossover. The required state of the switches depends on whether evaluating a mainline (top) or divergent (bottom) signal. IF there are no switches or the switch(s) are set as required, THEN go to step 2 ELSE Aspect is RED.
- First block. Only one loco can occupy a block at a time. IF block is not occupied THEN go to step 3 ELSE Aspect is RED.
- Second set of switches. The state of the switches between the first block and the second block is checked (including the crossover). IF there are no switches or the switches are set as required THEN go to step 4 ELSE Aspect is YELLOW.
- Second block. Again only one loco can occupy a block. IF block is not occupied THEN Aspect is GREEN ELSE Aspect is YELLOW
The aspect of the eight divergent signals identified above must be determined based on the intended path of the approaching loco. If there is no loco in the block approaching the signal than the aspect should be RED.
There is a refinement required for the four pair of adjacent blocks at the ends of the layout to avoid a lockup.
- For now, the lower signal will reflect the "main" divergent rout. Even on the top/mainline signal there is a choice of second blocks. Maybe I can figure out how to make the signals reflect the path of the approaching loco.
- Raspberry Pi 4 & Heat If pushed the Pi 4 can heat up enough to require throttling its clock and voltage to cool down and avoid damage. There is a hard limit of 85°C and a soft limit of 60°C. The normal clock frequency is 1.5GHz and a documented minimum of 600MHz. Is the Pi part of the Train Thing application going to push the Pi 4 that hard? Don't know. A fan just in case.
After running a test program loop for 20-minutes (1200 seconds) to get a stable starting point, the following 10-minute run was recorded without a fan.
The CPU frequency was also monitored, but not shown. I think around 91 seconds into the test, where the temperature is around 65°C, the voltage is throttled to drop the temperature a couple of degrees. The recorded frequency did not change, and the test program is similar for the whole run.
Running the same exercise, 20-minute run followed by a 10-minute run, this time with a fan installed, shows a 17°C temperature drop for the run.
It looks like the temperature reaches equilibrium around 45°C with the fan running vs 63-64°C without the fan (and voltage throttling?).
An example of when the frequency dropped for a second is interesting. The yellow line in the graph below is the frequency, 1,500MHz and 600MHz, scaled to display with the temperature. During the frequency drop, the sample rate is an artifact of the loop time to generate heat. As revealed by the X-axis, this detailed graph was extracted from a 20-minute run.
For completeness, two 20-minute graphs are included.
- Each point on the graph represents a ±1°C or more change in the reported temperature, except during frequency throttling.
- The graph represents 4-5 1°C changes in the reported temperature every second.
- The 20-minute runs sometimes would have a single drop in clock Freq from 1,500MHz to 600MHz.
- I think unmeasured the system throttles the voltage.
Semaphore, controlling servo mechanical mounting & connection
Wanting to tap into a fount of related knowledge, I remembered a classroom reality: 'If you need to explain a topic to someone else, you need to understand it yourself.' So, a list of design objectives, constraints, considerations.
- The servos have a gnarled shaft with 16 steps. With the body and shaft in a given position, an arm can be position in 22.5-degree steps
- The closes to the servo shaft I can connect is ~5mm
- A servo has a range of rotation of just under 180 degrees, which varies servo to servo.
- Although the movement of the control wire will be sinusoidal, I would like to use as much of the rotation of the servo as practical for granularity.
- The movement of the semaphore control wire is about 3-5mm from RED to GREEN aspect. With YELLOW in between. This is horizontal/RED, 45°/YELLOW and vertical/GREEN. "Upper quadrant" signals.
- The controls from the servos attached to one of the two wires coming down the mast of a double signal should be close to the mast center line to reduce ware.
- Need to have a small circuit board on the servo mounting bracket for a power plug for the semaphore lights.
- Because locomotives were invented in England, the engineer/driver is on the right side and so are signals with the semaphore arms pointing away from the track.
- The semaphore masts will need to be installed on top of a short ~1/2" column. In some cases, the semaphore arms for one track extend over the adjacent track and need to be elevated to clear passing locos.