Jump to content
 

Wireless DCC System for ?90 (using SPROG, Raspberry Pi and JMRI)


Recommended Posts

This weekend, I finally got the following cheap wireless DCC set-up working nicely:

post-7525-0-49005200-1361131058_thumb.jpg

Although I'm using a Sprog Nano and an SBoost, you could easily use a Sprog II which would bring the costs in at around £90. If you already have a DCC booster then you can simply buy a Sprog Nano to use as the command station which brings the costs down even further (£20 less). An example set-up for £90:

  • Sprog II:  £45
  • Raspberry Pi:  £25
  • 32GB SD Card:  £10
  • Edimax WiFi Card:  £10

For a small layout this is a really nice compact solution - most of the components are so small they can be mounted underneath the baseboard to keep the wiring simple. The Raspberry Pi runs JMRI in headless mode. With the configuration correct you can simply switch on the Pi, wait for it to boot and you are ready to run trains from your favourite Apple or Android smartphone or tablet after a minute or so.

 

My test set-up is shown below (apologies for the picture quality - taken on the same smart phone that I was using to control the trains!). The only piece that isn't really visible is the tiny(!) Edimax Wifi dongle plugged into the second USB port of the Pi. I have the Pi in a case but there is a lot of dead space taken up by this bulky case so its feasible to mount it without a case.

 

post-7525-0-34988300-1361131507_thumb.jpg
 

The basic steps for setting up the Pi (requires some basic linux knowledge):

  • Install Raspbian (as per the Raspbian wiki)
  • Update the Pi using apt-get
  • Install Java using apt-get (openjdk-6-jre)
  • Get the Edimax wifi working by booting the Pi into X - there is an icon on the desktop to configure it!
  • Download the latest version of JMRI onto the Pi
  • Launch JMRI (very slow with the GUI).
  • Set up the SPROG in JMRI preferences
  • Set up the in-built WiThrottle Server to run as an action on startup via JMRI preferences
  • The above two steps above will generate a file (DecoderProConfig2.xml). Copy this and rename it to JmriFacelessConfig3.xml
  • Run JmriFaceless and test the set-up!
  • Configure JmriFaceless to run as a daemon at boot time.
  • If you do choose to use a Sprog Nano then you will also need to write a small Jython script to be loaded at JMRI start-up time that switches on the layout power via a DCC command (PM me if you need a copy of this).

A few enhancements I'd like to make:

  • Power the Pi from the 12V DC power supply that is powering the SBoost (need to step down to 5V for this).
  • Configure the Edimax to work as a wireless access point rather than a wifi peer (thus removing the reliance on my home wifi network)
  • Work out how to get all of the roster information that I spent hours configuring using JMRI on my laptop to work with WiThrottle so the buttons are nicely custom labelled for each sound loco. Not sure how easy/hard this is as I haven't even tried copying the roster data to the Pi yet.

It's worth noting that although I started this project back in the summer, I ran into major problems using either the Lenz LI-USB or early versions of the Sprog 2 (later versions are fine). This is down to the FT232B chipset in both devices that doesn't play nicely with the Pi (due to driver issues).

 

Big thanks go to Kevin at Coastal DCC and Andrew from Sprog-DCC for providing me the opportunity to test out a prototype of the Sprog Nano. I should have the set-up with me on the DEMU stand at Alexandra Palace later in the spring so please drop by if you are interested and would like to have a natter.

 

Guy

Link to post
Share on other sites

Guy, just copy the roster files from laptop to Raspberry, rebuild Roster on Raspberry and you're done. The function labels will appear in Paid-For WiThrottle (Apple) or EmgineDriver (android).

Also, if you have a layout described in a Panel then that will also display.

I doubt the Programmers are usable on a phone, but should be OK on a tablet.

 

 

Alternative to the Edimax dongle may be the Edimax Nano router. Those can be an access point and have an Ethernet socket.

 

 

What's the boot time now you're finished?

 

Nigel

Link to post
Share on other sites

What's the boot time now you're finished?

 

Nigel, I just went and timed it! 1min 25 seconds until the power light shows on the SBoost.

 

