DCC++ Hardware - Motor Shields

KE4NYV Jan 25, 2016

  1. Gregg

    Gregg TrainBoard Member

    237
    311
    18
    Andrew,

    On the Mega you don't want to connect pin 12 to pin 2 -- they are both outputs.

    Can you confirm what happens if you remove the shield and run the <D> command with a single jumper between pin 12 and pin 13? The LED near pin 13 should be blinking. If not, can you double-check the mappings in Config.h and DCCpp_Uno.h to make sure the MAIN DCC Signal pin is set to 12?

    If instead the LED near pin 13 is blinking, that means pin 12 is properly generating a DCC signal. If you then remove all jumpers and replace the shield, provided the shield is powered (e.g. through the VIN terminals), the LEDs next to output channel A should both start unlit, then turn on when you issue a <1> command, and then start blinking if you also issue a <D> command. If not, there is a problem with the Motor Shield pin 12. Is your motor shield an exact clone of the Arduino Motor Shield, or rather an "Arduino-compatible" motor shield (which means it may have different pin mappings). Can you provide a link to the specific board you have?
     
  2. conrailandrew

    conrailandrew TrainBoard Member

    18
    29
    11
    I don't see anything happening on the pin 13 LED (it's off) when the shield is removed and pins 12 and 13 are connected and I go into <D> mode. I tried the <1> command before entering <D> mode as well, just to be sure.

    I don't see anywhere in the Config.h that pin 12 or MAIN DCC Signal Pin is mentioned?
    The DCCpp_Uno.h looks ok, although are the shield mappings correct?
    Code:
    /////////////////////////////////////////////////////////////////////////////////////
    // AUTO-SELECT ARDUINO BOARD
    /////////////////////////////////////////////////////////////////////////////////////
    
    #ifdef ARDUINO_AVR_MEGA                   // is using Mega 1280, define as Mega 2560 (pinouts and functionality are identical)
      #define ARDUINO_AVR_MEGA2560
    #endif
    
    #if defined  ARDUINO_AVR_UNO
    
      #define ARDUINO_TYPE    "UNO"
    
      #define DCC_SIGNAL_PIN_MAIN 10          // Ardunio Uno  - uses OC1B
      #define DCC_SIGNAL_PIN_PROG 5           // Arduino Uno  - uses OC0B
    
      #if COMM_INTERFACE != 0                 // Serial was not selected
    
        #error CANNOT COMPILE - DCC++ FOR THE UNO CAN ONLY USE SERIAL COMMUNICATION - PLEASE SELECT THIS IN THE CONFIG FILE
    
      #endif
    
    #elif defined  ARDUINO_AVR_MEGA2560
    
      #define ARDUINO_TYPE    "MEGA"
    
      #define DCC_SIGNAL_PIN_MAIN 12          // Arduino Mega - uses OC1B
      #define DCC_SIGNAL_PIN_PROG 2           // Arduino Mega - uses OC3B
    
    #else
    
      #error CANNOT COMPILE - DCC++ ONLY WORKS WITH AN ARDUINO UNO OR AN ARDUINO MEGA 1280/2560
    
    #endif
    
    /////////////////////////////////////////////////////////////////////////////////////
    // SELECT MOTOR SHIELD
    /////////////////////////////////////////////////////////////////////////////////////
    
    #if MOTOR_SHIELD_TYPE == 0
    
      #define MOTOR_SHIELD_NAME "ARDUINO MOTOR SHIELD"
    
      #define SIGNAL_ENABLE_PIN_MAIN 3
      #define SIGNAL_ENABLE_PIN_PROG 11
    
      #define CURRENT_MONITOR_PIN_MAIN A0
      #define CURRENT_MONITOR_PIN_PROG A1
    
      #define DIRECTION_MOTOR_CHANNEL_PIN_A 12
      #define DIRECTION_MOTOR_CHANNEL_PIN_B 13
    
    I tested this shield with my Uno and it runs perfectly.
    I'm not 100% sure it's an exact clone, although the fact that it works with the Uno makes me think it is.
    http://www.ebay.com/itm/310787745501?_trksid=p2057872.m2749.l2649&ssPageName=STRK:MEBIDX:IT

    That's the one I have. The only difference is it says (Deek Robot) between the "MOTORSHIELD" and the "RESET".
    I can't seem to find any technical information on it or it's pinout information, unfortunately. That's what I get for going cheap, I guess. :p

    Thanks for the help!
    Andrew
     
    Scott Eric Catalano likes this.
  3. Gregg

    Gregg TrainBoard Member

    237
    311
    18
    Hmm. If it works with the Uno it should work with the Mega. The software should automatically detect which board you are using when it compiles and uploads (and the Arduino IDE will not allow you to compile for Uno and upload to a Mega, so that can't be the issue). I assume you changed the jumper wires (for Uno, jumper 5<->13 and 10<->12; for Mega, only one jumper 2<->13). Also can you confirm you are using the latest official release (1.2.1: https://github.com/DccPlusPlus/BaseStation/releases)?

    -Gregg
     
  4. w8one

    w8one TrainBoard Member

    89
    109
    5
    A easy way to check pin 12 would be to run the blink example from the Arduino ide change the pin to 12 and jump 12 to 13 if that works the pin is good, if not the pin is bad. It is possible that a pin on the avr don't work and the rest do.
     
  5. conrailandrew

    conrailandrew TrainBoard Member

    18
    29
    11
    Aha! Good idea, it failed that test, I think the Mega does indeed have a bad pin 12. I've used this board for a couple other projects in the past, and must have burned it out at some point. I assume I can set the code to use another pin (maybe 7?) and jumper it in to 12?

    Also, I didn't have the latest release, thanks for that pointer, Gregg!

    Thanks for the help!
    Andrew
     
    Scott Eric Catalano likes this.
  6. Gregg

    Gregg TrainBoard Member

    237
    311
    18
    Note that the original test should have revealed this - you can use the blink program or the <D> command. Either generates a blinking on pin 12.

    As written the code uses built-in circuitry tied to pins 12 and 2. You unfortunately can't change this with just the parameters in the DCCpp_Uno.h file. I intend on testing a method proposed a while ago that would allow for more flexibility, but haven't had a chance to do that yet (will be soon though since the server code I'm working on can't use the built-in circuitry). Another option would be to switch the code to use a different timer-counter on the Mega (there are 5 total). This would allow generation of the main signal on, say, pin 45 (if I am recalling where timer 5 is correctly).

    -Gregg
     
  7. David Bodnar

    David Bodnar TrainBoard Member

    264
    481
    13
    Over the last few weeks I have been experimenting with a number of different motor shields and H-Bridges. While some clearly are not suited to use with DCC++, the one that I tested today may be a real winner for those of us who need more than an amp or two of power.

    The H-Bridge was purchased on eBay for about $12.00. More significantly it is advertised to deliver up to 43 amps of power! Quite a claim.

    I did some tests today and had it working at 18 volts and delivering nearly 5 amps. The H-Bridge remained cool throughout the tests.

    I wired the unit directly to the pins on a standard motor shield. The H-Bridge powered the main line and the programming track was still connected to the motor shield.

    I made a video and put some notes on my web page here: http://trainelectronics.com/DCC_Arduino/DCC++/

    dave

     
    Last edited: Feb 6, 2016
    Erik84750, sboyer2, lnxlnx and 5 others like this.
  8. HVT

    HVT TrainBoard Member

    74
    93
    15
    Dave B,

    That is exciting news!!! Thank you for sharing your progress. One question I have is about short circuit protection. Will it pass the quarter test without melting stuff? And will it work with an auto-reverser, or can one be configured to work as an auto-reverser?

    Dave M
     
    Scott Eric Catalano likes this.
  9. David Bodnar

    David Bodnar TrainBoard Member

    264
    481
    13
    Dave - my testing to date has been mainly with power output. I got it to shut down via the DCC++ controller by adjusting the CURRENT_SAMPLE_MAX variable but need to do more testing.

    Not yet sure about auto-reverser use - I have never used or had a need for one so I need to do some reading!

    thanks

    dave
     
    GregW, HVT and Scott Eric Catalano like this.
  10. hoyden

    hoyden TrainBoard Supporter

    815
    778
    30
    Indeed...very interesting. Much simpler than paralleling outputs from a second shield. What kind of current sensor does it use? I bought a couple of 5A Hall sensors that I am considering using. 5A is about the current I could use.
     
    Scott Eric Catalano likes this.
  11. David Bodnar

    David Bodnar TrainBoard Member

    264
    481
    13
    Dave - I did some testing this AM - my notes are on my web page here:

    http://trainelectronics.com/DCC_Arduino/DCC++/#Power_Tests

    The bottom line is that the large H-Bridge will shut down from a dead short IF the value of CURRENT_SAMPLE_MAX is set properly.

    I hope that answers the first part of your question!

    Do you have any suggestions for a test that would answer the auto-reverser question?

    dave
     
    lnxlnx, HVT and Scott Eric Catalano like this.
  12. David Bodnar

    David Bodnar TrainBoard Member

    264
    481
    13
    The H-Bridge chip has a built in current output pin that outputs directly to the DCC++ controller.

    If you try this H-Bridge make sure you connect the current sense output directly to pin A0 on the Arduino, not through any motor shield you may have installed. I did my tests without a motor shield and connected the H-Bridge directly to the Arduino.

    I have a few of the Hall sensors, too, and plan on experimenting with them and these boosters.

    dave
     
    Last edited: Feb 7, 2016
    lnxlnx, HVT and Scott Eric Catalano like this.
  13. HVT

    HVT TrainBoard Member

    74
    93
    15
    Dave B,
    Yes, that answers the first question and provides some numerical guidelines for implementation. I would like to divide my layout into three power districts plus two auto-reverse sections at the top of the 2-track helix. There are 9 modules/sections that will probably each utilize a Mega for local servo/signal/detection and an H-bridge can be added to one in each district, with over current protection provided locally. The changes Gregg is working/testing on for the client Arduino will make this possible. Your current load testing provides a usable level of power with plenty of safety margin.

    The user controllable short circuit protection should make auto-reversing doable, unlike with the Pololu shield that cuts out faster than the software can react. Writing code for the AR to work is above my current skill set but I suspect that an Arduino motor shield Should handle one train in the AR section. But the out-of-phase condition when a loco enters must be sensed and corrected. I guess I could do a Rube Goldberg solution that uses pairs of absolute detection sensors on both sides of each double gap and with JMRI Logix the phase could be switched, but that is not ideal. Or use a Tam Valley Hex Frog Juicer which has a 1.7 amp switching threshold. The Hex manual describes how Duncan does it.

    I too look forward to your test results with the Hall Effect sensors. I am curious if the analog pins are sensitive enough to detect a 10K resistor wheel set and report that back to JMRI.

    Thanks for sharing your talents with us.

    Dave M
     
    Last edited: Feb 7, 2016
    Scott Eric Catalano likes this.
  14. David Bodnar

    David Bodnar TrainBoard Member

    264
    481
    13
    Dave - with the current sense line connected to the DCC++ controller (pin A0) any short shuts the H-Bridge down immediately. If I remove the current sense line I can short the output of the H-Bridge (power supply at 14 volts @ 5 amps) without shutting down - the H-Bridge does have an over-current shutdown but it is way above 5 amps! (the data sheet puts the minimum at 33 amps) Info on the chip and its data sheet is here:
    http://www.infineon.com/cms/en/prod...?productType=db3a304413719f72011372e9554e00da

    Hope that helps

    dave
     
    Scott Eric Catalano likes this.
  15. HVT

    HVT TrainBoard Member

    74
    93
    15
    Dave B,
    Great!. The DCC++ code in the client Arduino that shuts down the H-bridge can then be rewritten to switch the phase of the DCC signal when a given threshold is reached. The TVD Hex does this at 2.0 amps as explained in the Hex manual. http://tamvalleydepot.com/images/Hex_Frog_Juicer_Manual_v1_5_2p.pdf
    Dave M
     
    Scott Eric Catalano likes this.
  16. hoyden

    hoyden TrainBoard Supporter

    815
    778
    30
    "I am curious if the analog pins are sensitive enough to detect a 10K resistor wheel set and report that back to JMRI"

    Dave, the sensor outputs 2.5V with 0 current. The voltage varies upwards towards 5V for current in one direction and down towards 0V for current in the other direction. I used an 18W light bulb for a load and the voltage changed from 2.5 to 2.3V. For a device that can handle 5A trying to detect less than 0.002A would probably not be very reliable. That would be about 0.001V change. There will be more than that voltage variation just from the 0 current offset, which will vary greatly from part to part and with temperature.
     
    Scott Eric Catalano likes this.
  17. David Bodnar

    David Bodnar TrainBoard Member

    264
    481
    13
    And even more important is the fact that the Hall current sensor will NOT react to DCC as it will only work with DC. An AC signal, like the one that DCC uses, bounces back and forth from positive to negative giving no useful reading from the sensor. Too bad.

    You can measure the current used by a DCC system by inserting the Hall sensor in the DC supply line that goes to the motor shield. If you want to use it for block detection, which measures current on the DCC line, it is not going to work.

    I have a few other sensors to test - several that should work with detecting current draw in a block - stay tuned!

    dave
     
    Scott Eric Catalano likes this.
  18. RT_Coker

    RT_Coker TrainBoard Supporter

    516
    33
    13
    Dave,
    There is no law that says that the AR-sections cannot be fixed-DCC-phase, and the “connecting section(s)” auto-phase DCC. You just need to think through you setup to make sure that auto-phase “connecting section(s)” are not directly "track-connected" to more than one fixed-DCC-phase-section.
    Bob
     
    Scott Eric Catalano likes this.
  19. KE4NYV

    KE4NYV TrainBoard Member

    219
    281
    17
    For those using the cheaper eBay/Amazon/ect. L298P motor shields, are you experiencing them getting very hot while the track power is enabled and no locomotives are on the tracks? Basically sitting idle with track power on.
     
    Scott Eric Catalano likes this.
  20. David Bodnar

    David Bodnar TrainBoard Member

    264
    481
    13
    Jason - I have not noted any heat build up on the L298p boards (generic from eBay) ---- at idle the board draws about 30 ma @ 12 volts

    Under load they heat up quickly - I have started attaching a heat sink to the top of the chip using double sided heat sink tape. It makes a big difference.
    dave (N3ENM)
     
    Scott Eric Catalano likes this.

Share This Page