SparkFun Forums 

Where electronics enthusiasts find answers.

Have questions about a SparkFun product or board? This is the place to be.
By jbialstock17
#195764
I have been given, by the president of a charity operating a railroad history museum, the task of creating an automated system to operate what is referred to as a "home signal" for a miniature train ride at the museum. The facing, or "head", of the signal has these lamps, all of which are the same color:
  • Extreme top, extreme-left side, dead-center, extreme-right side, and extreme bottom
  • 45-degree arc between the left-side and bottom lamps
  • 45-degree arc between the top and right-side lamps
This signal, its control equipment, an existing grade-crossing signal, and the control equipment for that signal, get power from a system that delivers power as long as a 12-hour timer has not cycled off.

The center lamp must illuminate as soon as power is delivered to the entire signal, and must also remain illuminated until power is disconnected. When illuminated with the center lamp, those on the extreme-left and extreme-right form the "stop" indication, lamps on the extreme-top and extreme-bottom indicate "clear", and lamps on the diagonal are for "slow".

The equal colors of a highway traffic signal are red ("stop"), green ("clear"), and yellow/amber ("slow"). All lamps on the railroad signal will be yellow/amber LED.

The control system needs these components:
  • a momentary push button to change the signal from "stop" to "clear"
  • SparkFun #SEN-13959 ultrasonic sensor to detect the moving train, which travels three times around its track loop per cycle of the signal (the signal must not change from "clear" to "slow" until the train has completed its first loop)
  • SparkFun Redboard with attached, assembled ProtoShield kit (this is where the ultrasonic sensor, cycle-start button, and other electronics will attach)
  • A machined sheet-metal plate, preferably in a dark-color paint, to reflect the signal bream from the ultrasonic sensor's transmitter back at its receiver (the metal plate will be constructed by one of the museum's volunteers and mounted to a fence that sits approximately eight feet from the signal pole)
The momentary push button will serve a dual purpose, as it must also change the signal indication from "stop" to "clear", then to "slow", and finally back to "stop" (in that exact order), should the ultrasonic sensor fail.

The code that will be uploaded to the RedBoard must maintain the "clear" signal indication until the moving train has twice broken the ultrasonic signal beam, then change the signal to "slow" after the train completes the first loop around the track, and finally change the signal to "stop" when the train completes the second loop of the track. The museum volunteer who serves as engineer on the train crew needs to rely on a combination of the electronic signal indication ahead of them and a whistle indication given by the volunteer conductor at the back of the train in order to determine when the train should proceed or stop.

My current parts list includes these SparkFun items:
  • #COM-11996 (panel-mount momentary push button) x1
  • #TOL-12889 (5VDC 2A wall-adapter power supply with barrel jack) x1
  • #SEN-13959 (ultrasonic sensor HC-SR04) x1
  • #DEV-13975 (SparkFun RedBoard) x1
  • #DEV-07914 (SparkFun ProtoShield kit) x1
Suggestions for additional parts (excluding wire, which is provided by the museum) and help with code will be greatly appreciated.
By jbialstock17
#195770
Update to my previous post in this topic -- the parts list from SparkFun is:
  • #DEV-13975 (RedBoard) x1
  • #DEV-11665 (bare Arduino ProtoShield PCB) x1
  • #COM-08860 (super bright 10mm blue LED) x1
  • #COM-11118 (super bright 10mm white LED) x1
  • #COM-11148 (10mm chrome finish LED holder) x5
  • #COM-08862 (super bright 10mm red LED) x1
  • #COM-08861 (super bright 10mm green LED) x1
  • #COM-11119 (super bright 10mm yellow LED) x1
  • #PRT-09279 (8 pin stackable Arduino header) x2
  • #PRT-11376 (10 pin stackable Arduino header) x1
  • #PRT-09280 (6 pin stackable Arduino header) x1
