CommandStation-EX, motor shield config questions

franz_H0m Nov 6, 2020

  1. franz_H0m

    franz_H0m New Member

    5
    3
    1
    All,

    I want to define a motor shield with main track only, my idea is to free the IO pins that are used by the programming track for sensors instead.

    I use the latest CommandStation-EX. I did succeed to compile with following custom defined shield:

    Code:
    #define FRANZ_MOTOR_SHIELD F("FRANZ_MOTOR_SHIELD"),                                                 \
                                  new MotorDriver(3, 12, 13, UNUSED_PIN, UNUSED_PIN, 2.99, 2000, UNUSED_PIN), \
                                  new MotorDriver(UNUSED_PIN, UNUSED_PIN, UNUSED_PIN, UNUSED_PIN, UNUSED_PIN, 2.99, 2000, UNUSED_PIN)
    I kind of figured the second driver with no pins defined would eliminate the prog track.
    I use a L298N module without need for an inverter successfully, it compiles and I can run locos.

    However, I get an error message all the time, with varying current values:
    Code:
    *** PROG TRACK POWER OVERLOAD current=723 max=248  offtime=10000 ***
    Any advice how to get rid of this? Does it hurt?
     
  2. rkmAT

    rkmAT New Member

    8
    3
    1
    Hi!
    Normaly you need an analog pin to read the current of the track. In your case the station reads the current from pin UNUSED_PIN and this causes undefined values and the station turns off because of over current. If you don't need a prog track than I prefer you to use A0 for both tracks as the current pin and connect this pin to ground.

    But if you need this pin urgent then you can make a quick fix and modify the code in MotorDriver.cpp around line 92 from:

    int MotorDriver::getCurrentRaw() {
    if (faultPin != UNUSED_PIN && ReadPin(faultPin) == LOW && ReadPin(powerPin) == HIGH)
    return (int)(32000/senseFactor);

    into:
    int MotorDriver::getCurrentRaw() {
    if (currentPin == UNUSED_PIN) return 0;
    if (faultPin != UNUSED_PIN && ReadPin(faultPin) == LOW && ReadPin(powerPin) == HIGH)

    But do this only if you are confirmed in programming. Because if you update the software later then you have to make the fix again and the code may be changed there.
     
  3. FlightRisk

    FlightRisk TrainBoard Member

    548
    237
    14
    We would need to add a "NULL" or similar option and change a few things in the code. Then we could create a new motorboard type (just a couple of lines in the config.h file. We will take a look at that for the next version.
     
    franz_H0m likes this.
  4. franz_H0m

    franz_H0m New Member

    5
    3
    1
    Great, thanks, that helps at lot.

    Yes, I am aware of the risk to dig down into the code with future updates.

    Cheers,
    Franz
     

Share This Page