Skip to main content

Long time lurker here, hoping to make a contribution of interest to others.

Recently I've created a packet radio-based (great range!), battery-powered DIY engine control system that can be built for about $65 per engine (plus $25 battery).  It uses USA-made commodity parts and operates on software that I have written (and am quite willing to share).  With my system if you pull up a web browser on your handheld device you can control my trains, no apps required.  If I were to poke a hole in my home network firewall you could even run my trains from where you're sitting right now.  The engine control module's initial capability is similar to the commercial BlueRail system: motors and directional lights, and I've added flashing ditch lights.  But because it's using a microcontroller anyone can program, it can be easily expanded through software to do much more.  For example it would be easy to add audio using the onboard 10 bit D-A converter, or a simple add-on mp3 board.  An RFID reader could be connected and controlled for position sensing.  You could even program it to drive the DCS/DCC/TMCC/Legacy guts in your current engine I suppose.   Etc.  I'm not big on smoke and lots of extraneous chatter coming out of my engines, but to each his/her own.  I want my audio to have doppler based on where I'm standing.  That's coming.

My focus has been on the part of my collection that comprises mostly mid-90's conventional and PS/1 diesel electric engines.  I rip out the guts and replace them with my electronics that have a 5cm by 7cm by 1.9cm footprint.  There are ways to make that smaller.  Right now I've got three installations done and operating: an SD60, a Dash9 and a pair of F3's (one dummy).  My engines run about 2.5 hours on an 11.1 volt 2200mAh LIPO battery.  Here's the module as built:



and here's a wiring diagram:



Major components (with no endorsements intended) are:  
   Adafruit Feather M0 48 MHz micro-controller ($24.95) with on-board RFM69HCW (433/900 MHz) packet radio.
   Pololu step-up-step-down voltage regulator, Item # 2872 ($4.95 each for 5) (Under the microcontroller in the board image -- can't be seen)
   Pololu 18 volt, 17 amp motor driver, Item # 2991 ($26.96 each for 5).
   
At 17 amps the motor driver is more than what is needed, but for the incremental cost I like the safety margin.

Components for the ditch lights appear in the image of the module, but not in the wiring diagram.  Wiring for ditch lights is essentially the same as for the directional lights.  Flashing is under software control.

Separately, to avoid running miles of wire for my switches, I've designed and built packet radio controlled switch modules.  Place a switch module near a remote cluster of switches and control them by radio from your control center.  It saves a lot of wire.  I can post about this module as well if anyone is interested.

I've seen many discussions on this forum and elsewhere about the benefits and drawbacks of what some call BPRC.  Many argue against it because of cost.  I'm showing that cost is not really an issue now especially when you compare with replacing your broken PS/2, PS/3, TMCC, Legacy module.  And you get a lot of flexibility you can control!

Attachments

Images (2)
  • DIY Engine Control with Commodity Parts: Engine Control Module
  • Engine Control Module Wiring Diagram: Wiring Diagram
Original Post

Replies sorted oldest to newest

@Jeff: I've got an unpolished video of the maiden run of my first completed board installed in a pair of Chessie F3's.  Electronics are in the lead engine and battery is in trailing engine.  (Control module *and* two 2200 mAh batteries fit in my SF Dash9 easily).  Sorry about the CNW cars behind them  They were most convenient ones to grab as a test load.  As you can see in the video, my dream layout is very much under construction.  It's two levels with a hidden automated elevator between levels for transferring from mainline to yards below.  Varying scenery will be projected using $100 LED projectors, and audio will be multichannel with effects determined by observer position in room.  Tracking of trains will be done using cameras.  A past tracking project: https://github.com/pfr/VideoSpeedTracker .  This mix of trains and electronics is what I think has the best hope of keeping our hobby healthy.

I plan to post better videos discussing my approach and some overview of the hardware construction, as video of operations.  I also plan to post my software on Github so others can have access to it.

Here's a shot of the Web based interface I built.  It was quick and dirty but works fine for my testing:  What you see is the top level page on the left.  When you click on an engine it opens a new tab, which you can then drag out onto the desktop so that you have concurrent views of everything.  I've done that twice here.

TechnoRailGUI02

Attachments

