Jump to content
 

DCC++ EX - One approach to a user interface


Recommended Posts

  • RMweb Gold

Having had a successful crack at the original DCC++ I was intrigued to see the recent developments with DCC++ EX and keen to have a go.   This is the result so far.


I'd used an Arduino Uno and  a Deek Robot motor board for my original DCC++ attempt and, for convenience, I used the original PC "Project" based user interface Ap.  It was fine for playing around with on the bench but certainly wasn't a serious contender for a practical layout controller in my opinion.  Not that that matters too much as yet as I haven't got a layout but when I do finally get round to playing trains properly the idea of having my head stuck in a computer seems to me to be missing the whole point!


The prospect of a proper, wireless controller to go with the base station plus, if I understand the "sales" patter correctly, a perhaps more professional, structured and extensible implementation of the code was most appealing. That isn't for one moment to take anything away from the original DCC++ developer;  whole original concept and implementation of the DCC++ system was such a brilliant bit of lateral thinking that if anything, I believe he deserves a medal.


I do have a pet DCC related hate though - FUNCTION KEYS!     I can't remember that F9 (pressed on a Wednesday morning before coffee) simulates a squealing, stuck brake block on the A4 pacific but F9 on one Class 37 (with a Wontgo decoder) makes the sound of the driver opening his Snap tin but F9 on the other Class 37 (equipped with a Superdooper Mk 29 decoder) turns the air compressor on and why the heck should I have to?     Perhaps the easiest way round such problems might be to employ a "user interface" that can be re-configured dynamically with appropriate labels etc.  That probably means using a Smart phone and a suitable app, either acquired for beer tokens or self-produced.  Although I've written plenty of software in my time I've never written a Smart phone App and I wouldn't know where to start ....   


Anyway I'm not going down that route; I'm toying with the idea of building my own handheld wireless controller with "controls" (buttons, levers, knobs, switches) that emulate the sort of thing that might be found in the cab of the real locomotive.    Fortunately, as I actually only have one locomotive (an O Gauge 08 shunter if you must know), the handheld controller will be bespoke to it both in terms of physical controls and the operation of certain features.    Of course, once the first one is up and running it shouldn't be that difficult to adapt it to another  type of loco.   One things for certain, I'm never going to have a stud of hundreds of locos!


My 08 is equipped with the Paul Cheeter sound file in the decoder.  This provides quite an array of supplementary sounds all triggered, of course , by different function keys but not necessarily representing things under the direct control of the driver.   So the plan is to embed logic in the hand controller to, for example, turn the air compressor on and off at appropriate times automatically but clearly related to brake applications as would be the case in the real loco.       Other locomotive devices that are manually operated by the driver eg the fuel transfer pump will have a suitable control and that will be down to Muggins here to make sure it's used at the appropriate times.   Maybe, if I don't operate the fuel transfer pump I shouldn't be able to start the engine and maybe the engine will stop of its own accord after extended use if the service tank runs out of fuel?  :scratchhead:


So, in this quest I've acquired a nice shiny new Arduino Mega, another Deek Robot motor board and an ESP01 WiFi board.    These have been assembled in a boring grey plastic box to form the DCC++EX base station.   Basically a very easy task indeed, the only slight complication is that because the WiFi module is not a shield it needed a little carrier module to sit on so that it could be wired in appropriately.  I've also added a couple of external LEDs to show when the power is applied to the main and programming tracks.  This created the need for a couple of transistor drivers driven by the appropriate outputs.   As I won't have a separate programming track I will be adding a slide switch to the base station so I can select Operating & Programming modes as needed but that's still on the to-do list.

 

1542849771_BaseStationInternals.JPG.e8d3840b0d7a62d0aa7befb7d944fc91.JPG

 

741876958_BaseStationIndicators.JPG.13f5bbc1cf5e1e498b9a5add5c488a23.JPG

 

 

982139332_BaseStationConnections.JPG.22939f484358c845040bee711c94f396.JPG


Once the base station was assembled I first tried using the wizard from the DCC++ EX website  to install the  software but although I could make it work using a USB cable and a throttle app on the PC  I could not get the WiFi module working, evidenced by the fact that try as I might I couldn't connect the "SRCP Client"  throttle app I was using for initial testing to the base station.  The SRCP Ap is German and doesn't seem to have a lot of documentation ....


