DCC++EX with Arduino Mega and LMD18200

french_guy Jan 9, 2022

  1. french_guy

    french_guy TrainBoard Member

    628
    374
    28
    Hello

    I've built the command station with a Mega and 2 x LMD18200 form the French website Locoduino:
    https://www.locoduino.org/spip.php?article187
    Now, what do I need to update (in config.h and/or others) for the LMD18200 and the current sensing that is 3A max with this type of motor driver?

    Thanks
     
    ARA likes this.
  2. Sumner

    Sumner TrainBoard Member

    2,798
    5,837
    63
    I'd probably ask the question on their Discord site if you don't get an answer here soon....

    https://discord.com/invite/PuPnNMp8Qf

    I did just find this thread but it doesn't address your question but might bring up that with that board you might have to use something else for the current sense if I understood it right, but a lot of it is over my head.....

    https://discord.com/channels/713189617066836079/734955580149727243/792095742679449600

    Did you use that motor board since the recommended ones are hard for you to find?

    Sumner
     
  3. wvgca

    wvgca TrainBoard Member

    499
    305
    21
    you might want to look at the BTS7960, a little more power in that package , lol
     
  4. french_guy

    french_guy TrainBoard Member

    628
    374
    28
    I already use a Uno + Deek Robot motor shield with DCC++EX.....works great
    I wanted to build another one with the LMD18200 that provides slightly more power
    The Locoduino website explains everything very well.....and being French, it was even easier
    But I need help with the program / configuration though.....
     
    Sumner likes this.
  5. Ash

    Ash TrainBoard Member

    106
    66
    8
    These lines could be added in config.h
    #define LMD18200_MOTOR_BOARD F("LMD18200_MOTOR_BOARD"), \
    new MotorDriver(3, 12, UNUSED_PIN, UNUSED_PIN, A0, 4.88, 3000, UNUSED_PIN), \
    new MotorDriver(11, 13, UNUSED_PIN, UNUSED_PIN, A1, 4.88, 3000, UNUSED_PIN)
    #define MOTOR_SHIELD_TYPE LMD18200_MOTOR_BOARD

    Note that pin 13 is now used (vs. pin 2 with DCC++).
    The 4.88 current factor is based on 1.0 V/A -- but use caution with MAX471 modules.
    Use a meter to check the DC output which you plan to connect to A0/A1. With no load, it should be 0 volts -- a faulty module might output the track voltage and damage the Arduino.

    -- for further information see:
    https://dcc-ex.com/advanced-setup/motor-board-config.html#your-board-is-not-in-the-supported-list
     
    Sumner likes this.
  6. french_guy

    french_guy TrainBoard Member

    628
    374
    28
    So I will have to re-wire to use pin 13 vs pin 2, right?
     
  7. Ash

    Ash TrainBoard Member

    106
    66
    8
    Yes. Use pin 13.
    While you could update the motor board definition to use pin 2, changing the wiring to use pin 13 will result in utilizing "high accuracy waveform".
     
  8. french_guy

    french_guy TrainBoard Member

    628
    374
    28
    OK, so I've changed the wiring (pin 13 vs pin 2) and added those lines in Motordrivers.h
    // LMD18200 Motor Board
    #define LMD18200_MOTOR_BOARD F("LMD18200_MOTOR_BOARD"), \
    new MotorDriver(3, 12, UNUSED_PIN, UNUSED_PIN, A0, 4.88, 3000, UNUSED_PIN), \
    new MotorDriver(11, 13, UNUSED_PIN, UNUSED_PIN, A1, 4.88, 3000, UNUSED_PIN)


    And this one in Config.h
    #define MOTOR_SHIELD_TYPE LMD18200_MOTOR_BOARD

    Compilation seems OK (no error - I get this message):
    Sketch uses 41244 bytes (16%) of program storage space. Maximum is 253952 bytes.
    Global variables use 1677 bytes (20%) of dynamic memory, leaving 6515 bytes for local variables. Maximum is 8192 bytes.


    But when I try to upload, I have an error
    java.io.IOException: Access is denied
    at java.io.WinNTFileSystem.createFileExclusively(Native Method)
    at java.io.File.createTempFile(File.java:2024)
    at processing.app.BaseNoGui.saveFile(BaseNoGui.java:886)
    at processing.app.SketchFile.save(SketchFile.java:287)
    at processing.app.Sketch.save(Sketch.java:138)
    at processing.app.SketchController.save(SketchController.java:352)
    at processing.app.Editor.handleSave2(Editor.java:1908)
    at processing.app.Editor.handleSave(Editor.java:1883)
    at processing.app.Editor.handleExport(Editor.java:2023)
    at processing.app.EditorToolbar.handleSelectionPressed(EditorToolbar.java:498)
    at processing.app.EditorToolbar.mousePressed(EditorToolbar.java:448)
    at java.awt.Component.processMouseEvent(Component.java:6536)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
    at java.awt.Component.processEvent(Component.java:6304)
    at java.awt.Container.processEvent(Container.java:2239)
    at java.awt.Component.dispatchEventImpl(Component.java:4889)
    at java.awt.Container.dispatchEventImpl(Container.java:2297)
    at java.awt.Component.dispatchEvent(Component.java:4711)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4904)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4532)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4476)
    at java.awt.Container.dispatchEventImpl(Container.java:2283)
    at java.awt.Window.dispatchEventImpl(Window.java:2746)
    at java.awt.Component.dispatchEvent(Component.java:4711)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:760)
    at java.awt.EventQueue.access$500(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.awt.EventQueue$3.run(EventQueue.java:703)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:84)
    at java.awt.EventQueue$4.run(EventQueue.java:733)
    at java.awt.EventQueue$4.run(EventQueue.java:731)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:730)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
    Access is denied


    Any idea what am I doing wrong?
     
    Last edited: Jan 11, 2022
  9. Ash

    Ash TrainBoard Member

    106
    66
    8
    Uncertain of the issue.

    Perhaps try to upload again, after making sure that JMRI was shut down and after freshly starting the Arduino IDE.

    And while the changes you made can work, all 4 lines would normally be added to config.h --- then when you download a new release, you copy over your config.h file without editing the system files.
     
  10. french_guy

    french_guy TrainBoard Member

    628
    374
    28
    Well, I did try on a different USB port, and it seems to work
    I've also put all the 4 lines in config.h
    I will have to add visualization led on the LMD18200 boards to verify it works with the serial monitor and some basic commands
    What exactly do I need to verify (and how) with the MAX471 current boards?
     
    Last edited: Jan 12, 2022
    Sumner likes this.
  11. Ash

    Ash TrainBoard Member

    106
    66
    8
    Your primary test is to confirm that MAX471 does not put high voltage into A0/A1 analog pin. Before connecting to A0/A1 check the voltage with track power supply plugged into the wall. You are not trying to turn on track power yet; you just need power to MAX471 so that you can measure the voltage on the MAX471 pin you plan to connect to A0/A1. With no load, it should be very close to zero volts DC. (My faulty MAX471 modules measured 13 volts, instead of zero.)

    You can also put a resistance load on the MAX471 output terminals to verify current sense. Perhaps use something with a heating element and measure the resistance to confirm it will not pull more than 3A. I have a clothes iron that measures 14 ohms.
    13 volts / 14 ohms = 0.93 amps
    And if the output of the MAX471 intended for A0/A1 is close to 0.93 volts, it confirms the expected 1.0v/A.
     
    Sumner likes this.
  12. french_guy

    french_guy TrainBoard Member

    628
    374
    28
    I will try with a 10 ohm 10W resistor......
     
  13. french_guy

    french_guy TrainBoard Member

    628
    374
    28
    Looks like everything is fine....with a 10 ohm /25 watt resistor, I measured 1,34 /1,35V on each output, the board being powered at 13.5V
    13.5 / 10 ohm = 1.35A
     
    Last edited: Jan 19, 2022
  14. french_guy

    french_guy TrainBoard Member

    628
    374
    28
    Looks like hardware/wiring is exactly the same between main and prog
    But is there anything specific in the software that differentiate them though? Like less current for the program output?
     
    Last edited: Jan 22, 2022
  15. Sumner

    Sumner TrainBoard Member

    2,798
    5,837
    63
    From what I know (limited) the program track is set at a lower max current. DCC++EX does allow you a lot of options in this regard. Check out this link if you haven't.....

    https://dcc-ex.com/reference/software/command-reference.html

    Some of the options let you send a serial command that joins the program track to the main or back to the program track. I switch a program track back and forth to the main so I can drive off with a DPDT switch but now you don't have to due that if you want to use the serial commands described above.

    Also some decoders don't always program well with the default NMRA specs and again DCC++EX allows you to manipulate the specs....

    https://dcc-ex.com/reference/software/diagnostic-d-ack-command.html

    Since I've been running DCC++EX I haven't any longer had problems programming decoders and I haven't had to change the default settings but if I do I can.

    DCC++EX is going past a lot of the commercial stuff in what your options are,

    Sumner
     
  16. french_guy

    french_guy TrainBoard Member

    628
    374
    28
    Here is my Base Station by the way:
    20220122_173723.jpg
     
    KC Smith and Sumner like this.
  17. wvgca

    wvgca TrainBoard Member

    499
    305
    21
    that's a relatively clean install... good job
     

Share This Page