Images (1)
  • TechnoRailGUI02: Three tabs inside a browser showing engine selection and control

@Paul Reynolds 121018

I really like what you have going on with this project.  I too believe one facet of the future of the hobby is the mix of custom electronics with the tactile nature of the trains and layout.  Something like this in kit form would be a fun project to involve older kids (teens) into the hobby while introducing them to electronic engineering and software coding. 

Great price point - in line and lower price than similar products.

I apologize for my ignorance, but does the radio signal emit from the phone/device? or does the website communicate with a separate device to provide the signal?

I would like to hear more about the radio controlled switch modules.

I also like your idea of varying scenery using LED projectors.  I've attempted something similar and really liked the effect in person:  https://ogrforum.com/...3#153322190445430903

Which brand / model of projector are you using?

I think it's efforts like yours that will push the hobby forward.   

@JD2035RR: "Something like this in kit form would be a fun project to involve older kids (teens) into the hobby while introducing them to electronic engineering and software coding."

I agree!  Just before I sat down here my wife was encouraging me to put together a course (I have a background in education).  I may do it.  There are online forums like Great Courses Plus where a short course with labs could work.  I'm also thinking about laying out some PCBs for manufacture for what I've worked up because a time consuming effort for me has been routing and soldering all the little wires on the solderable perf boards I use.  If you know someone who does small batch PCBs please let me know.  I've only begun to look.

>>> does the radio signal emit from the phone/device?

A more general answer before offering my specifics.  Your handheld device needs to be able to access my home network.  As I mentioned above if I poked a hole in my home network firewall you could get to my internal Web server by surfing to my IP address through your Web browser and you'd be off and running.  Right now you have to be in the house and access my Web server through my wireless network.  By accessing the proper name for the server (IP address) on my home network you gain access to the webpages I showed in my previous post.  The Web server connects through software to a packet radio.  Commands you issue through the Web interface are sent out through back end software for the Web server through an attached packet radio to my engines.  The Web server software I wrote can run on most any popular computing platform.  It's not as complex as it may initially sound and I'll be making my software available on Github in the near term.

My Web server and its backend software are all implemented on a $30 Raspberry Pi 3 with an attached packet radio.  The RPi is attached to my home network.  So it serves up control webpages to anyone accessing it through a browser (as depicted in my previous post), sends the commands to backend software I wrote in Python, which in turns sends the commands on to my engines.  So one platform, the RPi, sits between your handheld and my engines.  The webpages could be hosted on your home PC, as long as you had a way to connect your PC to a device with a packet radio.  That's easily done through USB to, say, one of the Adafruit Feathers with a packet radio on board. Here's the Raspberry Pi 3 with a packet radio daughter board ("HAT").  It's connected to my home network and power only.  It communicates (Webpages) with my handheld device and sends commands to all of my engines.



>>>   I would like to hear more about the radio controlled switch modules.

Sure.  As with the engine control, there's one device -- I'm calling it the switch master-- that has a packet radio that acts as the distributor of commands to a set of remote modules (in this case "switch nodes" rather than engine control modules).  The switch master receives commands from my desktop computer via USB right now, but that could be changed to most any other source.  It sends a command on to the correct switch module, and waits for an ACK back to ensure the command was received and acted upon.  The switch master could just be one of the Adafruit Feather M0's with a packet radio attached (See my original post for the one I used in engine control modules).  Because I had a handful of Adafruit "Itsy-Bitsys" around ($14 each) I bought separate packet radio boards ($10) and drive them from the Itsy Bitsys.  Total cost ($24) is essentially the same as for the Feather M0 with on board packet radio ($25).   Here's my first switch master ($24):

And here's a switch node that sits out by a cluster of switches:

Again, the switch node is using an Itsy Bitsy and separate packet radio board.  The Feather M0 with packet radio on board I used in my engines could be used instead.  To avoid using up all of the I/O pins on the Itsy Bitsy I bought a $5 mux/demux board from Sparkfun and can control 16 switch operations with five output lines from the Itsy Bitsy (4 channel select and 1 signal).  Right now I'm using DZ1000's on my switches.  They require about 14 VAC.  So I bought the board of relays you see in the image ($14).  If I decide to switch to DC controlled switch motors like the Tortoise I should be able to drive the switch operations through NPN FETs instead.  To be determined.

