Craig Thomasson BNML2

This blog will document my ongoing efforts to update the electronics in my 2.5" scale locomotive.

For some time now, I have wanted to add a wireless throttle to my 2.5" scale loco.  Last fall, a group of local Live Steamers decided to make the trek to the Train Mountain Triennial this June.  That seemed like the perfect motivation to make some enhancements.  My initial plans were to come up with a custom protocol for my wireless throttle, but after some technical details on the upcoming ProtoThrottle were discussed, I realized I was using essentially the same hardware.  My making some changes to the software, I could easily adapt the controller to work with the ProtoThrottle when it comes out.

A quick post on another thread got the attention of a few folks interested in adapting the ProtoThrottle for their use, so I thought I could share my journey in hopes that it can help and encourage others.  Since the ProtoThrottle isn't actually available yet, I'll need to build my own throttle initially.  However, we will eventually get there!

Craig 

See what's happening on the Office Park Zone at my blog: http://model-railroad-hobbyist.com/blog/49643

Reply 0
Craig Thomasson BNML2

Let's have a look at our patient

Several years ago, a fellow On30 modeler who is also in Live Steam set out to demonstrate that it was possible to build a small Live Steam locmotive using commonly available shop tools for under $1000.  That resulted in myself and another On30 group member joining him in his shop to construct our own critters.

9_121710.jpg 

My critter is loosely based on a Davenport 35 ton industrial loco.  The main frame pieces were designed in CAD and then plasma cut.  The rest of the parts are basic structural steel (angle, bar, channel).  Everything is bolted together.  The only shop tools really needed are a drill press, small horizontal band saw to cut the parts from steel stock, and a sander or angle grinder for sharp edges.  A couple of items on this loco were welded, but those were mostly cosmetic.  The body is made from a sign material.

9_122111.jpg 

Here is the business end of things.  I like to tinker with electronics, so I went overboard designing accessory electronics for it.  The top project box houses a bell ringer project circuit board.  The middle box with all the switches contains several custom PC boards to control the headlight operation, and configure lights and sound when MUed.  The bottom box contains a Phoenix sound card and a custom PC board for controlling the horn and bell operation.  Warning sounds are important in this scale.  The custom board allows the option to use either the external bell and/or horn when sound is on or to use the sound card bell and horn.  When sound is off, the external bell and horn are always used.  When in a consist, only the lead unit bell and horn are active.

9_122445.jpg 

Still more boxes...  The box on the front (left here) is the wiring distribution box. The front and rear throttle/MU cables are plugged in at the bottom, and the top has cables running to other boxes.  The box on the right is the PRO-150 motor controller from 4QD.  It is a 24v motor controller rated for 150 amps peak and about 60 amps continuous.  It is a popular choice for electrically powered locomotives.

9_122626.jpg 

Here's the user interface. During the initial construction, we had grand plans of fleets of critters all MUed together.  That resulted in a 24-pin MU cable design and the associated bulky wiring.  The throttle cable screws onto the socket on the loco. 

This is great in that it ensures a secure connection and there's no worry about the throttle cable popping off while running.

This is awful in that if the throttle ever falls from your hand, it will happily bounce on the ground thumping the speed knob as the loco takes off away from you.  Ask me how I know...  Did I mention these things can get up to 12 mph?  Have you ever seen someone chasing after a runaway locomotive?  I know folks who have seen me someone do that...

The end goal for this project is to replace all of the project boxes, except the motor controller, with a single box, and to remove all of the throttle/MU wiring.  That will greatly simplify the electronics and wiring and make maintenance easier.

Craig

See what's happening on the Office Park Zone at my blog: http://model-railroad-hobbyist.com/blog/49643

Reply 0
Scott SRLinesrr

What is the interface

How are you interface into the locomotives. I have a 1.5" scale engine so the a pro-120 broad and setup for pheniox sound. I have looked into the protothrottle but lack knowledge to update. 

 

 Scott

Reply 0
Craig Thomasson BNML2

@Scott, I'll be discussing

@Scott, I'll be discussing the interface in an upcoming post. I actually haven't got to that point just yet. The controller is in its box for testing but I haven't added the external connectors yet. Craig

See what's happening on the Office Park Zone at my blog: http://model-railroad-hobbyist.com/blog/49643

Reply 0
Neil Erickson NeilEr

RPi or Arduino?

Craig: I’m following along with interest. My understanding is that the ProtoThrottle is based on the RaspberryPi and not the Arduino. There are good libraries out there for the Arduino as far as sending dcc commands but I don’t know much about the RPi. You certainly can make a wireless controller for job specific applications such as the large scale loco but the PT is to be adaptable to other systems. Do you have something similar in mind?

