# Experimental Control System



## davidarf (Jan 2, 2008)

For many years I have used radio control and battery power for electrically powered locomotives because this has given the best solution for working along side live steam and portability to operate on any track. Last year the Sierra sound unit in my MTH F3 died and I could not find a suitable replacement. The only option I could find at the time was from Phoenix and is far too expensive. This prompted me to look for another solution. Having worked with DCC in smaller scales, I had no desire to go back to that and the cost of most DCC solutions is prohibitive.

The only option seemed to be to come up with something new. The simplest starting point seemed to be Arduino microprocessors because of the vast amount of support on the web, the flexibility in design available, and the very low cost of the components. I also found an excellent sound solution in a board called the Wave Trigger, which plays simple WAV files from a micro-sd card.

A fundamental design decision was to drop the use of the speed dial/slider/stick found on most control systems. Instead I opted to use a command control solution. For diesel electric (in my prototype), I provided for direction switches, engine notch switches and brake switches. The commands from these are transmitted to the loco (or lead loco in the case of a consist) and the on board processor uses these to drive the loco (and to control the followers in a consist). The results of the commands are also reported back to the control, including the current speed in scale MPH.

Here is a film of the first test run of the prototype system 




There is still much fine tuning to do, but the solution is already providing a very interesting driving experience.


----------



## East Broad Top (Dec 29, 2007)

Cool! I take it that by programming the load, you're essentially adjusting the momentum on the throttle as well as the top speed per "notch?" 

