Jump to content


Google Ads are only seen by non-members of RMweb - Create an RMweb account and you'll only receive modelling ads.

Posted Image What was your favourite model of 2017? Cast your vote


Photo
* * * * - 1 votes

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

Sprog Nano Raspberry Pi JMRI DCC Wireless iPhone Sprog Edimax




  • Please log in to reply
82 replies to this topic

#1 lyneux

lyneux

    Member


  • Members
  • PipPip
  • 701 posts

Posted 17 February 2013 - 20:33

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

PiProject.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.

 

IMG_0582.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


  • Like x 10
  • Informative/Useful x 3
  • Thanks x 1

Google Ads are only seen by non-members of RMweb - Create an RMweb account and you'll only receive modelling ads.

#2 Nigelcliffe

Nigelcliffe

    Member


  • Members
  • PipPip
  • 3,196 posts

Posted 17 February 2013 - 21:18

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

#3 ukinfidel

ukinfidel

    Registered Member


  • Members
  • Pip
  • 17 posts

Posted 17 February 2013 - 22:13

Looks great. I might have a go at getting something similar going myself as I have nearly all the parts already!



#4 lyneux

lyneux

    Member


  • Members
  • PipPip
  • 701 posts

Posted 17 February 2013 - 23:00

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.



#5 Nigelcliffe

Nigelcliffe

    Member


  • Members
  • PipPip
  • 3,196 posts

Posted 18 February 2013 - 08:27

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



#6 Robin2

Robin2

    Member


  • Members
  • PipPip
  • 777 posts
  • LocationNear Manchester

Posted 25 February 2013 - 10:28

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



#7 Nigelcliffe

Nigelcliffe

    Member


  • Members
  • PipPip
  • 3,196 posts

Posted 25 February 2013 - 10:46

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



#8 Dutch_Master

Dutch_Master

    Member


  • Members
  • PipPip
  • 5,392 posts

Posted 25 February 2013 - 13:49

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

 

You must remember that you're booting a full modern Linux environment on a machine that has the computing power of well over a decade ago. Raspbian can be tweaked to shorten its boot times, but that requires some serious tinkering, like removing unwanted drivers and modules, a new, trimmed down kernel and some serious pruning in the installed packages. That ain't for ordinary Linux users, let alone the model railway fraternity. Mind, Java (what JMRI is build on) also has some overhead and so also takes time to start. A comparison with RocRail could be interesting.

 

Setting up a wifi AP isn't that difficult, see

man iwconfig
A small bash script to configure and boot the AP on boot is not too difficult to write...



#9 Rammy

Rammy

    Member


  • Members
  • PipPip
  • 531 posts
  • LocationDerby - home of the mighty Rams!

Posted 07 March 2013 - 00:11

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

#10 Dutch_Master

Dutch_Master

    Member


  • Members
  • PipPip
  • 5,392 posts

Posted 07 March 2013 - 02:13

Depends on what you'd expect from whatever solution you choose: if you want it 'plug&play' then wait for the commercial offering. If you want some tinkerin'round and learn something in the process, the RPi is the way to go :yes: (mind, it's Linux. Finnish, not French :P )



#11 Robin2

Robin2

    Member


  • Members
  • PipPip
  • 777 posts
  • LocationNear Manchester

Posted 07 March 2013 - 08:54

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



#12 red death

red death

    Member


  • Members
  • PipPip
  • 2,197 posts
  • LocationLondon

Posted 07 March 2013 - 10:10

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


  • Like x 1

#13 MattWallace

MattWallace

    Member


  • Members
  • PipPip
  • 792 posts
  • LocationWales

Posted 10 March 2013 - 20:18

If it's of any help, https://github.com/proffalken/JMR-Pi is a script that I wrote to auto-install and launch JMRI on the R-Pi.

 

It will install the latest "production" release of JRMI by default.

 

Matt


  • Like x 2

#14 icn

icn

    Registered Member


  • Members
  • Pip
  • 14 posts

Posted 27 March 2013 - 18:34

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...


Edited by icn, 27 March 2013 - 18:35 .


#15 Dutch_Master

Dutch_Master

    Member


  • Members
  • PipPip
  • 5,392 posts

Posted 27 March 2013 - 20:05

There are continuous rotary encoders with build-in pushbutton available, but for comfort you'd need a bunch of other buttons too: for the various functions (F0-F?? ) modern DCC systems support. If set up cleverly, you could double the keyboard for decoder entry as function buttons too. In any case, you'd need a display to see what's going on. Plenty of choice: LCD, LED, even with alphanumeric text... But it all adds to the price, coming ever closer to a commercial offering. That carries a warranty too :P


  • Like x 1
  • Informative/Useful x 1

#16 SHMD

SHMD

    Member


  • Members
  • PipPip
  • 1,694 posts
  • LocationManchester

Posted 27 March 2013 - 20:13

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.



#17 sncf141r

sncf141r

    Registered Member


  • Members
  • Pip
  • 12 posts

Posted 28 March 2013 - 01:28

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.



#18 Dutch_Master

Dutch_Master

    Member


  • Members
  • PipPip
  • 5,392 posts

Posted 28 March 2013 - 03:52

May I suggest a new thread then, as not to pollute this one with all the boring techie stuff ;)

 

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:



#19 Robin2

Robin2

    Member


  • Members
  • PipPip
  • 777 posts
  • LocationNear Manchester

Posted 28 March 2013 - 07:30

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



#20 Ron Ron Ron

Ron Ron Ron

    Member


  • Members
  • PipPip
  • 4,329 posts
  • LocationPlanet Spud

Posted 28 March 2013 - 13:27

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.
 
 

  • Agree x 1

#21 Suzie

Suzie

    Member


  • Members
  • PipPip
  • 2,178 posts

Posted 29 March 2013 - 13:31

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.



#22 roundhouse

roundhouse

    Member


  • Members
  • PipPip
  • 9,335 posts

Posted 29 March 2013 - 14:01

Android smartphones do now make use of the volume buttons on the dude of the phone if using JMRI which does give some tactile control even if it's not a turning knob

#23 Nigelcliffe

Nigelcliffe

    Member


  • Members
  • PipPip
  • 3,196 posts

Posted 29 March 2013 - 14:47

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



#24 Ron Ron Ron

Ron Ron Ron

    Member


  • Members
  • PipPip
  • 4,329 posts
  • LocationPlanet Spud

Posted 29 March 2013 - 14:50

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.

 

 

.


  • Like x 1

#25 melmerby

melmerby

    Member


  • Members
  • PipPip
  • 6,938 posts
  • LocationWorcesterhire

Posted 29 March 2013 - 20:44

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








Also tagged with one or more of these keywords: Sprog Nano, Raspberry Pi, JMRI, DCC, Wireless, iPhone, Sprog, Edimax

Google Ads are only seen by non-members of RMweb - Create an RMweb account and you'll only receive modelling ads.