Selfmade DCC++ Shield

tnt23 Mar 9, 2020

  1. tnt23

    tnt23 TrainBoard Member

    27
    15
    4
    Thought I'd post this as separate thread. Got my selfmade DCC++ shield up and running, with just a few bloopers.

    IMG_20200309_122420.png

    Turned out the Arduino footprint I have picked was upside down one, that is, oriented at Arduino being mounted on some board as an add-on. Doh!

    Luckily, I could abate this by using longer pins and mounting them and the power connector both upside down, too. Alas, so much for the lovely silk print.

    IMG_20200309_122134.png

    The Prog track worked out of the box, reading CV without any problems. For the Main track, however, I have discovered that the Inhibit inputs for bridge switches in fact was enable signal, active high. Oh well, will remove the unnecessary inverter in next revision.

    Current sensing on Main works, too, after I have turned the opamp stage into simple buffer. Haven't checked the overcurrent cutout yet.
     
    Erik84750 and Paul1361 like this.
  2. Paul1361

    Paul1361 TrainBoard Member

    41
    6
    2
    What is your operating and max current target? Also is current sensing done before or after the bridge? I have a theory that if current sense is after the bridge the rapid switching may be throwing off the current sense signal and that we may need to add some discrete circuitry to smooth it.
     
  3. tnt23

    tnt23 TrainBoard Member

    27
    15
    4
    I've got two old locos from PIKO, each running at 0.5A max I think (never was able to register more than that even at full speed), and a Roco diesel that can draw around 1A. Plus a dozen or so of Signal masts that'd be another 0.5A. So I was aiming at 2.5A at least.

    Max current I don't know, somewhere around 4-5A probably.

    Main bridge is a copy-n-paste of IBT-2 bridge, a pair of smart halfbridge BTN8982 chips with built-in current sense for High Side. The sensing they provide is rather sloppy, could be up to 20% off for small currents. JMRI reports 2% track current when idle (my PSU reports current of around 50mA drawn). I believe with higher currents the accuracy will be better, it does not need to be very precise for short circuit detection anyway.

    Another thing is I am using one of those affordable power supplies that offer voltage regulation and current limiting:
    dps3005.png
    So I might not be able to register any overcurrent event with DCC++ BaseStation because the PSU would react faster.
     
    Erik84750 likes this.
  4. Paul1361

    Paul1361 TrainBoard Member

    41
    6
    2
    I have noticed the current inacuracy also with my ibt-2, jmri shows 25-30% while only drawing 600-800 ma. I believe this may also cause main track programming issues. Maybe add a maxx current sense chip to the design.
     
  5. Paul1361

    Paul1361 TrainBoard Member

    41
    6
    2
    Scratch the MAX471/472, they are EOL. Going to look into other chips.
     
  6. tnt23

    tnt23 TrainBoard Member

    27
    15
    4
    MAX47x are said to have 2% accuracy, and require external current sensing resistor for currents over 3A. I personally would prefer using built-in current sensing in IBT-2 even if it is rather inaccurate. My perception is that on the Main track precision current metering is not something everyone would need.

    Current transformer similar to one used in block occupancy detection can probably be an option.
     
    Erik84750 likes this.
  7. tnt23

    tnt23 TrainBoard Member

    27
    15
    4
    I don't think the incorrect percentage reported for the IBT-2 by JMRI has something to do with problems with programming over the main. POM does not require acknowledgements if I am not mistaken, so current sensing really should not matter here.

    By the way, I was also getting 30-40% reported by JMRI for IBT-2 bridge previously. Need to check my DCC++ BaseStation code for any changes.
     
  8. Paul1361

    Paul1361 TrainBoard Member

    41
    6
    2
    It may not affect main programming, but there is a issue where the IBT-2 bridge chips current sense is desighned for a 40A+ range where we are only using them up to 10A max and lose resolution and get bad readings below 1A. Unfortunately it does not look like the gain resistor for the CS is external, but built in so we can not even change it to bring the CS range down.
     
  9. tnt23

    tnt23 TrainBoard Member

    27
    15
    4
    The two current sense resistors on IBT-2 are external 1K surface mount resistors, tricky to desolder but doable. It is not quite clear from the datasheet if arbitrary resistor value can be chosen to tailor the resulting voltage to application. What would be the case of using a 40A+ bridge and willing to observe currents under 1A? :)
     
  10. Paul1361

    Paul1361 TrainBoard Member

    41
    6
    2
    The IBT2 is cheap and widely available and has switching times well within the needs of DCC. Also running a device capable of 40A+ at 10A and lower greatly reduces heat and increases longevity of the device. I do not see any reason we can not get full range current readings with a 20ish ma accuracy thru the system.
     
  11. Paul1361

    Paul1361 TrainBoard Member

    41
    6
    2
    According to the datasheet the 1k resister yields 8.5A/V. Time for some maths.....
     
  12. Paul1361

    Paul1361 TrainBoard Member

    41
    6
    2
    Ok, so my ibt-2 had 10K gain resistors, popped those off the board and put a single 1k resister from the connecter IS lines to ground, jmri dropped to 8ish%....

    Need to order a resistor assortment, a 1k percision pot, and get the rheostat in that I ordered to figure out optimum value for this new resistor.

    We should be able to simply add 1 resistor between the connected IS lines to ground to adjust the current sense to something more accurate and practical for our application.
     
  13. tnt23

    tnt23 TrainBoard Member

    27
    15
    4
    The chips under question have accuracy of about +/-28% worst case, my experience with similar ones was that they can be calibrated to give somewhat better results under small currents, like 50-100mA error, but that would require some effort and should be done on each board individually.

    (A few bits on it here - https://www.trainboard.com/highball...ware-motor-shields.90314/page-19#post-1122869)
     
  14. Keith Ledbetter

    Keith Ledbetter TrainBoard Member

    279
    195
    12
    Paul really interested in your results. I think a pot is a great idea. If indeed you find useful may be worth fabricating modifying original posters pcb with a spot for a pot or I guess once we find right resistance should be consistent with all other parts equal? that we could solder the chips/other bits on ourselves as a hat for UNO/Mega. I think others have tested up to about 4A without any significant heat on the drivers so could eliminate that massive heat sync and replace with something reasonable sized if you are going to run more than 4A I have been wanting to do this for some time just havent taken the time to study the schematics or learn how to do PCB design easily but clearly original thread starter has done most of the hard work needed on it.

    TNT are you willing to post schematic and board files?
     
    Last edited: Mar 11, 2020
  15. tnt23

    tnt23 TrainBoard Member

    27
    15
    4
    EssexDan likes this.
  16. tnt23

    tnt23 TrainBoard Member

    27
    15
    4
    For the record, this was my old setup:

    photo_2020-03-15_23-27-32.jpg
     
  17. FlightRisk

    FlightRisk TrainBoard Member

    548
    237
    14
    @tnt23 Hi Tim. Been so busy with DCC++ EX and some accessories and new features but really wanted to get more into this. We have a complete Command Station with FireBox, but still want a board that is pin compatible out of the box to stick on an Uno or Mega for DIY folks. There are changes coming though in that we won't need 2 timers anymore, so no jumpers with An Uno or a Mega, but to me, a board with all the pins in the right place, can handle 5 Amps, can run the main track and the program track, and have accurate current reporting is the sweet spot solution.

    There really is no need to have a Command Station that has more than 5Amps. If you need more than that, people should use boosters. That would also make it easier to have accurate current sense over that range. On the IBT-2s, Dave Bodnar stuck a 10k resistor from A0 to ground on his booster project which put the resistors on the IBT-2 in parallel. That gave a value of 3.3k. The max current before having to switch to a lower resistor would be around 12Amps. Again, I could be convinced that someone *might* want 10 Amps, but I just think that is unnecessary and/or a different market than the one we are targeting with these shields.
     
  18. Ash

    Ash TrainBoard Member

    106
    67
    8
    I encourage efforts towards a standard 5 Amp shield. 5 Amps would have been adequate, until I went shopping for a power supply. And it seems the shield rating could be quite a bit higher than the power supply.

    After getting started with a minimal/standard motor shield, I began looking for a motor shield that would not break. What happens when I get a 7A or 10A power supply? And I don't know about boosters or what use they would have if my power supply is adequate.

    My searching led me to your links to the model-railroad-hobbyist and locoduino sites.
    https://www.trainboard.com/highball/index.php?threads/motor-shield-question.130561/#post-1135502

    I now have the following components on order:
    Mean Well 15V 10A power supply: LRS-150-15
    Dual Motor Driver Module Board H-bridge MOSFET IRF3205 3-36V 15A
    Pololu current sensor modules: ACHS-7121 10A and ACHS-7122 20A
    ( coupon was available https://www.pololu.com/specials )​

    Why 15 volts and not 18 volts as shown on the locoduino site?
     
  19. FlightRisk

    FlightRisk TrainBoard Member

    548
    237
    14
    There a multitude of issues that make it difficult to find or even build a motorboard that will work for model railroading needs. This is a motor controller that we are using to generate a varying PWM signal. We are toggling the the direction pin at radio frequencies, something the boards were not designed to do (see the VNH2SP30 that won'twork). As soon as you find a chip for a Dual-H Bridge or a Current sense chip, it is labeled "end of life". The LM298s are highly inefficient, so you have to figure in the voltage drop on these boards, so have to have a 15V supply to get 12 or 12V out depending on your current. And current sense is the major issue we have always had to deal with. Without accurate current sense, we can't read the ACK back from a decoder on the Program Track or have proper short circuit detection. And some chips have built-in overcurrent detection which shuts down the board in 30-60 microseconds. There goes our short circuit detection and the possibility to use auto reversing (the whole system would shut down when the train shorts at the autoreversing section). And if we find a good board, it may not be available or it would cost to much to ship to some countries. I'm frustrated this week, can you tell? LOL. We've been having a big discussion about how to work with all the boards out there, but also design a new shield.
     

Share This Page