What you see above is all built out and tested.  The 16 gauge wire I'll be using to run 14VAC out to the switch nodes arrived on my doorstep about an hour ago.  I'll use a bridge rectifier with smoothing cap to produce DC, and step it down to 12VDC (for the relays switching) and 5VDC to Itsy-Bitsy, radio and mux power using a couple of LM2596 Buck converters for.  If I switch over to DC switch machines that setup would be simplified (12 VDC on the bus instead and one Buck converter for the 5VDC.)

>>> Which brand / model of projector are you using?

I've got a couple of DBPower projectors gotten off Amazon.  There are a bunch of brands out there starting at about $40.  Be sure to get one with vertical keystone correction since you'll want to mount them up high and aim down somewhat towards your projection surface.  If you watched my video in my preceding post you can see I've got a lot of projection surfaces.  And I have a lot of images I plan to project.   I'm not into building trackside models and scenes much, at least on my mainline.  My plan is to project scenes that can take you across the country, using careful fading and reuse of projection surfaces to create a convincing effect.

Ultimately my trains will be automatically dispatched.  I'm a computer scientist.  I read papers about how the big railroads avoid collisions and deadlock.   I've kept up with the development of Positive Train Control (PTC).  My plans for my auto dispatcher will take an arbitrary schedule and run the trains, deadlock and collision free, on schedule if it's feasible.

Again, I heartily agree with you @JD2035RR.  These kinds of electronics re very attractive to students and trains offer an excellent platform on which to experiment with control, audio, video...

I'm happy to address any further questions.

The problem with retirement is there's just not enough time.

Attachments

Images (4)
  • Switch master: Switch master - one for whole layout
  • Engine Packet Master: Engine Packet Master - one for whole layout
  • Switch master: Switch master - one for whole layout
  • Switch node: Switch node

I will comment more later, but I really enjoyed your responses.  My problem with my projector is it is only 200 lumens.  It is only a small portable projector designed for outdoor movies after dark.  Also, it was difficult finding video loops with the scenery at the correct perceived distance.  I would love to hear more about what you have in mind.  Also, you have a great space for your layout!

Last edited by JD2035RR

Paul, that looks great!  I've started playing with the RFM69 modules for remote control in operating cars. In my case, I have one node receiving TMCC commands from the Legacy base, and that master node transmits to local modules. So if you wanted you could make your installations controllable from the Lionel remotes pretty easily.

You're probably aware, but if you don't need the power of the M0 you can can get modules that integrate an Atmega 328 (standard Arduino setup) with the RFM69, like the Moteino or Anarduino.  I think those come in a little cheaper than the Feather.

Paul, that looks great!  I've started playing with the RFM69 modules for remote control in operating cars. In my case, I have one node receiving TMCC commands from the Legacy base, and that master node transmits to local modules. So if you wanted you could make your installations controllable from the Lionel remotes pretty easily.

You're probably aware, but if you don't need the power of the M0 you can can get modules that integrate an Atmega 328 (standard Arduino setup) with the RFM69, like the Moteino or Anarduino.  I think those come in a little cheaper than the Feather.

Interesting what you're doing with packet radios and the TMCC system!  Did you have to figure out the TMCC command structure and communications protocol?  I've worked with two friends, one in San Diego (Mark) and the other in Washington state (Mike) who invested a LOT of time figuring out the comms between an MTH remote and a TIU.  Mark's documented it all on his Web site (http://www.silogic.com/trains/layout.html).    They're using Panstamp radios to communicate with the TIU.  I wrote code for Mike that does the CRC and Morton encoding that MTH uses.  Mark's just started looking at the Feather Atmega 328 with packet radio as a possible replacement for the Panstamp (apparently his source has gone out of business).  That stuff's too messy for me, and too proprietary (I have paid a lot for Lionel/MTH equipment; I just want more flexible control).  I like the thought of rolling my own, and getting the benefits of being able to program in functionality that Lionel and MTH may not have thought to incorporate (e.g. an on-board radio, battery voltage monitoring, and  interfacing with an RFID reader).