In the end, I downloaded the DCC++ EX code, then explicitly set some WiFi parameters (IP address, network name and password if I remember correctly) and then built and loaded it using the Arduino IDE.   That was successful and I have to say I found it quite amazing when I was able to connect the phone app to the base station and was first able to drive the loco with my phone!


As I've said, the phone was just a convenient stepping stone so time to press on with the hand controller which will be Arduino based and equipped with a WifI module for comms to the base station.  Providing it with re-charargable batteries might be a smart move too!   


The next VERY big problem for me was writing a suitable WiFi client program for the hand controller.    Previously I've only ever been a user of WiFi and the intricacies of understanding details  of servers & clients were completely alien to me.   It's been a steep learning curve but I've got there!   To simplify things I decided to write the most basic of programs that would just enable the Arduino (that will one day reside in the non-existent hand controller) to connect to the base station and execute a couple of very simple commands;  How about "Main Track" power On and Off?  

 

Command formats were determined from the documentation but that was the easy bit.    How to actually send the required command strings via WiFi was somewhat more troublesome.   As I mentioned, it has been a very steep learning curve but little by little a suitable client was constructed, connected to the network and then the  server and finally commands successfully issued and received.   Again, it was amazing to see the LED on the little grey base station flashing on and off knowing that it was being controlled wirelessly by another little grey box with an Arduino in it sitting near by.   I was going to say simple things please simple minds, but that's being rather unfair - the achievement was far from trivial!


So, the next and most obvious step was to expand the repertoire of commands and actually make a loco move.   As the hand controller currently has no controls, the main program was extended to issue commands in sequence to drive the loco up and down a short length of track.   Those that have experience of Arduino programs know that it comes as second nature to an Arduino to then repeat such a sequence of instructions and that's where I am at the moment.

 

2049342404_DCCEXCommands.JPG.f12051f4fb9d3221255e30045811417f.JPG

 


