Turntable controller: finalised project proposed

Erik84750 Feb 12, 2024

  1. Bob Brockhouse

    Bob Brockhouse TrainBoard Member

    34
    33
    3
    Erik,

    Thanks for the reply. You are not referring to Norm by any chance ? We exchanged emails
    regularly with his Nextion throttle project for the UNO version. Recently had sent a catch up
    email to his most recent address at gmail. Receiving no reply I assume his email has changed.

    Just for info.

    Cheers
     
  2. Erik84750

    Erik84750 TrainBoard Member

    353
    141
    12
  3. peteGSX

    peteGSX TrainBoard Member

    39
    84
    2
    Sorry but a tangential comment here... next time you're talking to your knowledgeable friend, you'd be welcome to mention we have recently released an Arduino library throttle developers can use if he wishes to work that into his Nextion software :)
     
  4. peteGSX

    peteGSX TrainBoard Member

    39
    84
    2
    Always happy to help if I can, and I'm also curious to see the success (or otherwise) of this, as the notion of auto reversers is a reasonably regular topic on the DCC-EX Discord server.

    Incidentally I happen to have all the components to make one also, but alas not the time, at least not at the moment anyway.
     
  5. Sumner

    Sumner TrainBoard Member

    2,846
    6,004
    63
    Pete do you have a link to were I can find out more about that? Thanks,

    Sumner
     
  6. peteGSX

    peteGSX TrainBoard Member

    39
    84
    2
    Sure can! We have some general guidance for throttle developers here: https://dcc-ex.com/throttles/tech-reference.html#gsc.tab=0

    The library itself is documented here: https://dcc-ex.com/DCCEXProtocol/index.html

    It can be installed like any other Arduino library in the IDE, just search for "DCCEXProtocol".

    Edit: Nearly forgot, but there is also the #dccexprotocol-library on Discord too.
     
    Last edited: Apr 19, 2024
    BNSF FAN and Sumner like this.
  7. Bob Brockhouse

    Bob Brockhouse TrainBoard Member

    34
    33
    3
    An update to my earlier post. Have managed to get the breadboard lash up to show signs of life.

    Would seem I had intermittent contact between the relay pins and the breadboard, giving no
    activity. Can report the LED now indicates the transistor switching function works. Have made
    a mock up of the rail connections to simulate the gaped rails needed. The LED and the relay
    confirm the tripping when the gap is shorted.

    Next step is to actually set up some real rails with the gap and run a loco to replicate what we
    see on the author's video. So the essence is the circuit does work with the component values
    given in the parts list, and the Arduino code given.

    From there would be the evaluation as to it's suitability for turntable use. May need some
    tweaking to suit. I would be guided by pete's comments on important considerations to
    reach any conclusion.

    Cheers
     
  8. Bob Brockhouse

    Bob Brockhouse TrainBoard Member

    34
    33
    3
    To those interested, have found a circuit for a simple DCC phase checker using LED's to
    display phasing on two separated tracks, such as we have with auto reverser.

    Could be incorporated into the project as a visual confirmation of the auto working correctly.
    A permanent display somewhere near the turntable maybe, as a row of six LED's.

    Credit goes to "vggrek" on posting the circuit on May 2019, MRH Forum - DCC polarity tester.
    MRH - magazine. Simply do a "save image as" to have a copy of the circuit, as well a copy of
    the chart showing what to expect from each of the LED's when in use.

    I plan to bash one up for evaluation, if proven will incorporate into my autoreverser.
    Would simply be wired to the existing DCC input and output connectors.

    Cheers
     
    Sumner likes this.
  9. Bob Brockhouse

    Bob Brockhouse TrainBoard Member

    34
    33
    3
    Erik,

    Referring to your controller circuit diagram, the A4988 stepper driver is wired as default of
    full step mode. I would like to use / try some of the microstepping options if usable with your
    project.

    Your recommendation to using a NEMA17 on what settings range would be welcome.
    As well any comment you may have on the use of a TB6600 stepper driver with your
    controller would be welcome.

    Thanks in advance.

    Cheers
     
  10. Bob Brockhouse

    Bob Brockhouse TrainBoard Member

    34
    33
    3
    To peteGSX and other's interested.

    Have set up the autoreverser test track with real rail gapped as required.

    Can report that the circuit does indeed register a short when a loco hits the
    gapped rails. It also (unfortunately) stops the loco on the gap, seemingly
    shutting down my command station instantly which is good in one way.
    We can see the command station is functioning correctly as it should for any
    short.

    Further testing is needed to prove that the command station is resetting to
    zero speed , which could explain why the loco is not progressing past the gapped rails
    after the short is detected.

    For info, I am using a DCC-EX command station running with Arduino mini Mega, and a
    Deek Robot motor shield. Cloned Arduino Rev.3 motor shield. The mini mega is rigged to
    a UNO prototyping board so the motor shield just plugs in, works a treat.

    While I'm here, must mention that the DCC polarity tester has been tested also. I am not
    confident it is really for DCC. The circuit itself does not equate to the negative voltage
    we have on a DCC bus. Meaning voltage that is AC in form and is below zero in value.
    Have tested with LED 4 across the rails, it lights up when mounted either way on DCC,
    not what we need . The circuit would function as shown on the chart provided , on DC.

    Cheers
     
  11. Erik84750

    Erik84750 TrainBoard Member

    353
    141
    12
    Hi Bob, sure a different stepper modus is possible: in my pcb there are solderpads for MS1 through MS3. If left open, then "full step" (default) is applicable. Depending on the shorting of MSx different ratios can be selected. For example, soldering all three bridges brings the stepper to a 1/16 th modus.
    Is that a answer to your question?

    A TB6600 stepper MotorInterfaceType = 1, just as for the A4988.
     
    Bob Brockhouse likes this.
  12. Erik84750

    Erik84750 TrainBoard Member

    353
    141
    12
    ..and finally here is the schematic for a ACS712-based auto-reverser.

    Since the ACS712 is modular based I used two connectors (X2-1 and X2-2) for the current to be measured; these need to be connected to the module current-connectors.
    Supply and ground are connected to X6-1 and X3-1.
    And the module output is connected to A0 through X3-2.

    General sypply and ground: X1-1 and X1-2.

    The controller (Uno, Nano, Pro Mini) is to be programmed with the output driving D2 (to the mosfet gate), at least per this schematic (changes are easy :) ).
     

    Attached Files:

    Bob Brockhouse likes this.
  13. Bob Brockhouse

    Bob Brockhouse TrainBoard Member

    34
    33
    3
    Great news,thanks Erik, can tinker around to satisfy the curiosity.

    Cheers
     
  14. Erik84750

    Erik84750 TrainBoard Member

    353
    141
    12
    Software to follow, but that will be a very small amount of code. The code published on the above Github page is flawed. I will do some testing over the weekend, and expect a working version to be uploaded here by Monday.
     
  15. Erik84750

    Erik84750 TrainBoard Member

    353
    141
    12
    Here the software for the above schematic:

    //Autoreverser 1.0 (2020-12-25)
    // DCC Isolated Autoreversing circuit for turntable track
    // A0 pin connected to the out pin of the ACS712 current sensor
    // D2 pin connected to the gate of the MOSFET, driving the relay
    /*
    https://www.trainboard.com/highball...ller-finalised-project-proposed.154256/page-3
    */
    //
    // FILE: ACS712_20_DC.ino
    // Adapted from AUTHOR: Rob Tillaart
    // PURPOSE: demo for AutoReversing circuit for DCC turntable track polarity reversal
    // URL: https://github.com/RobTillaart/ACS712
    //
    // use with Arduino Serial Plotter/Monitor

    #include "ACS712.h"
    #define relay 2
    #define led 13

    // Arduino UNO has 5.0 volt with a max ADC value of 1023 steps
    // ACS712 5A uses 185 mV per A
    // ACS712 20A uses 100 mV per A
    // ACS712 30A uses 66 mV per A

    ACS712 ACS(A0, 5.0, 1023, 185);
    // ESP 32 example (might requires resistors to step down the logic voltage)
    // ACS712 ACS(25, 3.3, 4095, 185);

    void setup()
    {
    Serial.begin(115200);
    while (!Serial);
    Serial.println(__FILE__);
    Serial.print("ACS712_LIB_VERSION: ");
    Serial.println(ACS712_LIB_VERSION);
    ACS.autoMidPoint();
    // Serial.println(ACS.getMidPoint());
    pinMode(relay, OUTPUT);
    pinMode(led, OUTPUT);
    }

    void loop()
    {
    int mA = abs(ACS.mA_DC());
    Serial.println(mA); // may be omitted to increase loop speed

    if (mA > 2000)
    {
    digitalWrite(relay, HIGH);
    digitalWrite(led, HIGH);
    }
    else
    {
    digitalWrite(relay, LOW);
    digitalWrite(led, LOW);
    }
    delay(100); // reduce delay to less than the time required by the DCC++/EX power booster to shut down due to a true short circuit; usually <10.
    }


    // -- END OF FILE --
     
    Sumner and Bob Brockhouse like this.
  16. Erik84750

    Erik84750 TrainBoard Member

    353
    141
    12
    Below is a revised schematic for the autoreverser (no essentials have been modified, addition of a 5V regulator, diodes and caps, and a few adjustments to connectors).
    Also added are the Gerber files for PCB manufacture.
     

    Attached Files:

    Bob Brockhouse likes this.
  17. Bob Brockhouse

    Bob Brockhouse TrainBoard Member

    34
    33
    3
    Excellent work Erik, the additional 5V. supply is a great idea. Cheers.
     
  18. Erik84750

    Erik84750 TrainBoard Member

    353
    141
    12
    I dimensioned the pcb so that 2 can be made out of a standard 100x100mm board (used by most PCB fabs).

    The board supply voltage may be anything of either 5V (without regulator) or either between 7V and about 20V.
    A bill of materials needs to be made but if required I will help sourcing all parts.
     
  19. Bob Brockhouse

    Bob Brockhouse TrainBoard Member

    34
    33
    3
    Erik,

    With over 3000 views now, your project has attracted a lot of interest, me included.

    Now, I seek your indulgence with two questions relating to the autoreverser code.

    Line 44 says "mA_DC" should this be "mA_AC" or it doesn't matter in this case ?

    Line 47 says "mA >2000", referring to command station trip current or what the
    circuit must register to activate the relay ? Can this setting be varied to suit a user's
    needs ie less loco's = less current, more loco's = more current. Different needs for a
    large club layout or a smaller home layout crosses the mind.

    Like the inclusion of a 5v. regulator to the circuit, for me I will be bashing up a breadboard
    version with bridge rectifier up front. Makes for a self contained package, just like the front
    end of most decoders where the track DCC bus is rectified to power the electronics within.

    Thanks again.
     
  20. Erik84750

    Erik84750 TrainBoard Member

    353
    141
    12
    ..I am most surprised too :)

    The DCC signal actually is a modulated DC current (where the polarity may be inverted, hence the relay). The library used (by Rob Tillaert) can measure either an AC current-where no polarity is involved- or a polarised current (such a DCC).

    Sure Bob, the 2000mA is an arbitrary value to discriminate between a regular loco current use and a short circuit current. If a loco consumes less then, say, 500mA nothing wrong with changing the threshold from 2000 to, say, 1000.
    Remember that the ACS712 is a noisy detector unable to discriminate between current differences of less the a few hundred mA's.

    It' my pleasure Bob.

    Using a rectifier on the DCC bus causes the circuit to be galvanically connected to the DCC signal. I would not recommend this.
     

Share This Page