Turntable controller: finalised project proposed

Erik84750 Feb 12, 2024

  1. Bob Brockhouse

    Bob Brockhouse TrainBoard Member

    46
    39
    3
    Thanks for the quick response. Really helps a project along to have the questions answered.

    Will heed your advice on the bridge rectifier idea, as will have the 12 volt stepper power line
    to use to feed the autoreverser 5 volt regulator as an option.

    Many thanks.
     
  2. Erik84750

    Erik84750 TrainBoard Member

    360
    152
    12
    Here is an update to my program. In the previous version I made a beginner's mistake, ie an endless loop when shortcircuit is detected.
    Below I inroduced a software version of a bistable multivibrator, ie when a short is detected the relay is either activated of disactivated depending on its previous state, with a 500ms delay to cover the relay response time.
    Additional advantage: short circuits are "immediately" detected (within a +/- 2µs response time for a 16MHz crystal frequency).

    //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
    bool relayState = false;

    // 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); // comment out to increase loop speed

    if (mA > 1500 && relayState == false)
    {
    digitalWrite(relay, HIGH);
    digitalWrite(led, HIGH);
    relayState = true;
    delay(500);
    }
    else if (mA > 1500 && relayState == true)
    {
    digitalWrite(relay, LOW);
    digitalWrite(led, LOW);
    relayState = false;
    delay(500);
    }
    }

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

    Bob Brockhouse TrainBoard Member

    46
    39
    3
    Erik,

    Excellent work on the autoreverser. Very happy to report the updated schematic and the
    revised code perform just fine with my lash up on a prototyping DIL pcb.

    All connected to a test track, the loco sets off the trip indicator as expected. The loco
    does not hesitate or stop, just continues it's travel seamlessly.

    I commend your time and effort, as far I'm concerned it's a project worthy of more
    recognition. And nicely documented on your Github if I may say.

    Many thanks, Bob.
     
    Erik84750 and Sumner like this.
  4. Erik84750

    Erik84750 TrainBoard Member

    360
    152
    12
    Bob, this is my pleasure! It makes me thankful to have people like you appreciate my work :).

    One thing I am hesitant about is something you made a remark to me before concerning a line of code:
    int mA = abs(ACS.mA_DC());
    to be changed to, ..maybe?
    int mA = abs(ACS.mA_AC());
    Just wondering if it does make a difference to performance? In a few weeks I might get the time to connect an oscilloscope to measure any speed difference in detection and relay action. But meanwhile, if you spot a difference please enlighten me :).
     
    Bob Brockhouse likes this.
  5. Bob Brockhouse

    Bob Brockhouse TrainBoard Member

    46
    39
    3
    Speaking for myself, I would be curious to know if a scope can pick a difference in performance.
    From what I have seen so far by naked eye, the loco has no hesitation across the gapped rails
    moving in both directions, my DCC-EX command does not freak out. I have a track output LED
    on my command station that shows a very quick short circuit, so quick it does not trip out.

    Would be timely to hear from other builders as to their mileage and observations. I am very
    happy with what we have , use it as is. I reckon Erik has burnt enough midnight oil here.

    Cheers
     
    Sumner and Erik84750 like this.
  6. Erik84750

    Erik84750 TrainBoard Member

    360
    152
    12
    Thank you Bob, your support is very much appreciated!
    By the way, if you ever plan on coming to Europe just PM me :).

    EDIT: for who is interested, my github page contains it all, https://github.com/Erik84750
     
    Sumner likes this.
  7. peteGSX

    peteGSX TrainBoard Member

    40
    85
    2
    Apologies, I haven't logged in for a while, and missed all the updates!

    If the loco is not stopping with the updated auto reverser in play and the command station not tripping, then that is fantastic!

    There have been changes to the time to trip in the DCC-EX software as a result of seeing auto reversers being slower than the short circuit detection, but not sure if those have progressed from our development versions into a production release yet.

    Either way, this is great news, and looks like a good result!
     
    Bob Brockhouse likes this.
  8. Bob Brockhouse

    Bob Brockhouse TrainBoard Member

    46
    39
    3
    Thanks for the kind words about coming to Europe. Unfortunate for me old age and health and
    budget will hold me back. Would be nice to sample the famous waffles dripping with the equally
    famous chocolate.

    Now again I ask for your indulgence, referring to the autoreverser schematic, D13 of the Arduino
    goes to a 1k resistor then to connector marked X2-1. I assume this then goes to a LED, but
    connected to what / where and for indication of what activity ? To date with my test setup, I have
    left D13 unconnected, the autoreverser is doing it's thing but need to clarify the intent of this LED.

    Cheers
     
  9. Erik84750

    Erik84750 TrainBoard Member

    360
    152
    12
    Bob, that is to an external LED (ie 3mm, 5mm, or whatever). It doubles as the built-in LED on D13.
     
    Bob Brockhouse likes this.
  10. Bob Brockhouse

    Bob Brockhouse TrainBoard Member

    46
    39
    3
    Erik,

    Referring to the actual controller code, not the autoreverser. When we see "wrong key pressed,
    press character key" does this mean either the asterix "*" or the hash "#" key are what the
    message refers to ? May seem a dumb question, but need to ask to set my use correctly.

    When selecting a saved position either of these "characters" must be keyed before entering
    the desired stored track value ?

    Thanks
     
  11. Erik84750

    Erik84750 TrainBoard Member

    360
    152
    12
    Good morning Bob, thank you for your query. I will answer asap, but it may take a few days: we arrived yesterday evening to our Provence residence (southern France) after a +1000km drive and it will take some days before we are fully settled in.
     
    BNSF FAN likes this.
  12. Erik84750

    Erik84750 TrainBoard Member

    360
    152
    12
    Qualifier: while my gear has still not been set up I try to answer by reading from the code from my program; its response to "Wrong key pressed...": this appears when character (A, B, C or D) is selected, and no pending operation.
    When selecting B, then, after entering the numerical position value then press either # to validate, or press * to erase the last entry.
    When selecting D then an index value needs to be entered.
    When selecting # a desired index position is entered,
    when selecting * then the same as # except the result will be +180°.

    This operation is supported by character D.
     
    Bob Brockhouse and BNSF FAN like this.
  13. Bob Brockhouse

    Bob Brockhouse TrainBoard Member

    46
    39
    3
    Thanks for the early reply, which I will need to read over again a few times for it
    to sink in. My interpretation of "character" meant any keys that are not alpha or
    numerical, leaving the hash and asterisk as the only contenders.

    I do apologize if my question caused confusion, the keypad usage has been
    documented in your Github, and read multiple times. Some things take me
    a little longer lately to digest. Boolean logic I will never get so leave it alone.

    Back in France, long journey again, but worth every kilometer no doubt.

    Cheers
     
    Sumner and Erik84750 like this.
  14. Erik84750

    Erik84750 TrainBoard Member

    360
    152
    12
    Hi Bob, yes indeed, our Provence home is our little paradise; we love it here.

    Please send me every question you have, I must admit you are an ideal tester. This helps me to improve the user experience of this project. As a creator I have a tunnel vision borne out of months of development on my own; so your testing, comments and questions are invaluable to me (an excellent example is the development of the autoreversing project; I had not thought of that before your questions on that issue (y)).

    I will modify the help file "character" issue, good to point that out.

    Cheers!
    Erik
     
    Sumner and Bob Brockhouse like this.
  15. Bob Brockhouse

    Bob Brockhouse TrainBoard Member

    46
    39
    3
    To peteGSX,

    Have noticed a new throttle posted on the DCC-EX site, "blue pill wired throttle" by "n1ksn" aka
    Andrew Palm. Has a Github link. This has attracted my attention as a project of great interest and
    downloaded the available file.

    My apologies to raise this with you knowing it may not be politically correct, I can't see a way to
    make contact seeking to clarify what versions of libraries his throttle was created with ? If an
    update to his Github is pending, it would be welcome to see version numbers and maybe a
    wiring diagram to backup the pin assignments shown in the code.

    Currently having no luck with compiling his code, with no meaningful error messages to work
    with. I do acknowledge that the DCC-EX team have no obligation in this matter. Just like to see
    this project functional. Would be ideal if Andrew is a Trainboard member and willing to respond,
    but do respect his right to keep a low profile as the case may be.

    Thanks.
     
  16. Erik84750

    Erik84750 TrainBoard Member

    360
    152
    12
    Hi Bob,

    maybe start a new thread to avoid hijacking this one?

    Thanks!
    Erik
     
  17. Bob Brockhouse

    Bob Brockhouse TrainBoard Member

    46
    39
    3
    My bad, will open up in DCC++ forum.

    Cheers
     
  18. Bob Brockhouse

    Bob Brockhouse TrainBoard Member

    46
    39
    3
    Pete,

    Update to this post, this subject now a new thread on the DCC++ forum "Bluepill throttle".

    Cheers
     

Share This Page