Next step is to brush up on the real 08 drivers notes (isn't the internet wonderful!) and then determine how to use each of the functions on the Cheeter sound file most appropriately and then set about building the physical controller and writing the "proper" software for it.   Of course, if there are any real 08 drivers reading this I'm all ears, can you spill the beans please!


I'm going into the workshop now, I could be some time ......

 

 

Edited by PupCam
Added picture
  • Like 1
Link to post
Share on other sites

  • RMweb Gold

So, emerging briefly from the workshop for air (well, actually the study 'cos that's where the PC is and all the "work" is software at the minute) a modicum of progress has been made.

 

The general principle is to try and understand how the real locomotive works and build a simple "digital" model of its inner workings which is then used to operate the functions that the real driver doesn't touch.    This "model" runs in the hand controller (well it will ultimately) taking its inputs from the driving commands received and adapting its behaviour accordingly.   This model is the combination of a state machine and a number of function or system models.   So far the only actual function modelled is a very crude one of the air system pressure.   When the air compressor is on, the pressure rises until such time as the compressor would be turned off by the "real system".   Following which the pressure will decay based on system leakage (hopefully small!) and "consumption" i.e. brake application and release.    

 

The state machine monitors the "air pressure" and turns the compressor on and off (i.e. sends the DCC command to the loco to either turn the sound effect on or off) and operates other things such as the Spirax valve.

 

As I've spent my career in the aviation rather than the railway industry it will come as no surprise that I, along with most people, actually have no idea of the intricacies and complexities of the operation of, say, a humble 08 locomotive.    But it's fascinating trying to find out!

 

Anyway, the following image shows on the left-hand side the code which drives the loco (ultimately to be replaced by the hand controls).   Note there is no mention of turning the air compressor and Spirax valve on or off or turning flange squeal on (a random operation here).   The Eagle-Eyed will note that at present I have to explicitly state that the loco is not moving; this is to stop the embarrassing situation of the flanges squealing when stationary!   However, as the state machine and digital model are extended this need will disappear.

 

On the right of the image is some diagnostic data showing things like the air compressor on/off status etc.  You will note that as time passes (new values are printed every second) the air pressure is building.

 

245120397_DCCEXCommands2.JPG.a108efacf693a59d8814faeb5f9a30ec.JPG

 

 

The video shows the result.    So much to learn about real railway engine operation!

 

 

Edited by PupCam
  • Like 1
Link to post
Share on other sites

  • 2 weeks later...
  • RMweb Gold

So the latest updates to the WiFi controller are the addition of some proper manual controls so the locomotive can actually be driven.     At the moment these comprise a pot for the throttle, a toggle switch for direction and push buttons for brakes and horn.    The brake button will be replaced with a pot at sometime so a crude approximation of partial braking can be incorporated although the efficacy of this will ultimately be governed by the function of the decoder.   The throttle pot may well be adapted to replicate the 5 "notch" positions of the full size loco by some means.   

 

I've found and downloaded from the internet the BR 08 locomotive handbook.  If you just want to waggle a knob to make a loco go then it's not for you but I find trying to understand how the real thing works and then replicate it, as far as is practical, fascinating both in this project and previous ones (I learnt a lot about Vickers machine guns when I was building a 1/3 scale replica for a 1/3 scale model of a Sopwith Triplane but that's a completely different story!).

 

The handbook and other information I've found on the full-size 08 have provided a lot of information into the things that have to be (digitally) modelled in order to "control" the sound effects, for example the air pressure values when the air compressor cuts in and cuts out so rather than just make them up which is what I did initially I can now use the proper values.   These models are part of the Arduino controller and although only crude representations hopefully I'll be able to refine them a bit and get them to an acceptable level.    One big problem is that the model of the motion of the locomotive has, as far as I'm aware, to be be open loop as there is no way of actually getting data back from the loco when running.     The motion model isn't too bad but occasionally it thinks the loco has stopped when it is actually still moving and vice versa.     This isn't too serious a problem as the main purpose of the motion model is to prevent "flange squeal" sounds being played when the loco is stationary!  

 

Anyway, at least the loco can be driven at will now and the driver doesn't need to worry about pressing F16 to turn the air compressor on at an appropriate time.    There' still quite a bit to do with the code and a lot to do with the physical controller but it's coming on.

 

Here are the two boxes, the base station on the right and the wireless controller on the left although I should point out this is purely for development purposes and hopefully the finished item will look very different and somewhat more professional!

IMG_3585.JPG.6ba01f741f3dd7969331f9903e4f589a.JPG

 

All of the braking system sound effects (vacuum exhauster, air compressor and Spirax valve) sounds along with the flange squeal in the attached video are auto generated whilst the loco motion and horn is under the control of the driver.

 

Once the engine starts you will hear the vacuum exhauster and air compressor turning on and, as the air pressure builds the Spirax valve operating. Then when 21" of "vacuum" has been attained the exhauster cuts out followed shortly afterwards by the compressor turning off once 85psi "air pressure" has been achieved at which time the locomotive is able to release the brakes and move off.    The vacuum system will need a driver controlled switch as it is only actually used when hauling vacuum fitted stock.

 

 

 

 

Alan

 

Edited by PupCam
Added video details
  • Craftsmanship/clever 1
Link to post
Share on other sites

  • 2 weeks later...

Hi Alan,

 

Have you joined us on Discord where we have live support? We could have saved you a bit of time and also explained some features that are not really documented yet or are just alluded to, like the new way to handle functions. I did not see any name that started with "Pup" and we have only one Alan ;) Keep up the good work!

 

Fred

 

DCC-EX

  • Like 1
Link to post
Share on other sites

  • RMweb Gold

Hi Fred,  No I did take a quick look at Discord but it's all new to me so I ran away!   Perhaps I'll have another go!

 

Work is progressing, the main problem I have at the moment is trying to solve the famous error that seems to happen randomly  ......  Turning on debug level 4 in the Esp WiFi utility code reveals "Dirty characters in the serial buffer! > 2" but not certain why or how to fix it yet!

 

[WiFiEsp] >>> TIMEOUT >>>
[WiFiEsp] Data packet send error (1)
[WiFiEsp] FAILED to write to socket 3
[WiFiEsp] Disconnecting  3

 

I should add that the error is occuring in "my" client NOT the DCC++ EX so don't go worrying !   

 

Anyway, I've been working on some other aspects of the "User Interface"  and I'll leave this here for your amusement or maybe puzzlement (if that's a word) to work out what the heck! :lol:

 

If only there was a way to get live operational data (not CV stuff) back from a DCC decoder .....

 

 

Alan

Edited by PupCam
Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...