It's good to know that it works with WiThrottle - a pity it is only the paid-for version! The nice thing with this set up is that there is nothing stopping developers (e.g. me) writing improved user interfaces to run on smart phones and/or tablets. Although WiThrottle is fairly feature rich (the free version at least) is pretty ugly and could be improved massively. The WiThrottle protocol looks fairly easy to extend if required.

Link to post
Share on other sites

Guy, 

have you tried a comparison with RocRail, particularly speed to launch ?   

 

The thing which goes through my head is how much "not needed" stuff gets loaded with JMRI.  This doesn't matter with fast computers (my desktop launches JMRI in about 5 seconds), but it can be annoying with slow ones.  I appreciate that "headless" has removed the GUI code from launching.

An alternative would be to write new code which talks "sprog" on the USB-serial output, and presents a TCP/IP socket for WiThrottle.   In the middle might sit the XML from your JMRI Roster (copied from another machine).   This new code would look like WiThrottle, but wouldn't take over a minute to launch.

 

Of course, all this timing might be irrelevant if the Linux is taking most of the boot time; can't easily speed that up. 

 

 

 

WiThrottle paid-for is somewhat better in its UI than the free version; various things become more apparent once the extra capabilities are added.   I think the appearance is quite good (on phones and iPod Touch), and its use is excellent (the slider is superb, both in the way it works and positioning).    But, its been a while since Brett did any updates to the application and there are probably other things which could be done.   

The Android "EngineDriver" gets more regular updates and is free, but it's throttle slider is less good.  On some devices the volume buttons can double as speed control for EngineDriver (such use is against Apple's programming guides, so not done on the iPhone).

 

 

- Nigel

Link to post
Share on other sites

This is very interesting, but I have a few questions.

 

I presume the Raspberry PI is being used instead of a PC and I could use my Netbook in its place? (I don't have a TV so I don't think I can use a Raspberry PI).

 

I also presume that you are using the Sprog to drive your trains and not just to program the chips on your locos. The Sprog website seems to focus on using the Sprog as a programmer.

 

What instructions (from the PC) does the Sprog work with when it is used as a controller? For example, does it work with Xpressnet commands like a Hornby Elite?

 