Thanks for the excellent pointers to Moteino and Anarduino.  One of the reasons I went with the M0 based processor is a lot more memory.   My choice doesn't put any requirements on anyone who wants to try what I've done here but with less expensive components.  My M0 code is Arduino.  Adapting for an Atmel 328 would require using a different setup for 20KhZ PWM and timer interrupts.  There's plenty of support on the Web for doing that.

@Tom Tee posted:

Paul, real nice work there!!  If you are looking to expand your battery source you may want to consider MTO batteries from Red Lion PA.  Folks have been using them for quite a few years in 0 scale 2 rail.

Many different physical configurations, excellent chargers, neat widgets, nice people to work with.

www.mtobattery.com

I've seen your postings while browsing the forum Tom.  I'll take a look.

@Tom Tee posted:

Paul, real nice work there!!  If you are looking to expand your battery source you may want to consider MTO batteries from Red Lion PA.  Folks have been using them for quite a few years in 0 scale 2 rail.

Many different physical configurations, excellent chargers, neat widgets, nice people to work with.

www.mtobattery.com

Tom, when I go to your site looking for Lithium battery packs I find:  "Sorry, there are no products in this collection"  I've been using Tenergy 11.1V 2200 mAh packs with full protection.  When I receive a 10% coupon from them I get one of these packs for just under $25.

Phil, I think I'm already using your CRC/Morton code, since Mike passed it on to me!  I built a fully automated train control system based on Arduino Mega, that uses Mike & Mark's work to control DCS engines (as well as TMCC)

I wondered if it would be possible to coax the RFM69 to talk to the TIU - it would be sweet if Mark could get the RFM69 OOK working.

Unlike DCS, the Lionel protocols are fully documented, so reading Legacy commands from the Command base serial output is easy. Right now I'm working on some boards that would plug into the Lionel LCS system, and bridge between the LCS and RFM69 or CC1101 radios.  

Phil, I think I'm already using your CRC/Morton code, since Mike passed it on to me!  I built a fully automated train control system based on Arduino Mega, that uses Mike & Mark's work to control DCS engines (as well as TMCC)

I wondered if it would be possible to coax the RFM69 to talk to the TIU - it would be sweet if Mark could get the RFM69 OOK working.

Unlike DCS, the Lionel protocols are fully documented, so reading Legacy commands from the Command base serial output is easy. Right now I'm working on some boards that would plug into the Lionel LCS system, and bridge between the LCS and RFM69 or CC1101 radios.  

Mark wrote yesterday he's got the Adafruit Feather 32U4 with RFM69 working with OOK.  So it can talk to the TIU.  He mentioned something about the board needing a soldered jumper in order to work with Mike's TrainBrain, so for now he's pursuing a Seeduino solution.

What software are you using to drive your fully automated system?  Mark's RTC?  TrainBrain?  JMRI?  Home brew?  I'm still looking for how to automate my setup once I get the pieces I've described here pushed out to my engines and switches.  Sorry if you've posted elsewhere here about your automation.   I've followed your posts in the past but don't recall.

Paul

Mark wrote yesterday he's got the Adafruit Feather 32U4 with RFM69 working with OOK.  So it can talk to the TIU.  He mentioned something about the board needing a soldered jumper in order to work with Mike's TrainBrain, so for now he's pursuing a Seeduino solution.

What software are you using to drive your fully automated system?  Mark's RTC?  TrainBrain?  JMRI?  Home brew?  I'm still looking for how to automate my setup once I get the pieces I've described here pushed out to my engines and switches.  Sorry if you've posted elsewhere here about your automation.   I've followed your posts in the past but don't recall.

Paul

I'll reach out to Mark and see - I've used the Elechouse CC1101 modules with 3v Arduinos, but the RFM69 would be more compact.

My system is entirely home-brew - I've been evolving it from one based on the Basic Stamp years ago!  It relies on identifying engines with RFID readers at designated entry points, and then subsequently tracking the trains with third-rail block occupancy.

If you're interested you can see the code here.  But at this point it's probably very hard for anyone else to unravel - the system includes custom SPI and I2C boards for occupancy sensing and controlling hacked MTH signal heads, remote controls for a TMCC crane and sawmill, and a spoofed C/MRI interface with JMRI for a graphic control panel.  And I don't think I even understand the block control logic any more...

