Introducing DCC++ ---a complete open-source DCC station and interface

Gregg Aug 25, 2015

  1. Scott Eric Catalano

    Scott Eric Catalano TrainBoard Member

    205
    57
    6
    Also Gregg....you should add the changes to select either an Arduino motor shield or a Pololu motor shield....this way no matter which shield is used the base station will know which one is selected....more like Else If type of thing
     
  2. TwinDad

    TwinDad TrainBoard Member

    1,844
    551
    34
    I'm going to have to do something similar with the Ethernet support... there are two or three different boards that need different libraries compiled in.
     
  3. w8one

    w8one TrainBoard Member

    89
    109
    5
    A long time ago in a house far away a had a layout for HO scale, 10 years and two houses later I have the space to try again. I bought at the time a prodigy AD150 but as far as i can tell its not controllable from a PC. I Am interested in this as well all the possibilities with arduino control but i'm concerned with the 2 - 4 amp limit. I found these on the web, I know its not a shield, but I would like your thoughts. For the H-bridge this looks like it will work to me. http://www.ebay.com/itm/111140003697 And a couple of these for the current sensing. http://www.ebay.com/itm/400770304649 .
     
  4. Scott Eric Catalano

    Scott Eric Catalano TrainBoard Member

    205
    57
    6
    I've been running and testing HO Scale locomotives with a basic Arduino Uno....powered by a computer via usb or power supply. The Pololu motor shield (capable of taking 18-26 volts) is powered by a 18 volt power supply from a digitrax super chief DCC system. So far no issues with the amps. I will know more as I am going to be setting up a complete system at my local mall where the club I belong to sets up a display in an empty store front starting Black Friday thru new years. I will be posting feed back every step of the way.
     
  5. dccrail

    dccrail New Member

    3
    0
    1
    Great project, Gregg! DCC led me into a business opportunity about 8 years ago and I've been out of this hobby since then while focusing on building that business. I have been unpacking my train boxes the last couple of weeks and am anxious to get back into it. As a maker, the Arduino platform is right up my alley. My motor shield will be here Monday.

    So I am curious - any idea why there are no open source locomotive decoders, yet?
     
  6. TwinDad

    TwinDad TrainBoard Member

    1,844
    551
    34
    I'll give two reasons...

    1) Simply, nobody has thought to do it... yet...

    2) A decoder must be pretty small, requiring compact circuit board design and surface mount components. That reduces (but does not eliminate) the population of people with the skills and equipment to pull it off. Plus, see (1) above.
     
    papahnash likes this.
  7. Scott Eric Catalano

    Scott Eric Catalano TrainBoard Member

    205
    57
    6
    Well Geoff talks about 17 function stationary decorders for under 5 dollars: http://model-railroad-hobbyist.com/node/19446 so the technology is there for the DIY to do
     
  8. TwinDad

    TwinDad TrainBoard Member

    1,844
    551
    34
    Oh, of course the technology is there. It wouldn't be all that hard, either. It's just that someone has to actually do it. My point is really that it only hasn't been done simply because no one has yet done so. If I can get a few other things cleared off my work bench, I may take a stab at it myself.

    A stationary decoder would be quite simple. A loco decoder only requires miniaturization.
     
  9. dccrail

    dccrail New Member

    3
    0
    1
    I have a PCB assembly line that only gets used about 20% of the time. I would be interested in making some application specific open source PCBs for base stations and decoders.
     
  10. Gregg

    Gregg TrainBoard Member

    237
    311
    18
    Friends (and welcome new members to the thread!),

    I've just released version 1.1.0 of the BaseStation code to GitHub with lots of new features based on feedback over the past few weeks.
    1. The code now works with an Arduino Uno as well as an Arduino Mega. The board type is automatically detected at compile time (and you will get an error message that stops the compilation if you try to compile from the Arduino IDE without selecting either an Uno or Mega in the IDE itself).
    2. Since the code is multi-platform, I renamed the repository to just BaseStation instead of BaseStation_Uno
    3. Per request, there is now a #define constant named MOTOR_SHIELD_TYPE. Set it to zero for an Arduino Motor Shield or to one for the Pololu MC33926 Motor Shield.
    4. Turnouts and Sensors are no longer defined by creating arrays in the code. Instead, they are now created/edited/deleted during run-time with extensions to the existing <T> command and a new <S> command. See Accessories.cpp and Sensor.cpp for documentation on all the details.
    5. To retain Turnout and Sensor definitions when the power is removed, store them in EEPROM with a new <E> command. Clear them all in one shot with the new <e> command.
    6. The <s> status command now includes info on the type of board (Uno versus Mega) and the Motor Shield being used.
    7. Per request, Sensor checking has been augmented so that instead of just sending the message <Q ID> when a Sensor state turns on (i.e. its pin goes from HIGH to LOW), it now also sends the message <q ID> when the Sensor state turns back off (i.e. its pin goes from LOW back to HIGH).
    8. The new versions of the <T> and <S> commands echo back <O> or <X> to signify success or failure (such as running out of memory by adding too many turnouts).

    As always, please let me know if you find any issues, have any suggestions, etc.

    -Gregg
     
  11. Gregg

    Gregg TrainBoard Member

    237
    311
    18
    Hi w8one,

    Without seeing the specs or schematics it's hard to tell if the the board at http://www.ebay.com/itm/111140003697 will work right out of the box or not. The reason is that most H-Bridge chips utilize two digital input lines to control each single output channel. If the lines are in opposite states (e.g. one High and one Low), voltage is applied across the output pins in either the positive or negative direction. This is how DCC++ produces bi-polar DCC signals. And if the two digital input lines are in the same state (e.g. both High or both Low), no voltage is applied to the output channel, and the impedance is either set High or Low. This is useful for "braking" a spinning motor or simply allowing it to coast. But it's totally useless for DCC since we are trying to generate digital signals, not directly control the motors in the trains.

    Unfortunately, even though we need to use only two of the four possible states above, we still need to control two digital pins. And the way DCC++ works, we can only generate a single logic signal on one pin per channel. This means we need a small circuit to transform our single logic signal into two separate but opposite logic signals. The Arduino Motor Shield and the Pololu MC33926 Motor Shield contain these exact circuits on their boards, which makes them ideal for use with DCC++. Pololu also makes a Motor Shield capable of 16 amps/channel but it does not include this additional circuit, meaning it can't be used directly for DCC++. I'm guessing the higher-current shield you found on E-Bay may also lack this additional circuit.

    However, that does not mean you can't use it -- rather, you'll just need to create the additional circuit to drive two opposing digital signals based on the output of one of the Arduino pins. Creating a generic circuit to use with the Arduino in the form of a shield would probably make a good project.
     
  12. w8one

    w8one TrainBoard Member

    89
    109
    5
    In the add on ebay it shows in the comments: Forward dir=1 pwm=pwm, Reverse dir=0 pwm=pwm, stop brake dir=x pwm=1. I assume dir=x to mean it does not matter, and pwm=1 to mean either 100% pwm or 1% pwm I'm not sure which. it only has 6 pins to interface ground pwm2 dir2 pwm1 dir1 +5v. From my research the 1 pin to control 2 outputs is just a logic inveter or not gate so 1 is opposite the other. I have a clone of the arduino motor shield coming (sometime between now and February) from ebay (along with others) when it all get here I will test them to find out and let everyone know. I also read in the l298 data sheet it could be set to one output at 4 amps.

    I just finished locating my train stuff, and am working on cleaning and repairing while waiting for parts. Now all I have to do is build My layout.
     
  13. esfeld

    esfeld TrainBoard Member

    443
    382
    17
    Gregg
    Had the system working with an UNO board:
    Pulled the UNO board off .... changed jumpers on motor shield (only jumper is pin 13 -4 as per instructions) pinned Motor Shield to Mega 2560 ...new Base Station Master compiles and uploads. Run DCCpp_Controller ...(in Processing 2) it opens, but hangs at "waiting for Base Station on serial port: comm 4" ...... I checked Device Manager.. the Mega board is on Comm 4 .... when I compiled I made certain that I was on the Mega board and on comm 4 ....... Any ideas?
    Steve
     
  14. Gregg

    Gregg TrainBoard Member

    237
    311
    18
    Can you check that the new code works still with the Uno to make sure I didn't inadvertently mess something up? If it works with the Uno but not the Mega, try with the Mega but without the motor shield (the Controller program doesn't actually know if the motor shield is attached and should respond the same either way). Also, can you communicate with the Mega just using the Arduino IDE Serial Monitor?

    Note that PCs are terrible at changing serial ports and it may be that the connection on the comm port is blocked, in which case the only solution I ever found to work was rebooting.

    -Gregg
     
  15. esfeld

    esfeld TrainBoard Member

    443
    382
    17
    Gregg
    Already rebooted after each try ...... Device Manager changes from UNO to MEGA an Comm 4 as necessary so I do not think it is the USB port ........ Controller works with UNO and no motor shield but does not find the serial port with the MEGA ........ My bad ... never thought that a new board would be bad ...... can not communicate with the serial monitor with the MEGA so I would think that it is a bad board. ...... thank you. ...... will get back to you after a new MEGA board
    Steve
     
  16. Gregg

    Gregg TrainBoard Member

    237
    311
    18
    The behavior of the Mega sounds a bit strange --- for each Arduino I plug into my USB, I get a different Comm Port so that you can use multiple Arduino's at the same time (not really needed for DCC++ plus useful for other reasons). I'm surprised the UNO and MEGA are both using Comm 4. So perhaps the Mega board is indeed bad. Let us know what happens with the new one - good luck!
     
  17. RT_Coker

    RT_Coker TrainBoard Supporter

    516
    33
    13
    All,
    If someone is interested in doing a Bluetooth HO Locomotive board like the attached picture, I would be very interested in taking with you. The Bluetooth sub board costs < $10. I have the PIC firmware almost completed and am testing on a locomotive with kluged up hardware.
    I can be contacted through the “Conversations” features of this forum or on this tread: http://www.trainboard.com/highball/...train-control-thread.79261/page-3#post-945361
    Bob
     
  18. TwinDad

    TwinDad TrainBoard Member

    1,844
    551
    34
    Still having trouble with my Ethernet board. Probably going to have to replace it. Budget says that will be a couple of weeks.

    I like the 1.1 interface changes. Timing/schedule says that corresponding updates to JMRI will probably not make it into the 4.1.4 release (which is already overdue), but I should have no problem getting them into 4.1.5 or 4.2.0 whichever is next.
     
  19. esfeld

    esfeld TrainBoard Member

    443
    382
    17
    Gregg
    It was not the MEGA board..... I had still been using Processing 2 ......when I went to another box with Processing 3 I was able to get the Comm ports sorted out and get everything to work ... ported it all back to the laptop and everything is working as it should.. PLEASE see what you can do about an input box for cab numbers ...... it is tedious to change the code and causes me headaches :)
    Thank you
    Steve
     
  20. Gregg

    Gregg TrainBoard Member

    237
    311
    18
    Steve, glad to hear you were able to sort out the comm port issues -- Processing 3 seems to have a more stable serial interface. Also, now that BaseStation 1.1 is released and the MEGA video is on YouTube I'll turn back to the Controller. I have some ideas for dynamically changing the Cab number directly in the cab box itself.

    -Gregg
     

Share This Page