Neil Erickson, Hawai’i 

My Blogs

Reply 0
Michael Petersen petersenm

RPi or Arduino

Quote:

My understanding is that the ProtoThrottle is based on the RaspberryPi and not the Arduino.

The ProtoThrottle itself is actually not based on either.  Internal to the throttle it is a bare bones ATmega1284P AVR (e.g. no Arduino bootloader).  The receivers for the ProtoThrottle are a mix.  For the direct connect systems (NCE, Lenz, Digikeijs) it's another custom AVR-based board.  For ESU and the WiThrottle based systems (Digitrax, MRC, CVP, generic JMRI, etc) it is a RasPi Zero W running some python code that bridges between the ProtoThrottle commands from the XBee and the command station via WiFi.

https://www.iascaled.com/store/ModelRailroad/ProtoThrottle/Receivers

Building an Arduino that receives the ProtoThrottle commands from an XBee and generates DCC signals through something like a motor shield should be no problem.  In fact, we've thought about building something ourselves for simple demo purposes.

Michael

Reply 0
Craig Thomasson BNML2

Determining Controller Requirements

Before we can go much further, we must first determine what we need to control.  Then we can work on how to control it.  For my loco, I have the following outputs to control and type of control needed:

  • Horn - digital (on/off), controls a pneumatic solenoid
  • Bell - digital, controls a 12v alarm bell
  • Front light - PWM for dimming, 20w halogen bulb so need to handle at least 2A.
  • Rear light - same as front light
  • Brake - motor controller, controls a linear actuator, needs to handle up to 1A
  • 4QD motor controller has a specific set of required controls
    • Ignition - digital, must be on for controller to work
    • Direction - digital
    • Speed - analog, QD supports Voltage Follower (a type of Op-Amp circuit)
  • Sound card
    • Horn trigger - digital
    • Bell trigger - digital
    • Shitdown sound trigger - digital
    • Sound card power - digital

I also want to replace all of the configuration switches with an LCD display and simple menu system.  For that, we'll need 4 buttons along with whatever control lines are needed to drive the LCD display. 

For rapid development, I want to use as many off-the-shelf products as possible. There are lots of sources for Arduino boards, accessory "shield" boards, and other little relay/switch/communications boards. My main sources are Amazon and SparkFun.

With the list of control requirements, we can now figure out what hardware we need.

  • Arduino Mega board - lots of pins, multiple built-in hardware serial ports, and lots more program and memory space compared to regular Arduino boards.  The multiple serial ports will come in handy later.'
  • 5 volt dual-relay boards.  For the 4QD and sound card outputs, I'm going to use relays instead of having to deal with complexities of some of the more unique signals.
  • 4-channel MOSFET switches for the digital and PWM outputs
  • Digital-to-Analog converter (DAC) board for driving the 4QD speed line
  • Motor controller shield
  • Nice big 4 line by 2 character LCD display

A picture of almost everything connected using jumper wires for testing.

1_190129.jpg 

The next task is to figure out if we can stuff all of these items into a box!

Craig

See what's happening on the Office Park Zone at my blog: http://model-railroad-hobbyist.com/blog/49643

Reply 0
Craig Thomasson BNML2

Packaging up the Controller

When working with off-the-shelf boards, they will ultimately determine the size of the enclosure since they come in fixed sizes.  The enclosure I ultimately selected was larger than I wanted, but will still reduce the amount of clutter inside the loco.

1_111728.jpg 

Here we see the first group of boards used.  Clockwise from upper left:

  • Arduno Mega
  • LM298-based motor controller shield (brake output)
  • XBee shield with XBee module, also has wiring for connectors to other boards
  • Small Digital-to-Analog board based on the Microchip MCP4725 DAC IC (speed output)
  • 4-channel opto-isolated N-channel MOSFET driver board (digital and PWM outputs)
  • 3 x 5-volt 2-channel relay boards (horn, bell, soundcard controls)

The XBee shield and module came from Sparkfun.  Everything else is from Amazon.

1_112020.jpg 

Here we see the enclosure and the user-interface boards.  I selected the Hammond 1591U enclosure with bottom mounting flange.  The lid has openings for the LCD display and menu buttons.  The enclosure has the standoffs mounted for the arduino.  Not seen is a hole in the side for the Arduino USB connector.

The menu button board is one of the few custom boards. I like to use ribbon cable whenever possible for multi-wire cables.  You can peel off the number of wires needed and solder header strips and sockets to each end.  The wiring is much neater than having a big jumble of individual wires.  In the previous photo you can see that I did use individual wires for many of the connectors.  That's because the ribbon wire was too small for the insulation-displacement connectors I had on hand.