All other parts requiring a purchase will be acquired from AllElectronics.com:
  • #PIR-8 (IR photo detector) x1
  • #PS-1212 (12V DC 1A power supply) x3
  • #MPB-1B (normally open SPST momentary push button with black cap) x1
  • #STS-56 (heavy duty on off SPST toggle switch) x1
  • #SC-510 (black toggle switch safety cover) x1
The toggle switch will control power to the home signal equipment, as well as to the lights, bell, and controls of a nearby grade crossing signal, such that the existing 12 hour mechanical timer can be removed. Additionally, all of this power and control equipment will be located on a single control station near the dispatcher's location, as it takes three volunteers to form a complete crew:
  • Engineer -- controls speed and direction of train while moving, sounds horn when approaching grade crossings and station, applies/releases brakes at correct point in train movement
  • Conductor -- loads/unloads riders to/from train at station, signals engineer for correct train movement by whistle, provides safety information to riders
  • Dispatcher/station master -- loads/unloads riders to/from train at station (if no conductor available), indicates correct train operating speed to engineer and conductor by manually changing arrangement of signal lamps at start of run and when infrared equipment fails to properly detect moving train, provides safety information to riders (if no conductor available), manually starts/stops grade crossing lights and bell (when toggle switch sensors embedded in track fail to operate correctly)
As the ultrasonic sensor has been swapped out for paired infrared emitter and detector units, the sheet metal plate that was intended to reflect the transmitter beam to the receiver will no longer be needed. Again, suggestions of additional, non-wire, parts and assistance with writing code to operate the home signal are appreciated.
By jbialstock17
#195771
Oops, I forgot to attach an image of what the illuminated part of the home signal looks like. This is the signal, sorry for the black and white photo, that's how it was on the web site I got it from.
PRR Home Signal.jpg
You do not have the required permissions to view the files attached to this post.
By jbialstock17
#195774
I had to revise the parts list yet again, after hearing from the museum's president that an IR beam project across the track to its receiver would be broken by every car of the passing train. This is the latest version of my bill of materials --

As with the previous versions of this list, all item numbers given are catalog numbers for a specific web site/store.

Items from SparkFun:
  • #CAB-13685 (3-pin JST-to-breadboard jumper) x1
  • #COM-08860 (10mm super-bright blue LED) x1
  • #COM-11118 (10mm super-bright white LED) x1
  • #COM-11148 (10mm chrome-finish LED holder) x5
  • #COM-08862 (10mm super-bright red LED) x1
  • #COM-08861 (10mm super-bright green LED) x1
  • #COM-11119 (10mm super-bright yellow LED) x1
  • #SEN-08958 (long-range infrared proximity sensor) x1
The sensor detects the moving train passing by and changes the signal pattern, displayed to the engineer and conductor on the train, from "clear" (green LED) to "slow" (yellow LED after one complete loop around the track) and finally to "stop" (red LED after two complete loops around the track). In other words, the "clear" signal pattern lights the green LED for the station master until the sensor has twice detected the passing train, after which the signal changes to the "slow" pattern and the control box to the yellow LED, and finally, after the second of three loops around the track (the third time that the sensor has spotted the train), the signal changes to "stop" and the control box to the red LED. Additionally, the blue LED is the power lamp (on so long as the control box has a supply of electricity going to it), and the white LED only illuminates when a burglar-alarm type system trouble happens, such as the IR sensor failing to correctly identify the moving train, thereby requiring the station master to click the momentary push button on the control box in order to manually change the signal from "stop" --> "clear" --> "slow" --> "stop" (both sensor and control button must change the signal pattern and corresponding illuminated LED in this exact order).

Updating my SparkFun parts list also required changes to the bill of materials that are to be acquired from AllElectronics.com:
  • #ATM-2560 (Arduino Mega) x1
  • #PS-1228 (12V DC 1.5A power supply) x1
  • #MPB-1B (N.O. SPST momentary push button) x1
  • #STS-56 (heavy-duty on-off SPST toggle switch) x1
  • #SC-510 (toggle switch safety cover) x1