(I have the impression (can't remember from where) that it uses a much more basic set of commands which requires more intensive work by the PC.)

 

Thanks

 

...R

Link to post
Share on other sites

This is very interesting, but I have a few questions.

 

I presume the Raspberry PI is being used instead of a PC and I could use my Netbook in its place? (I don't have a TV so I don't think I can use a Raspberry PI).

 

Yes, the PI is a Linux computer.  It has monitor output to either HDMI (modern digital monitor connection) or television.

 

You could use a Netbook.   JMRI is written in Java and runs on Windows, Linux and MacOS.  

 

I also presume that you are using the Sprog to drive your trains and not just to program the chips on your locos. The Sprog website seems to focus on using the Sprog as a programmer.

 

It can do both.  The Sprog is a small DCC command station, though its origins are as a programming device.   

 

What instructions (from the PC) does the Sprog work with when it is used as a controller? For example, does it work with Xpressnet commands like a Hornby Elite?

 

The Sprog has its own instruction set.  They are available from the designer of the Sprog - I think there is a download.    But, if you use software like JMRI, the instructions are taken care of by the writers of JMRI.   JMRI will also work with an Elite and most DCC system with a method of connecting to a computer.

 

 

- Nigel

Link to post
Share on other sites

  • 2 weeks later...

Interesting concept Lyneux, so thanks for sharing this.

I already have a Pi and have been looking for an iPad / Android wireless solution so this may be an option. I see there is now a Sprog3 with a 2.5A booster. I assume this should work the same?

Really can't make my mind up between trying something like this or waiting for the Hornby elink to come out.

 

Thanks

Dave

Link to post
Share on other sites

I use Linux (Ubuntu) on my netbook and I have written a small program to control my trains through a Hornby Elite controller. The software on my netbook is actually a web server so I can use the browser on my Android phone to drive the trains without any need for special software on the phone. The phone, rather than the netbook, provides the Wifi connection.

 

If you are new to this the idea of a web-server might be intimidating but most of it comes from an off-the-shelf free package and my program only has about 50 lines of code plus the HTML stuff needed to create the screen displays.

 

It may be possible to get this sort of thing to work on a PI.

 

...R

Interesting concept Lyneux, so thanks for sharing this.
I already have a Pi and have been looking for an iPad / Android wireless solution so this may be an option. I see there is now a Sprog3 with a 2.5A booster. I assume this should work the same?
Really can't make my mind up between trying something like this or waiting for the Hornby elink to come out.

Thanks
Dave

Link to post
Share on other sites

  • RMweb Gold

Interesting concept Lyneux, so thanks for sharing this.

I already have a Pi and have been looking for an iPad / Android wireless solution so this may be an option. I see there is now a Sprog3 with a 2.5A booster. I assume this should work the same?

Really can't make my mind up between trying something like this or waiting for the Hornby elink to come out.

 

Hi Dave

 

Yes, it will work the same.  In fact I tihnk it is a simpler solution than the Sprog Nano plus SBOOST.

 

Cheers, Mike

Link to post
Share on other sites

  • 3 weeks later...

On a related topic: I've just thought it would be quite useful to make a cheap throttle to use with this setup (i.e. a hardware throttle) -- something along the lines of:

 

- AVR to communicate with the RPi (or other PC) over USB.

- Potentiometer as throttle (read using the ADC in the AVR) -- or possibly a rotary encoder (not sure if a continuous rotary encoder would be useful?).

- Some buttons and switches as input: one directional, possibly a few functions. (Loco selection etc. would be done on the PC -- i.e. I'd probably modify JMRI's throttle to read the throttle setting from the AVR.)

 

It wouldn't be particularly beatiful or sophisticated, but would allow finer control of the loco than a touchscreen/computer interface, for hardware cost of ~£20-30.

 

Has anyone heard of anyone else doing a thing / potential problems? (I know of the OpenDCC Throttle, but that's a much more complicated system, AFAICS without a PC involved.) It would also be possible to interface directly to the RPi, but it lacks an ADC so at least one interfacing chip would be required, and using USB means it's not RPi specific.

 

In any case, I'm digging into the JMRI code at the moment to see how easy this would be...

Link to post
Share on other sites

  • RMweb Gold

On a related topic: I've just thought it would be quite useful to make a cheap throttle to use with this setup (i.e. a hardware throttle) -- something along the lines of:

 

- AVR to communicate with the RPi (or other PC) over USB.

- Potentiometer as throttle (read using the ADC in the AVR) -- or possibly a rotary encoder (not sure if a continuous rotary encoder would be useful?).

- Some buttons and switches as input: one directional, possibly a few functions. (Loco selection etc. would be done on the PC -- i.e. I'd probably modify JMRI's throttle to read the throttle setting from the AVR.)

 

It wouldn't be particularly beatiful or sophisticated, but would allow finer control of the loco than a touchscreen/computer interface, for hardware cost of ~£20-30.

 

 

I couldn't agree with you more - except I used a PIC.

 

Your price estimate is pretty spot on too for the cost of materials but excluding DIY hours and the cost development time! (It's a labour of love...)

 

Although my design has a H-Bridge built in, I did leave an expansion port free on the board for 'future plans'.

Such plans include:-

Comms, (via Bluetooth, USB or RS232), to - or from - a PC.

A DCC interface/Booster/Driver.

A wireless Loco Decoder.

On board Battery supply.

 

A Quadrature Encoder, or what you call a "continuous rotary encoder" is also on my mind but in this case quite easy to implement as dedicated peripherals are being added to PICs all the time, or you could just achieve it with interrupt-on-change and bit-banging.

 

 

The development board design, and the throttle design/build, are all described in the 2012 Challenges. Just look for “Smart Driver Board” or “Throttled CAB Controller”.

 

I'm holding off on further work until last years voting is over and then I'll continue.

:)

 

 

Kev.

Link to post
Share on other sites

I couldn't agree with you more - except I used a PIC.

 

I did put code on the Lenz yahoo group for a simple throttle using an Arduino, a rs-485 board, a potentiometer, and a toggle switch. (oh, and a lenz bus connection, eg 5-pin DIN connector)

 

Todays thought is using the WIImote and JMRI - some work already done there, so the work is done.

 

I'm a fan of tactile feedback, not visual feedback, based on full-size steam railroading, and having colleagues working in human-factors work, so the Android/iPhone solutions are not optimal, IMHO.

 

More if anyone wants discuss!

 

John A. Stewart

Ottawa, Canada.

Link to post
Share on other sites

How could it possibly provide finer control than a touchscreen/computer interface which could easily be programmed to give 1000 throttle steps - if that was any use.

 

And if you already have a PC and smart phone it wouldn't cost a penny!

 

...R

 

 

snip...

It wouldn't be particularly beatiful or sophisticated, but would allow finer control of the loco than a touchscreen/computer interface, for hardware cost of ~£20-30.

snip

Link to post
Share on other sites

 

The only reason I see for going the mobile phone route is the as-yet-to-be-implemented option of having a live video stream from each loco you're controlling, allowing operators to run the train as if they were inside the cab... :) And thus obey signals et all ;) :yes:


 
It would be interesting to see this working where it has already been implemented on an out of the box DCC system; i.e. the Roco Z21.
 
Roco showed it working at the recent Nuremberg trade show and I think the feature is enabled on then next update, if it's not already happened.
The video stream is displayed through the cab windows when driving using the cab view option.
 
 
Link to post
Share on other sites

there are capacitative stick-on knobs for touch screen displays, usually sold to make a games console replica.   If the software App were redesigned to use those as an option, then the physical knobs can be added very cheaply.

 

Or, as RoundHouse says, the volume buttons are always available to the programmer (probably more readily available in Android than Apple iOS).

 

 

- Nigel

Link to post
Share on other sites

Perhaps what we need is a USB/Bluetooth 'knob' add-on for phones that will enhance the tablet experience without costing a fortune. I have seen desktop ones but a bit to bulky to velcro to a phone.

 

Interesting that you should say that, as I've been thinking about a similar solution for a couple of years.

 

Go into any Apple Store and you will see there are no tills or pay points. None whatsoever!

 

All the staff are equipped with an iPhone docked on a handheld base unit (looking much like a large battery pack on the back), encased and protected in a rubber "bumper".

This set up looks like a pocket sized version of those wireless credit/debit card payment devices that are used in shops and restaurants, but with a completely touch interface without the physical buttons. 

 

Seeing photos and videos of the Ring RailPro handset, which has a large screen with a touch interface, but also a physical knob; galvanised my thoughts about combining a smart device like a phone/iPod with a host base unit that could contain one or two physical controls like a control knob or thumbwheel. 

Such a combination of touch screen and physical control(s) would be a very useful solution in providing both a modern user interface, along with the physical and tactile control(s) that many people prefer.

 

The resulting handset would have a recess ready to accept a smartphone or iPod, which would just clip in and clip out again after use.

The benefit would be the much reduced cost of developing and producing a modern day DCC handset equipped for both simple and sophisticated applications.

 

Another benefit would be that this handset could be used across many different DCC platforms, subject to suitable control apps being available.

 

 

.

Link to post
Share on other sites

  • RMweb Premium

Interesting that you should say that, as I've been thinking about a similar solution for a couple of years.

 

Go into any Apple Store and you will see there are no tills or pay points. None whatsoever!

 

All the staff are equipped with an iPhone docked on a handheld base unit (looking much like a large battery pack on the back), encased and protected in a rubber "bumper".

This set up looks like a pocket sized version of those wireless credit/debit card payment devices that are used in shops and restaurants, but with a completely touch interface without the physical buttons. 

 

 

.

I seems to be taking a long time to get to this sort of wireless processing kit into mainstream use.

 

Many years ago (20?) I went in to a restaurant in the UK which took your order on a machine about the size of a modern cordless Credit Card machine. When the order was complete the waiter/waitress pressed a button on the device and the order was transmitted to the kitchen. I believe the machine was docked into a charge point between uses.

 

An excellent idea I thought at the time (suitable for all sorts of uses), but it doesn't seem to have advanced much in the meantime.

 

Keith

Link to post
Share on other sites

Archived

This topic is now archived and is closed to further replies.


×
×
  • Create New...