Hi Paul,  So sorry there are Gremlins visiting you.  Maybe try again, being on the computer for many hours with reports I see all kinds of strange action.

I entered:

MTO Battery,

mtobattery,

mtobattery.com,

www.mtobattery.com and each time it took me to their website. ???

Well worth connecting with them, very friendly, very accommodating.

They offer a variety of assembled configurations which allow for tight otherwise impossible installs.  My tightest so far has been a twin tower drive GP-7.  The board and battery are both inside the body and I control it at a 75' indoor distance with the Piko $90 system..

MTO Battery

battery store in Red Lion, Pennsylvania
Address: 237 N Church Ln, Red Lion, PA 17356
Hours:
Closed ⋅ Opens 8AM
Last edited by Tom Tee

Tracking of trains will be done using cameras.  A past tracking project: https://github.com/pfr/VideoSpeedTracker .  This mix of trains and electronics is what I think has the best hope of keeping our hobby healthy.  And some overview of the hardware construction, as video of operations.  I also plan to post my software on Github so others can have access to it.

Well... this got my attention!  I'm about to wire my new layout for detection... I was going to order the parts this week ...but, I think I'll put a WHOA on that pony for minute and check out the future.

Thanks Paul!

Last edited by Dennis-LaRock

My system is entirely home-brew - I've been evolving it from one based on the Basic Stamp years ago!  It relies on identifying engines with RFID readers at designated entry points, and then subsequently tracking the trains with third-rail block occupancy.

If you're interested you can see the code here.  But at this point it's probably very hard for anyone else to unravel - the system includes custom SPI and I2C boards for occupancy sensing and controlling hacked MTH signal heads, remote controls for a TMCC crane and sawmill, and a spoofed C/MRI interface with JMRI for a graphic control panel.  And I don't think I even understand the block control logic any more...

I just spent a chunk of time looking through your code (You put executables in header files!).  Initially I'm most interested in how you interfaced to the JMRI graphic control panel.  Do you have images of your control panel that you would/have shared?  Do you use any other parts of JMRI?   I do think having a package available that easily connects the lower level electronics like we're doing to the visual control interface is important for attracting folks starting out on electronics projects with model trains as an implementation platform (a path I think is critical to keeping our hobby healthy).  And into your code I will slowly descend, with this as a warning sign:

debug << F("Block 3 hack in effect") << endl;

But first I'm going to go run the 16 ga 14 VAC bus for my switch modules and think about laying out a design for a PCB for the engine control modules I posted here initially.

Paul

Well... this got my attention!  I'm about to wire my new layout for detection... I was going to order the parts this week ...but, I think I'll put a WHOA on that pony for minute and check out the future.

Thanks Paul!

It may be a while before I get camera-based tracking working to my satisfaction on my railroad.  I'm confident I can do it but it will take time and is currently prioritized below other facets of getting my trains running.  Mark ((http://www.silogic.com/trains/layout.html))  has RFID readers under the track working quite well and he's documented it at his Website.  Friend Mike in Wa state has RFID readers mounted in engines and cars working very well.  Each approach has its advantages and  disadvantages.  I have a slight preference for placing the readers in the rolling stock. (Tags are 5 cents each and can be placed with abandon around your layout.)  So if you can't wait for my camera-based tracking these two guys and @Prof_Chaos and others have RFID working at a very reasonable price.

I just spent a chunk of time looking through your code (You put executables in header files!).  Initially I'm most interested in how you interfaced to the JMRI graphic control panel.  Do you have images of your control panel that you would/have shared?  Do you use any other parts of JMRI?  

Yeah, I'm self-taught and the code isn't pretty!

My JMRI implementation is very idiosyncratic. I use the C/MRI protocol to pass data between the Arduino and JMRI scripts, so that I can use JMRI to do things like represent the internal logic of the control system, and use JMRI to control operating cars and accessories on the layout via TMCC.

I haven't maintained it recently, because it's a pain to modify for new engines/cars/accessories, and I've installed tactile switches on the layout that I enjoy more than poking a touchscreen.  But here's what it looks like when running:

Add Reply

Post
×
×
×
×
Link copied to your clipboard.
×
×