Jump to content
 

WiFi locomotive control


SimonME46

Recommended Posts

Hi Folks

I've been working on a WiFi/Arduino mobile Decoder for my O gauge locos, with a view to using JMRI for its Virtual Sound Decoder under baseboard sound setup. I've never done any coding, so it's taken me a few months, and I must admit to quite enjoying the challenge. Certainly the outcomes where a funny looking bunch of wires actually do what I want them to do is rather exciting! Unlike DCC, I feel like a have flexibility and control..

 

So the basic idea is that I wanted BPRC for motor control, servos for front and rear couplers, a servo for the outside valve gear reverser, forward and rear lights, firebox light.

 

I've got it working, sketch is available at https://github.com/SimonME30/DCCpp

Another hardware option would be to use the Deltang boards, and this would actually be a very small, neat, cost effective package. I'd just need to pick Robin's brains a bit.

 

I don't intend to use iPhones etc to control my locos, but that is an easy option via JMRI.

Link to post
Share on other sites

Interesting. Are you masquerading under the name StefanBruens on Github - or is that someone else (just so I understand).

 

I'm not clear from your description here or on Github exactly what the ESP8266 does for you? Maybe you could make a simple block diagram showing all the parts in your system.

 

If you are using an ESP8266 as a receiver I don't understand what you are thinking of using a Deltang device for?

 

I know, vaguely, what JMRI is (even downloaded it once) but I have never used it or studied its innards.

 

...R

Link to post
Share on other sites

Oops, sorry, somehow I grabbed the wrong link, I've corrected it now.

 

Hmm. I had a block diagram previously that I'd found on the web, pretty much described exactly what I was after. I'll go play on Inkscape and see what I can do.

 

With the ESP8266, I also need a DRV8833 and a 3v-5v step up and a 3v-9v step up. The Deltino is attractive as it is a neater package in terms of the H bridge, I need to double check how Deltang manages power, but at least the 3v-5v may not be needed.

 

