Forums Power and Sound Power and Sound DCC
  • Topic: Arduino DCC++ programing help needed

    Back To Topics
    (0 rates)
    • February 23, 2018 5:48 PM EST
      • Cypress, Texas
         
      • Posts
        321
      • Thanks
        0
      • Thanked
        11

      Arduino DCC++ programing help needed

      My last post on DCC++ kinda when in multiple directions so I hope this one will stay on track.  I built Dave Bodnar's DCC++ wireless Throttle and control board to go in the tender and  both work great.  I even layed out my own circuit board to make things cleaner and eliminate a rats nest of wiring.  As soon as the new boards arrive in a few days, I will assemble one and post photos of the throttle and boards i had made.  Now  with that being said,  I know nothing about Arduino C++ programming and just loaded Dave's script and it worked like a charm.  The only thing I dont like about the system is that I have to push a button on the tender to Link the receiver to the Throttle. This makes it  hard to do when it is in the round house or more than a arms length away. So what this message is about, is,  I want to change the script to have the DCC address for each locomotive hard coded into the script for that locomotive.  That way I can turn them all on and then select which one I want to run from the Throttle.  So  what I need is  someone that knows Both DCC and Arduino coding that can tell me how to change Dave's coding from scanning for the DCC address to having it hard coded and wont have to scan for the address.

      I hope this is straight forward and will be easy to do.  You can find Dave's code on his Trainelectronics.com website.  I am using the code that is for the VNH2SP30 motor driver with the DF Mini Player sound module.  the code and schematics are here:  http://www.trainelectronics.com/DCC_Arduino/DCC++/Receiver/index.htm

      Any help will be greatly Appreciated.  Oh  I have talked to Dave about this,  but he is on other projects now and does not have the time to look into it, so that why I am asking here.

      Dan

    • February 23, 2018 6:08 PM EST
      • Kittery, ME
         
      • Posts
        670
      • Thanks
        46
      • Thanked
        274

      It looks like you can comment out these lines:

        if (linkButtonState == 0) {
          linkAddress(); // if button pressed on boot link to first DCC address seen
        }
        getAddress();

      And then change these lines (immediately after those above) to match your locomotive address:

        activeDCCAddress = 1794;
        DCCAddress = 1794;

      It appears that 1794 is a hard-coded default address that Dave used while debugging. 

       

      There is also a routine there to save the address to EEPROM and load it again at startup, but these lines seem to overwrite the loaded address for some reason.

    • February 23, 2018 6:17 PM EST
      • Cypress, Texas
         
      • Posts
        321
      • Thanks
        0
      • Thanked
        11

      Thanks Eric,  That will get me part way there then.  Do I need the routine to save the address to EEPROM if the code is hard coded in the script?

       

      Dan

    • February 23, 2018 7:03 PM EST
      • Kittery, ME
         
      • Posts
        670
      • Thanks
        46
      • Thanked
        274

      I don't see any reason that you would.  I didn't dig into it TOO deeply, but let me know if that doesn't work, and I'll take a closer look.

Forums Power and Sound Power and Sound DCC

    Icon Legend

  • Topic has replies
    Hot topic
    Topic unread
    Topic doesn't have any replies
    Closed topic
    BBCode  is enabled
    HTML  is enabled

Add Reputation

Do you want to add reputation for this user by this post?

or cancel

Ads by Google