On the brake side of the equation, are they proportional (i.e., do they stop the train faster the longer you apply them? Can you do something like a retainer setting which would trim the top speed for a given notch and load?

Later,

K


----------



## davidarf (Jan 2, 2008)

East Broad Top said:


> Cool! I take it that by programming the load, you're essentially adjusting the momentum on the throttle as well as the top speed per "notch?"
> 
> On the brake side of the equation, are they proportional (i.e., do they stop the train faster the longer you apply them? Can you do something like a retainer setting which would trim the top speed for a given notch and load?
> 
> ...


Thankyou for your comments and questions.

Acceleration time and achievable speed are both a function of locomotive power and train load and so, although a given train may be capable of reaching maximum speed at notch 4, it would do so quicker at notch 7. The engine can then be backed off to notch 4 to cruise.

Deceleration times are a function of speed and train load, and so deceleration per MPH at high speeds is longer than at slow speed. Application of the brakes adjusts the deceleration times only while the brakes are applied and in proportion to the braking force applied. I am still refining the formulae that I have created based on the tests now that I have a rolling solution.

I did not come across the "retainer" concept in my research and so it is not catered for. Theoretically, it could be included. The strength of this solution is in having processing power in both the control station and the locomotives and the two way many to many communications, giving the ability to add new control concepts and to adjust settings while running. When I move onto a "steam" solution, I will of course add the regulator and this will need new formulae to work with the load and "notch up" settings to calculate potential speed and acceleration times. For diesel electric and electric power I considered the inclusion of switching between parallel and series connecting of motors during slow speed set off, but decided to leave that out for now. I have also done some work on gradient adjustment, but have yet to find a sufficiently stable gradient measuring device. I can get very precise gradient measurement at rest, but this becomes too unstable while the locomotives are in motion. Another possible solution for this is on order and will be tested at a later date.

David


----------



## Beddhist (Dec 17, 2013)

This is so cool! I was wondering when a manufacturer would come out with the first driveable train control system, but you have beaten them all to itl

Are you posting details/pictures/diagrams anywhere?

Regards,
Peter.


----------



## davidarf (Jan 2, 2008)

Peter

Many thanks for your comments. 

I got started on this because I had spent almost 2 years looking for a good affordable commercial control solution, including writing to some manufacturers to see if there was any chance of something to meet my specification. As it is still very much a work in progress I have not posted any details yet. The software changes too frequently at present and I would need to clean up the development mess. From a hardware standpoint, the solution is now quite stable. The locomotive units and controller are all based on the Arduino Mega 2560. I selected this over the smaller options because it gives 4 serial ports to play with. The communications use a Zigbee network based on XBee 2.4GHz modules. In the controller, the screen is a very simple 20 by 4 LCD module and the keypad was home built on a circuit board cut on my CNC mill. In the locomotives, power to the motors is via Dimension Syren 10s. These are excellent units and are easy to set up to receive serial input from the Arduino. Lighting, all converted to LEDs, is switched directly from the Arduino. Sound is generated on a WAV Trigger board, again controlled via serial from the Arduino.

Once I am happy that the solution is stable I will post pictures and parts lists together with my code on the Web. I am sure that there are better programmers and designers out there that can do a much better job of this, but I wanted to prove to myself that a solution better than the current commercial offerings is possible.

David


----------



## TonyWalsham (Jan 2, 2008)

Good luck David.
Just watch out for the DCC Kool Aider's who sure as day is not night will want to keep their pet system in the vanguard.
If you are considering going into manufacturing you will do well as long as the cost is less and the performance is better than your opposition.


----------



## lotsasteam (Jan 3, 2008)

I am with you guys, DCC Sucks (D rinking, C racking up and C oughing )


----------



## Skeeterweazel (Feb 11, 2014)

David, thx for sharing this. I'm using an Arduino (micro?) to act as a "cruise control" for my little live steamer. I'll keep an eye out for your updates. I'm sure i'll learn something.
Marty


----------



## davidarf (Jan 2, 2008)

Thankyou again everyone for the kind words.

Tony - I have no plans or intention to go commercial with this. I don't have the time or the skills. This project is to meet my needs and to prove the concept. In terms of costs and buying in small numbers, the controller has cost me just over $50 and the parts for each loco just over $90 without the Syren10 that I already had. This would put on another $60. I have another test rig without sound and speedometer and the parts for this came to just $35. I am sure that the parts could be sourced commercially for less than this.

Marty - I have worked up another test rig using an Arduino Nano to demonstrate to a friend how to hook onto a radio control receiver to switch lights at a cost of less than $5.

David


----------



## Martan (Feb 4, 2012)

Another Xbee fan


----------



## Michael W (Oct 10, 2012)

Amazing, where did you get the sound files from?


----------



## Greg Elmassian (Jan 3, 2008)

Very nice to see a loco running by notches.

What is the hardware cost for all the electronics in the loco? You must have a receiver and the main processor and I would guess motor drivers, and then something for lights.

Thanks, Greg


----------



## davidarf (Jan 2, 2008)

Thankyou for the interest in this project.

The sound files were created from sound clips that I found on the web, for example in film clips on Youtube. I was only able to get very short clean clips and have had to build the sound files from them using Audacity. I had only one clean notch sound and created the rest by pitch and speed shifting. The transition files were then created from those, again using the editing features in Audacity. Each notch change sets of the appropriate transition file, stops the old notch sound and then swaps from the transition file to the new notch sound. The Wav Trigger board is great and very easy to control. It allows me to play multiple files so that the engine sound is not cut out when I play the horn or brake sounds. I had searched the Web for a source where I could buy a suitable set of WAV files, but could not find any. This would have saved me many hours of searching through film clips and then more hours of sound editing experiments.

An outline list of the main components is in my earlier post of 16th March.

I found a slight problem using the Syren10 in that it would occasionally go to full speed when the loco is switched on. A message to the technical support at Dimension quickly resolved this when they pointed out that I had created a ground loop in my wiring. I am indebted to Dimension for their quick and helpful support.

The system was recently tested at a large show venue and performed faultlessly with many other 2.4GHz radio and wifi systems in use in the same building. Following that success, I am in the process of a significant rewrite of my software to give me more control parameters that I can then set up from the controller (to save having individual programs for different locomotives), to add in a regulator for "steam" models and to adjust slightly some of my power, weight, acceleration and deceleration calculations.

David


----------



## Greg Elmassian (Jan 3, 2008)

So the parts for a loco, equivalent to an R/C system with a sound board, or equivalent to a DCC motor and sound decoder is $150? (I see that should take you to 10 amps)

So can I also assume you are using Wi-Fi? 

Are you going to do all your locos like this? Just wondering, it would seem that it makes sense for you with just a few locos, but not economic sense if you were doing a fleet.

The system appears to run nicely with the software you have, a few more tweaks and it would be a competitor for the basic DCC functions, and also seems flexible enough that you do not have to be rigidly bound to DCC "speed steps", which DCC can never give up.

Regards, Greg


----------



## davidarf (Jan 2, 2008)

Technically, my system does not use wifi. The Xbee modules use the Zigbee protocol which, as far as I can fathom is very similar to wifi. It has great benefits over standard R/C and Bluetooth in that it is possible to set up reliable, self checking many to many the communication that I use in consist mode where the controller and lead loco talk two way and the lead loco and followers also talk two way.

I will probably convert all of my battery powered locos. It is quite inexpensive for locos without sound - less than $30 because I already have Syren 10 modules in them. The locos where I want sound are a bit more expensive, but no where near the cost of something like a Phoenix sound board. One of the main benefits to me is the better driving experience. Bringing a train to a halt in a station takes quite a bit of practice in manipulating the power and brakes.

The latest update of the software is nearly complete and I hope to test it in a few days. 

David


----------



## Greg Elmassian (Jan 3, 2008)

Just trying to get a calibration. I completely understand the incremental cost to you is low since you have the syren 10 units, which are $50 street price now.

Sorry, I missed that you did indeed indicate 2.4 GHz Zigbee

So the Arduino Mega 2560 at about $35
Syren 10 motor driver at about $50
Zigbee module $26 (probably want the 2 mw unit?)
And for sound you say there is more cost, do you add more computing power or some other module?
Also, what about lighting outputs?

This does indeed seem to be a possible alternative.

Regards, Greg



So, is the Zigbee module available incorporated into the


----------



## Martan (Feb 4, 2012)

David, very interesting project- I am a big Atmel and Xbee fan. You mentioned you were not interested in a commercial situation, would you be game to an open source sort of thing?

Martin


----------



## davidarf (Jan 2, 2008)

The last Arduino Mega I bought cost about $11 - $35 is way to high and XBees are about $18. The sound board is the Wav Trigger that can be obtained from Sparkfun for about $50. This has it's own on-board processor that can be controlled through physical contacts or by serial link from the Mega.

Lighting is all LED in the F3s that I have converted and these can all be switched from the Mega by adding just a small current limiting resistor of very little cost. I am using 6 of the digital outputs of the Mega for this. By comparison, with radio control I was using R/C relays that were costing me over $26 each lighting circuit. If I were to leave the conventional light bulbs in place I could have switched them with relays that connect to the Mega data outputs and these cost about $1.50 each.

I have no plans to make this a commercial operation and at present the software is still not ready to be made available to anyone else. Once I am satisfied that I have a settled solution I will clean up the code and then make it available on the web along with an outline of the physical design.

David


----------



## Greg Elmassian (Jan 3, 2008)

The best I can fine 2560's is about $14, sparkfun still has them at $45
the sound board is the kicker, as it should be, in the high end sound decoders the majority of the cpu is working with sound, but not just playing loops.

so:
main cpu 2560 $14
sound board $50
motor driver $50
Zigbee wireless $18

so $132 for a wireless receiver with looped sound, 8 amp motor driver (@ 24v), not bad...

Greg

Greg


----------



## IPTRAIN (Jun 1, 2012)

Greg Elmassian said:


> ....
> 
> Are you going to do all your locos like this? Just wondering, it would seem that it makes sense for you with just a few locos, but not economic sense if you were doing a fleet.
> 
> ...


Hi Greg

wouldn't confirm that! 
WiFi is cheaper than even DCC technologies - meanwhile - as to economies of scale! 

Just have a look at this board from China, which is a fully integrated wifi enabled microcontroller. 

http://hackaday.com/2014/08/26/new-chip-alert-the-esp8266-wifi-module-its-5/

https://en.wikipedia.org/wiki/ESP8266

with a huge community wordlwide http://www.esp8266.com/

https://www.linkedin.com/topic/esp8266

In China you can get the entry version below 2$ /transport included)!

http://de.aliexpress.com/item/Free-...ansceiver/32341788594.html?isOrig=true#extend

Just connect this board to a 10$ China H-Bridge (10 Amps )... and your locos are Smartphone wifi control enabled - with some electronic "chicken food" added - for below 15 $. 

Some more comfort available below 20 - 25 $

https://en.wikipedia.org/wiki/ESP8266#AI-Thinker_modules.5B11.5D

Regards


----------



## Greg Elmassian (Jan 3, 2008)

you forgot sound... and the sound in this thread is simple looped wav files.

the wireless part is actually trivial, Zigbee or WiFi or high power bluetooth is just a vehicle since you are dealing with an operating system that abstracts the physical interface.

I'm just comparing apples to apples, if I wanted a cheap DCC motor and function only controller, I can get D408 decoders for 35 bucks.

it's motor and function and sound that people want to buy.

Greg


----------



## Michael W (Oct 10, 2012)

Amazing Project, what Batteries and how many do you run? And to you run the mega from the same Battery pack than the motor?


----------



## davidarf (Jan 2, 2008)

Michael, 
The F3 locos run each using a 5 cell LiPo pack which powers everything on the loco. The controller is powered from 3 LiFePO4 cells. I also have a test rig in a wagon that I run behind a small "steam" loco and this runs on a three cell LiPO.

The system is designed control one loco at a time because of the design concept of command based "driving" the loco. I prefer this to the conventional speed control based method. 

The consist running is only tested with two locos at present and I will probably need to make some further adjustments to the software when I have a third diesel available to add to the consist. I have not yet progressed this option because I have been working on developing the software to cope with "steam" locos where I needed to add in the regulator function. This has been a significant change and is now being tested. I hope to take the system to a garden meeting on Saturday to give a good thrash on a different track and in close proximity to R/C systems controlling both live steam and battery powered trains.

A number of other refinements have been added to the software to help cope with different battery power and loco performance, and to cope with a situation where the controller "fails" (eg if switched off accidentally or runs out of battery power).

David


----------



## Michael W (Oct 10, 2012)

Thank you very much David, would you mind telling me what setup you use for the batteries? I.e 18v 4 amp?
Also could you post a picture of the pack?
Kind regards
Michael


----------



## davidarf (Jan 2, 2008)

Michael
The LiPO cells are 3.7v and therefore 5 cell packs are 18.5v nominal. The ones that I have show 4000 milliamp hour on the outer wrapper but I have never checked this to see if it is correct. Straight from the charger, I usually get about 20v. I have just charged them up and refitted them for the run tomorrow but will try to remember to get a photographs of one of them when I next take them out for charging.

I had a quick test run this morning on my track and the results were very encouraging, having sorted out some of the minor issues that I identified from previous test sessions. Hopefully, I will have a good run tomorrow at the garden meeting.

David


----------



## Michael W (Oct 10, 2012)

Wow thank you David, this means you run one pack 18.5 volt at 4 amp, this would be suffcient for my needs. I loved reading about your idea you have essentially done what I am toying with. I am planning of going the rasperry way tho...
Keep u the amazing work...


----------



## davidarf (Jan 2, 2008)

Here is the film I took of the test run at the garden meeting yesterday.





It was a very successful run but I still need to make a few more adjustments. I had many positive comments, particularly about the sound. The sound level seems to be just about right - loud enough to be interesting but not intrusive and annoying.

David


----------



## davidarf (Jan 2, 2008)

Since my last post I have been working on a cut down version of my control system to mount in a following vehicle (in my case a railway container) for powering smaller locomotives. It has no sound facility but does have regulator control for "steam" type locomotives and also now has locomotive battery level monitoring. Here is a link to a video clip of today's test run, including some photographs of the construction on the container and of the circuit board that I have cut for the XBee, the Arduino Nano processor board and the few ancillary components needed for this design.:





I am now working on a steam sound unit, but this is proving to be much more difficult that the diesel one already in use.

David


----------



## Greg Elmassian (Jan 3, 2008)

A helpful hint: simulate notching, that will limit the number of sound loops you need.

You can increase and decrease the volume to simulate load.

Greg


----------



## davidarf (Jan 2, 2008)

Volume adjustment to simulate load and notching (or cutoff) is relatively easy to program in and I agree that this is the route for that. The more difficult problem is to match to speed. Whilst physical triggers from the wheels/axles can synchronise steam blasts, these sound fine at low speed but as speed increases they get progressively more false in sound. The solution to this is to combine the tempo shifting provided by the triggers with progressive pitch shifting of the sound samples. This gives a more realistic effect, but is much more difficult to control. My experiments and investigation of the Wav Trigger sound board show that this is technically possible, but I need much more experimentation to find the best settings and then to develop the control programs to run it.

David


----------



## Greg Elmassian (Jan 3, 2008)

Actually pitch alone won't do it, chuff is very difficult, and the sound changes a lot. The length of the sound shortens, and the attack and decay change.

The real bottom line is you will get to a limit in this area and you need much more computing power, and at least a DSP to do it.

That's why not one of the high end sound systems do this with a simple microprocessor.

So, the best bet is to be "clever" with some new technique of simulating what happens.

Greg


----------



## VictorSpear (Oct 19, 2011)

I've used the Robertsonics desgined wav trigger you mention and discussed with Jamie, the designer extensively. It is a sophisticated product that uses the STM32 chip giving it plenty of ability but the board was being a little big footprint for my design. it also needed careful programmatic manipulation of the .wav files to achieve the desired affect. Often the 'woomph' would be lost and leave a staccato machine-gun effect at high speeds depending on the .wav recording. You also couldn't start the clip in the middle, so more interesting tweaks needed to be done using pause-and-resume toggling of the decay. I sorted most of it out over months of testing, but since then moved on to different polyphonic processor designs. 

Victor


----------



## Brandon (Jul 6, 2011)

Just curious why you picked the SyRen 10A vs say the 18v7 Pololu Simple Motor Controller that is cheaper?


----------

