DCC++ and Thottle

IronMan1963 Jul 7, 2019

  1. IronMan1963

    IronMan1963 TrainBoard Member

    161
    173
    9
    So here is my idea. Since I go to a bunch of Train shows I am looking to build an easily portable DCC++ with a wired Dave Bodnar type throttle. The DCC++ I can do. However I would like the throttle to handle any loco address I type in. From what I have read and can understand of the coding (which is very little) you can only use the addresses that you preload into the throttle. (Is it possible to change Dave's code to whatever loco address that you want?) I would like the system to be stand alone without having to run JMRI. I think I have all the parts for the throttle including both a 4x4 and 4x3 keypad a couple UNOs and MEGAs also a couple NANOs , 1 PRO MICRO and 1 ESP32 . Screens available are 1 2x16, 1 2x16 with buttons and the screen used in Geoff Bunza's simple Wifi throttle.
    I just don't get the programming. Any and all hardware and coding help would be great.
    If it is not possible thanks for reading.

    Thanks Richard
     
  2. Jimbo20

    Jimbo20 TrainBoard Member

    274
    178
    11
    Hi,
    I'm not sure which throttle code of Dave Bosnar's you are basing yours on, but with the version I started from you can program up to 4 different Loco addresses into the ROM using the keypad. And you can change them at any time. It worked very well. I actually used a pot for the speed control on mine rather than a rotary encoder, but doing that you need to be careful if you have several locos on the track at the same time and you switch the throttle between them, the speed can suddenly change to the pot's current setting. You don't have this issue if you use a rotary encoder.

    http://trainelectronics.com/DCC_Arduino/DCC++/Throttle/

    Jim
     
    Last edited: Jul 7, 2019
  3. IronMan1963

    IronMan1963 TrainBoard Member

    161
    173
    9
    That is the one I was looking at. But the code looks to me like you need to put the addresses into the rom at the time you program the Arduino. I am looking for a setup more flexible. If I pickup a used loco at a show and want to test it I can't rewrite the rom on the fly like that or can I?
     
  4. RCMan

    RCMan TrainBoard Member

    271
    132
    12
    It stores four Id's that you enter.

    • Control speed with a potentiometer - the center position is STOP, turning clockwise increases speed in a forward direction and turning counter clockwise increases speed in a backward direction
    • Accommodate and remember four locomotive DCC addresses (0--9999)
    • Allow entry of loco addresses with a 3x4 keypad
    • Use a push button switch to enter the loco change address function
    • Use a push button switch to move between loco addresses
    • Remember stored loco addresses
    • Use the keypad to activate DCC functions (bell, whistle, etc)
    • Have loco speed, direction, DCC address, function key status displayed on a 2 line by 16 character LCD display.
     
  5. IronMan1963

    IronMan1963 TrainBoard Member

    161
    173
    9
    So if I have 4 locos in and I want to change 1 I just hit the change loco button and over write 1 I already have in. That I can live with. Just looking at the code it had 4 addresses already in the code. Can you up the code to allow more locos? I assume I could use a Nano in place of the Pro Mini Don't have a mini on hand.
     
  6. Jimbo20

    Jimbo20 TrainBoard Member

    274
    178
    11
    Although there appear to be 4 pre-assigned loco addresses

    Code:
    int LocoAddress[4] = {1830, 3, 999, 4444};
    If I recall correctly they get overwritten on switch-on (because the EEprom values are empty - I guess this piece of code was written before the EEprom feature was incorporated) and all four default to address 0003, but you can change these at any time using the buttons and keypad on the throttle. When you do, any changes are written into the eeprom. So they are remebered even after switching the throttle off and back on. Presumably you can increase the number of stored loco addresses by changing the maxLocos value and '[4]'s to another value in the following piece of code, and adding more 1s and 0s as appropriate. I don't know what the maximum number of locos you could take it to though:

    Code:
    // Array set for 4 Loco2 - change the 7 numbers in the next 7 declarations
    int maxLocos = 4;// number of loco addresses
    int LocoAddress[4] = {1830, 3, 999, 4444};
    int LocoDirection[4] = {1, 1, 1, 1};
    int LocoSpeed[4] = {0, 0, 0, 0};
    byte LocoFN0to4[4];
    byte LocoFN5to8[4];
    byte Locofn9to12[4];// 9-12 not yet implemented
     
  7. IronMan1963

    IronMan1963 TrainBoard Member

    161
    173
    9
    Ok. That was the piece of code that was messing with my head. So I guess I will give this a try and report back. I only have a pot at the moment so will need to get an encoder. Thanks guys.
     
  8. David Wakefield

    David Wakefield New Member

    6
    0
    2
    I have been looking at this throttle this afternoon. (UK time) I would like to build the wireless version as my domestic director hates wires!
    any idea where the arduino sketch can be downloaded?
     
  9. jamescoleman1960

    jamescoleman1960 TrainBoard Member

    42
    15
    6
  10. David Wakefield

    David Wakefield New Member

    6
    0
    2
    Brilliant! Many thanks. I should have thought of that, have now found everything I need.

    Cheers
    Dave
     
  11. Keith Ledbetter

    Keith Ledbetter TrainBoard Member

    279
    195
    12
    Making it wireless with the HC 12 modules also discussed on Bodners site is extremely easy.
     
  12. David Wakefield

    David Wakefield New Member

    6
    0
    2
    Thanks Keith.
    I was about to post that I had built the throttle, finished it yesterday. I have used the HC 12s. Testing starts this weekend.
     
  13. Chris484

    Chris484 New Member

    6
    2
    2
    I built a wired version of the Bodnar throttle also; works great! I am waiting for the HC-12 modules from Amazon and will implement them. I would be interested in how your testing went.
    Also, since I built my throttle with a 4x4 keypad and a 4x20 LCD (I already had these on hand), I have extra buttons and display room to play with. I would like to add some additional capability such as turnout control to the throttle, but I can't wrap my head around the method needed to send the DCC++ commands from the throttle to the base- station. Can someone point me in the right direction?
    Thanks.
     
  14. Sumner

    Sumner TrainBoard Member

    2,838
    5,982
    63
    Sorry I can't answer your question but I have one. I have the parts to build Dave's throttle but haven't started. In his documentation I believe he said there still might be some bugs to work out. Not sure if that is still true. Are you running the sketch that he posted without any changes?

    I'd like to make the throttle but don't have the knowledge to change the sketch around if there were problems.

    I did order the HC-12 modules and would want to build that throttle so would like your feedback once you implement the change as to if everything is still working fine.

    Thanks and would love to see pictures of what you came up with for the case and anything else you did differently in the build,

    Sumner
     
  15. Chris484

    Chris484 New Member

    6
    2
    2
     
  16. Chris484

    Chris484 New Member

    6
    2
    2
    My throttle has a rotary encoder so I used that version of Dave's software. From what I can see, the HC-12 modules are basically "drop- in" replacements for the wired connection, so no additional software changes should be needed other than to config the HC-12's. We will see...
    The software from Dave works fine as is. The only changes I made were for the 20x4 LCD (as opposed to the original 16x2) and the 4x4 keypad (Dave's original is a 4x3) Both of these changes were minor. I also changed the 4 locos max to 3, since that is all I have at the current time. I can control throttle, bell, horn and lights on the 2 sound equipped steam locos I have. The 3rd is a diesel with only a mobile decoder installed; it runs fine with the throttle and I can control the lights.
    As far as a case, for now I just made a top plate to mount everything out of 1/8" hardboard plus a blank back plate. The are sandwiched together with nylon standoffs between them. I haven't figured out how to make a "final" version yet, however I expect it will be a little more aesthetically pleasing to the eye. pic1 throttle.jpg
     
  17. Sumner

    Sumner TrainBoard Member

    2,838
    5,982
    63
    Thanks that helps a lot.

    I have the same keypad and LCD as what he used so plan on designing a case around those. Hopefully I can print it with the 3D printer I have. One reason I selected it is because I think the bed on it will be big enough to print the case. It will probably be a little narrower than what you will need since I have the narrower keypad and LCD. How long and wide do you need to get your components in? If I had the dimensions I might be able to design something for you if your interested.

    What are you going to do for batteries? I might look at using some drone batteries I have as they are easy to charge and cheap but I haven't looked at the project for some time now to see if they would work. They are 3.7 volts and I think I could run them in series and get them to work?

    Sumner
     
  18. Chris484

    Chris484 New Member

    6
    2
    2
    My case measures about 4-1/4" wide at the top (LCD end) and 3-3/4" wide across the bottom. It is 9" from top to bottom. The width at the top is fixed by the LCD, but depending on batteries I may be able to narrow the bottom and shorten the height. It is also 1"thick; hopefully that can be reduced also (currently the pro mini I'm using is on a socket in case it fails so I think there will be some room to reduce the thickness an 1/8" or so.
    Like Dave's original, I was planning on using 2 3.7V batteries in series with a 5V regulator circuit to power everything. I don't want to have to remove the batteries to charge them, so a connector to the outside is also needed.
     
  19. Sumner

    Sumner TrainBoard Member

    2,838
    5,982
    63
    According to the specs on my printer it can print 8.6 inches long. It could print 9.8" vertically but I wouldn't want to print it in that direction if I could help it as then there would be 'overhangs' that would have to be dealt with. There would be the option to breaking the top and back into 2 sections and that is what I might do as then it would be easier to get to a battery compartment. At least the back.

    Like you I'd like to charge the batteries without removing them. I'll probably deal with with two charge outlets and a switch to switch them out of being in series.

    I really should get back on this. I finally had all the wiring figured out and got the parts ordered for two throttles and now it sits in a box. Thanks for possibly getting me motivated again. I worried I'd get it all together and it wouldn't work well without some programming required. Let me know how the change to 'wireless' goes as that is what I want to build and have the parts for and let me know if you would like a case,

    Sumner
     
  20. Sumner

    Sumner TrainBoard Member

    2,838
    5,982
    63

Share This Page