1_110446.jpg 

Putting everything together.  You may have to get creative when fitting boards.  Here, the relay boards are stacked together with an assortment of standoffs on one end.  The edges on the other end align with slots molded into the enclosure. They are wedged between the enclosure and Arduino boards to keep them from rattling around.  I have not added the external wiring and connectors yet.  That is the next task.

If you are considering a custom controller to adapt the ProtoThrottle to your needs, note that your requirements will probably be much different from mine.  For G-Scale if you're putting the controller on-board, you may only need the motor and XBee shields, and you can use one of the smaller Arduino boards (Uno R3).  As an example, Here's my current stand-in throttle (work in progress):

1_114113.jpg 

It uses an Arduino Nano and a Nano IO Shield, both from Amazon.  You can find the Nanos in 5-packs for $10-$15 (cheap!).  The shield also has a built-in slot for the XBee module, but you'd need to do something different for the motor controller.  Arduinos are a popular choice in robotics so there are lots of options available for separate motor controller boards.  If you look closely, you'll notice that I actually use 2 Nanos in the throttle.  The one tucked into the upper left corner handles all the processing for a small graphics display, while the main one handles the buttons and wireless tasks.  All of this fits into a plastic electrical box enclosure with room to spare.

Speaking of XBees, if you're interested in playing around with them, I highly recommend getting a starter kit from Sparkfun here (or somewhere else similar). It includes several parts that you would need, and they also have a tutorial on getting started with XBees.

Now that we have our hardware put together, we can start looking at the code that makes it work.

Craig

 

See what's happening on the Office Park Zone at my blog: http://model-railroad-hobbyist.com/blog/49643

Reply 0
DAR1976

if the throttle ever falls

Quote:

if the throttle ever falls from your hand

With a micro lever switch and some programming that run away locomotive can coast to a stop.

Interesting project. 

 

Reply 0
Craig Thomasson BNML2

Project Updates

It's been a busy few months with work-related projects.  Additionally, I was pushing to get the controller and throttle working for a local meet a few weeks ago.  Since I'm heading to the big Train Mountain Triennial meet at the end of June, that only leaves me with a couple of local area meets to work out any issues before the big trip.

The good news is that the throttle performed reasonably well during the last meet.  Here's a sneak peek of the current system.

8_215746.jpg 

8_215834.jpg 

Compared to previous pictures, the new controller has achieved one goal of eliminating a lot of the "stuff" that was crammed into the loco.

Even though the XBee modules are fairly easy to use right out of the box, I quickly re-discovered that any wireless development work is hard.  It took several days and a lot of online research to just get the XBees communicating reliably with each other.  Add in the fact that the XBee in the controller is sandwiched between two other PC boards, and the whole thing is then enclosed in a metal loco body, signal range isn't very far.  I had a reliable connection when sitting right behind the loco, but when I moved just two seats back (about 8 feet), I'd frequently lose the signal and control.

Then there's the matter of what to do when the connection is lost.  In smaller scales, you can simply reach over and pick up the loco off the track to stop it.  In these larger scales, loss of control can result in significant damage or injuries, so proper failsafe handling is important when control is lost. 

Since that last meet, I've been making some improvements to the communications messaging to make it more robust and failsafe.  I've also been restructuring the code so that it will be much easier to integrate in the ProtoThrottle when it's available.

Craig

See what's happening on the Office Park Zone at my blog: http://model-railroad-hobbyist.com/blog/49643

Reply 0
Michael Petersen petersenm

XBee Range

Quote:

Add in the fact that the XBee in the controller is sandwiched between two other PC boards, and the whole thing is then enclosed in a metal loco body, signal range isn't very far.

Are you using the standard XBee or the XBeePRO?  Although it's rather brute force, the extra output power of the XBeePRO can get through a lot of things.

Michael

Reply 0
Craig Thomasson BNML2

Standard XBees

I got the XBee explorer kit from Sparkfun to start on my XBee adventure, and it comes with the series 1 modules with the PCB trace antenna.  I have one of the U.FL connector modules ordered along with an external 6 dB gain antenna that I can stick up in the exhaust stack.

Another problem I encountered at the meet was one-way communications.  The controller was able to receive messages from the throttle, but the responses weren't getting back to the throttle.  So the controller would chug merrily along saying "I can still hear you, it's all good!", while the throttle would report a comm error.

I may look at the series 2 in the future, since more power also gives more reliable connection.  That way I can relax with the throttle in a lawn chair while the brakeman does all the work switching the yard. 

Craig

See what's happening on the Office Park Zone at my blog: http://model-railroad-hobbyist.com/blog/49643

Reply 0
Reply