The toggle switch is intended to control power delivery to the electrical-outlet box that supplies the home-signal and Arduino equipment, as well as the equipment for the nearby grade crossing, and the safety cover should protect the switch from environmental hazards, in addition to protection from accidentally being flipped by the station master or another museum volunteer.

The above changes also bring the sheet-metal plate, intended to reflect the IR-sensor beam at the receiver, back into play, as this part would be mounted to the right-hand side of the train's locomotive (traditionally the engineer's side of a real locomotive whether steam or diesel powered). This plate, and any needed electrical wire, are being provided by the museum.

How would I write the required signal-pattern changes, as described above, into the code for the Arduino Mega board? Would I also need to wire the home-signal lamps into the Arduino Mega board so that the IR sensor (or the push button in case of sensor failure) triggers a signal-pattern change?
By jbialstock17
#195786
I have only recently starting teaching myself to code in C/C++, but I do know Java, JavaScript, CSS, and HTML. Also, the input pin for the push button has to change state when the button's circuit is closed in order to trigger any change in the signal pattern and in the illumination of the station master's control panel. The grade crossing signals that I referenced in one of the earlier posts are one on either end of the station, with toggle switches that operate like momentary push buttons controlling the lights and bell on both crossing signals. The switch that activates the crossing signal is tripped by a sheet-metal plate on the left-hand side of the locomotive's lead wheel set (traditional fireman's side of a real train), with the switch to turn the signal off is tripped by a similar sheet-metal plate on the right-hand side of the last car's second wheel set.
User avatar
By DanV
#195787
You are tossing out a lot of specification info.
Are you trying to get assistance or get someone to do the work for you?
If you want to pay, there's a forum just for that:
https://forum.arduino.cc/index.php?board=26.0
Actually, that's Gigs and Collaborations and the heading says:
Gigs and Collaborations - Are you making a project and need people to help out, calls for projects for exhibitions, fairies
so, you may not have to pay.
User avatar
By phalanx
#195788
jbialstock17 wrote:I had to revise the parts list yet again, after hearing from the museum's president that an IR beam project across the track to its receiver would be broken by every car of the passing train.
Multiple breaks of the beam isn't necessarily a problem. The beauty of having software control of your system is that you can intelligently tune it to detect specific cases and ignore others.

For instance, let's assume that your locomotive has a total of 4 axles so there could be 4 interruptions of the IR beam when it passes by and that in the location you put the sensor it will take no longer than 2 seconds for the locomotive to travel past it. In your software, you would continuously look for an event to occur (break in the IR beam). Once an event occurred, you start a timer. You then continue to look for events while the timer runs. If you get a total of 3 more events before the timer reaches 2 seconds, you know that the locomotive has been detected and you can then flag the display logic of your code to update. If the timer reaches 2 seconds and not enough events have occurred, the program turns off the timer and starts looking for the initial event again without updating the display. You would also have to include some logic to prevent the system from retriggering on the cars being pulled by the locomotive. It could be as simple as a long delay after the locomotive is detected or if you go a certain period of time without detecting any more events. This would eliminate false triggers from debris like leaves falling through the sensor beam. Obviously there are many ways to accomplish this and they need to be tuned to your specific application.

Overall, your software requirements are not complex and can easily be handled by an Arduino. Since you have programming experience, you shouldn't have any problem getting up to speed in the C/Arduino environment. The part that many people underestimate with embedded systems like this are the real world interfaces that have to deal will real world environmental issues like weather, temperature, electrical noise, vibration, etc. It can take some significant thought and planning to make your system completely robust from an operational standpoint. While your Arduino has no problem interfacing with any of the items in your BOM in a small project enclosure, what happens when you need to interface with a sensor that's 50ft away while controlling your lights that are 100ft away in the other direction? Ultimately you want a robust system that works anytime and every time you call upon it. Pay close attention to the environment you are installing in and make sure you protect and condition your interfaces for reliable operation.

-Bill