I think JMRI is an off the shelf version of what you brewed yourself. Features I may use are Decoder pro (only if I do eeprom, or don't have access to serial/OTA updates). Operations/scripting will probably be good for documenting my working timetables, and could automate my fiddle yard so I just get to play trains on the visible side of the layout. And VSD should provide way better sound quality than any onboard DCC option, provided I can get the sound projects sorted.

Link to post
Share on other sites

With the ESP8266, I also need a DRV8833 and a 3v-5v step up and a 3v-9v step up. The Deltino is attractive as it is a neater package in terms of the H bridge

A Deltino would be a very expensive alternative to the DRV8833.

 

For my 00Gauge nRF24 wireless control system I feed the battery power (2S LiPo) to the DRV8833 and take power from it to a 3.3v regulator for the Attiny1634 and the nRF24. The Pololu DRV8833 has reverse polarity protection and short circuit protection and IIRC the Deltino has neither.

 

...R

Link to post
Share on other sites

Sorry I meant the Rx65 would be instead of an ESP8266 + DRV8833 combination. I just had another look through the Deltang specs. David has done a lot of work, but I see what you mean. 50euro and a reasonably closed 'bonnet' vs AUD30 and I can do whatever the heck I like in arduino land. You got me!

 

I've still got lots of things I can do, on track charging, wheel rev monitoring, and I think I will do momentum and braking on board.

Link to post
Share on other sites

If you are using O Gauge (with lot's of space) and you don't specifically need WiFi then I can recommend the nRF24L01+ transceivers and some form of Atmega MCU programmed with the Arduino system.

 

Another alternative to the DRV8833 is an Electronic Speed Control (ESC) (large selection at Hobby King) but many of them don't do reverse.

 

I did consider using ESP8266 WiFi modules as an alternative and I concluded that for a fleet of locos (which, of course, I will never have) it would be too difficult to guarantee the needed throughput without a very complex system. Normal internet usage is designed not to care about occasional delays in messages.

 

...R

Link to post
Share on other sites

I've read a bit about the wifi protocol being too much overhead. At present I'm working through (actually stuck) on how to get date from JMRI. Naively and ignorantly, I had hoped that just being on the same wifi network (said) would make things happy. But I haven't got the magic combination of JMRI DCC++ confit right yet. All part of the fun apparently. Unfortunately it's stopping me from making buildings! Must finish before moving on though.

 

Hence your nRF24L01 methodology may be much easier to get comms happening, and all the operating bits from my ESP8266 should just pop across.

Link to post
Share on other sites

Yes, I just used a USB-TTL cable. I mounted the Deltino on a piece of Veroboard that had a 6-pin connector on it to match that on the cable.

 

It's a long time since I used it and I cannot find it now so, sorry, no photo.

 

CAUTION If you are thinking of using my software be aware that there was a change in the Deltinos which required a change in the program so as not to damage the h-bridge. And sorry, right this minute I cannot remember which Deltino marked the change.  If you are thinking of using my program and if you need help please post the code you plan to use and I will try to figure it out.

 

...R

I've moved this over here so you aren't replying to 3 threads! Based on your comments about the DIY options, I probably won't go down the Deltino route.

Link to post
Share on other sites

I've moved this over here so you aren't replying to 3 threads! Based on your comments about the DIY options, I probably won't go down the Deltino route.

It'd be nice if some people on the Arduino Forum were considerate like that.

 

I don't think there is any alternative to the Deltang/Deltino system if you want to work with N-Gauge.

 

It also has the great advantage, for any Gauge, that it is an off-the-shelf solution that is as easy to implement as DCC.

 

But if you are using 00 Gauge or O Gauge and like tinkering (or need to save money) then there are simpler options - albeit in significantly bigger packages.

 

It would be an interesting Heath-Robinson project to use an Arduino to control a Deltang transmitter by attaching some servos to turn the knob and operate the switches :)

 

...R

Link to post
Share on other sites

This is an attempt at a block diagram for the what I consider to be the throttle control side of things. I 'think' I have found a way to connect with JMRI,via the DCC++ OVER TCP Server, just need to work out in the DCC++ base station code how it logs into the server, then drop that into my sketch. That and update the DCC++ base station code so that it will work on an ESP8266. I think I have seen where to do that. I think it wise to have DCC++ base station operating as expected.

 

To explain the diagram;

  • RPi3 with JMRI, used for
    • Fiddleyard automation (stepper motors),
    • operations scripting
    • auto Mill Lane signalbox, offer trains/receive trains
    • auto stop locos in the fiddle yard
    • under baseboard 5.1 sound via Virtual Sound Decoder
    • Location reported via RFID reader, (loco's could report their own position via optical encoder)
  • WiFi Custom Throttle
    • Laser cut from plywood to look like relevant steam loco backhead with reverser, regulator and brake
    • labelled switches for front/rear coupler, front light and rear light
    • variable momentum (eg Light engine, ECS, short train, long train), use DCC function values for this
    • likely rotary selector for a hardcoded list of relevant locos (ha, just like selecta!)
    • ESP8266 based (flexible)
  • WAP
    • Not sure about this, it was cheap, and powerful, but may not work without an internet connection
  • Locomotives
    • use the above ESP8266 WiFi decoder sketch
    • 1s LiPo 2000mah so no balancing needed, onboard protection board,
    • recharge through the track (rectifier/cap)
    • 12v step up VR for Motor Power
    • 5v step up VR for servos
    • DRV8833 H-Bridge
    • Front & Rear Coupler Servo's
    • Reversing gear Servo
    • Bi-Colour red/warm white front and rear lamp, rear lamp selectable (not yet done)
    • RFID tag (not done yet)
    • Optical encoder or similar to report wheel rotation/maybe exhaust beat timing
  • Track - 5v or similar DC at loco storage locations in fiddle yard, could also be adjacent to watering points in the station

 

throttle CTRL Diagram.pdf

Link to post
Share on other sites

Thanks for that - very interesting.

 

I presume th RPI will be acting as the web server to which the WiFi throttles and the WiFi locos communicate?

 

How frequently do you expect messages to go between a loco and the server?
And how much delay in one of those transmissions would be acceptable?

 

My own feeling is that implementing the same scheme with nRF24L01+ wireless modules would allow you to have more control over the wireless activity - assuming you are not already very expert on the innards of WiFi. But I do see the attraction of the self-contained ESP8266.

 

 

I have not tried it yet (and don't hold your breath while waiting :) ) but my assumption is that a simple Light Dependent Resistor (LDR) will be sufficient for train position detection on the assumption that my PC will know  which train it has sent where so if an LDR detects a train it can assume the identity of the train.

 

...R

Link to post
Share on other sites

I had hoped the RPi3 would be the server, I'm watching development on a thread I started http://www.trainboard.com/highball/index.php?threads/dcc-wi-fi-receiver-trackside-or-onboard.99820/page-5

 

Messages - should be anytime a change occurs, not constantly like DCC. The only ack I'm aware of is for throttle commands, and cv write (which I haven't done yet)

 

Delay, seems to be pretty small, and I'm not sure it's critical. Given the substantial momentum I plan to build in..

Link to post
Share on other sites

I am developing something very similar but in a larger scale (gauge3).   I am using a nodemcu (esp8266) as the on-board controller with the server running openhab2 on a Raspberry Pi3.

 

Here is a video showing the first trail

 

 

Am using phones or tablets as the hand held controllers.

 

Am also playing with brushless motors and arduino

 

 

next step is to merge the two projects.

 

Will follow your work with intrest

Link to post
Share on other sites

Looks very interesting. OpenHAB looks pretty powerful!

 I think it has great potential.  It would be possible to write a DCC binding for example to control DCC locos and wifi locos at the same time.  With the rules engine it should be possible to implement block signaling as well.

 

I have just connected some household lights to OpenHAB and now can control them by voice via an Amazon Echo.   Should be very simple to modify that slightly to get voice control for locos!

 

G

Link to post
Share on other sites

Archived

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

×
×
  • Create New...