Connecting a Serial Throttle directly to DCC++Ex

NormHal Dec 31, 2021

  1. NormHal

    NormHal TrainBoard Member

    138
    126
    12
    Hi guys,
    To save me from browsing through many posts, has anyone managed to connect a serial port based throttle (such as Dave Bodnar's original Nextion based version) directly to a Serial port of a DCC++Ex Command Station? I'd imagine a Mega would probably be the better host option. If so, how was it done, and were any modifications made to the DCC++Ex code?

    Thanks in advance,
    Norm
     
  2. esfeld

    esfeld TrainBoard Member

    442
    382
    17
    Norm; According to DCC EX documentation:
    The DCC++ API
    The first way to connect to DCC++ EX is to use our DCC++ API. This is the set of commands that tell the Command Station how to control your trains. DCC++EX understands simple command surrounded by brackets like this: “<1 MAIN>”. That command turns your main track power on.

    Since this is just sending characters back and forth across a serial connection, anything that can connect to an Arduino through a USB cable or one of the other serial ports using WiFi of Bluetooth can send DCC++ commands to the CS. This method is fast, direct, and can take advantage of special features that exist only in DCC++ EX. You can even connect using the Arduino Serial Monitor or connect to our WiFi with a terminal program like PuTTY and type DCC++ commands manually. Our WebThrottle-EX, JMRI and CABs like DCCpp CAB and DigiTrainsPro send commands in DCC++ format.

    I have not tried serial yet as at present my working throttles use Websocket communication .. I am experimenting with code to see if I can add Websocket to DCC EX .. I have been in touch with the developers, but they seem uninterested in this at the moment.
     
    NormHal likes this.
  3. NormHal

    NormHal TrainBoard Member

    138
    126
    12
    Thanks Steve, I'll do some further research. What I'm hoping to find is a configuration option which allows one to assign a serial port as a "pipe" for the direct connection. I want to avoid WiFi, BlueTooth, or even Ethernet for the connection if at all possible. I simply want to set up a simple, standalone Command Centre with an attached Throttle:)

    Thanks again
    Norm
     
  4. NormHal

    NormHal TrainBoard Member

    138
    126
    12
    QUOTE="esfeld, post: 1205812, member: 30987"]Norm; According to DCC EX documentation:
    The DCC++ API
    The first way to connect to DCC++ EX is to use our DCC++ API. This is the set of commands that tell the Command Station how to control your trains. DCC++EX understands simple command surrounded by brackets like this: “<1 MAIN>”. That command turns your main track power on.

    Since this is just sending characters back and forth across a serial connection, anything that can connect to an Arduino through a USB cable or one of the other serial ports using WiFi of Bluetooth can send DCC++ commands to the CS. This method is fast, direct, and can take advantage of special features that exist only in DCC++ EX. You can even connect using the Arduino Serial Monitor or connect to our WiFi with a terminal program like PuTTY and type DCC++ commands manually. Our WebThrottle-EX, JMRI and CABs like DCCpp CAB and DigiTrainsPro send commands in DCC++ format.

    I have not tried serial yet as at present my working throttles use Websocket communication .. I am experimenting with code to see if I can add Websocket to DCC EX .. I have been in touch with the developers, but they seem uninterested in this at the moment.[/QUOTE]
    I think I should have been more specific when I posted my initial question:-( .
    Connecting one of the old Nextion throttles to a DCC++EX CS by using a direct pair of wires from the Nextion Throttle (with Arduino UNO) TX and RX pins to the DCC++EX CS RX and TX pins works nicely, as indicated in the documentation. This however precludes the use of the debug console on the DCC++EX. Without digging into the depths of the DCC++EX code, and finding or defining a specific port for a throttle, so as to leave the debug port available for debugging:), I'd prefer to use one of the other 3 serial ports available on a Mega..., hence my question:)

    I must add that the connection using the regular debug port 0 works beautifully, and all credit must be given to the DCC++EX team!

    Norm
     
  5. Sumner

    Sumner TrainBoard Member

    2,798
    5,837
    63
    I've never seen his Nextion based throttle, do you have a link?

    I have the parts to build his wireless throttle. It and the wired one worked with DCC++ so would imagine they would also work with DCC++EX. I was interested in them since I like an old fashion knob for throttle control. I was to the point where I was thinking of trying to build one (wireless) with a ESP32 instead of the radio he used to connect to DCC++EX through the Wi-Fi option. I got to the point of looking to see if that was possible and then along came Jimmy's input on using an inexpensive volume pot connected to an Android phone running EngineDriver to control speed and direction.

    [​IMG]
    http://1fatgmc.com/RailRoad/DCC/page-3.html

    That gave me a physical throttle and EngineDriver which has a ton of features. One being I can see my JMRI DCC roster on the phone and select a loco to run either by address or finding it on the roster. EngineDriver has way more options and features than what Dave's throttle had so I'm really happy with it.

    I keep seeing Nextion mentioned. What is the advantage to it say vs. a phone or tablet as a throttle?

    Thanks,

    Sumner
     
  6. BigJake

    BigJake TrainBoard Member

    3,259
    6,172
    70
    Beware, potentiometers come in audio (exponential) and linear (linear) tapers. You want linear taper, where a given angle increment is the same change in resistance anywhere in the rotation range. Audio taper is designed to create a linear response for the non-linear effect of acoustic volume. Of course, software can be written to linearize an audio pot's signal, or vice-versa.
     
    Mark Ricci likes this.
  7. NormHal

    NormHal TrainBoard Member

    138
    126
    12
    Hi Sumner,

    Have a look here := http://trainelectronics.com/DCC_Arduino/Nextion_LCD/index.htm

    This link shows the Nextion implementation I started with and built on. I don't have a web site and everything is sharable:)

    Yes I agree, there are a number of throttle option around. My requirement was to have "instant" access to up to 3 locos very quickly, as well as turnouts and routes, so I decided to modify Dave Bodnar's initial work. I'm currently working on version 5.00 of the Nextion based solution, and am happy to share if you wish, however it's very much in "Alpha" development at this time. I prefer the Rotary Encoder method of Loco control simply because it allows one to flip between locos and retain the speed they were set to, and also see their individual speeds when flipping back.

     
    Last edited: Jan 1, 2022
    BigJake and Sumner like this.
  8. NormHal

    NormHal TrainBoard Member

    138
    126
    12
    Deleted...
     
  9. UkBloke

    UkBloke TrainBoard Member

    42
    5
    3
    The latest DCC-EX 4.0 release has the ability to accept serial throttle input on all 4 Serial ports on an Arduino Mega by adding a single line for each serial to the configuration file. (e.g. #define SERIAL1_COMMANDS )

    We are not reluctant to implement websockets, we would really like to have this facility ourselves. Its simply that the websocket setup conversation is much more complex than people imagine and there is simply no room or processing power that we want to spare to handle this overhead. That may change in future as we move to more powerful processors with ram and cpu cycles to spare.
     
    Sumner and NormHal like this.
  10. Sumner

    Sumner TrainBoard Member

    2,798
    5,837
    63
    I'd assume that this means that JMRI on the Pi could be on one serial port and something like Dave's wired or wireless throttle could be using a different one so potentially no problem using both at the same time? Would that be correct? Thanks,

    Sumner
     
    NormHal likes this.

Share This Page