What am I doing wrong?

Rob H Dec 30, 2017

  1. Rob H

    Rob H TrainBoard Member

    22
    15
    2
    Okay, I've spent the last few days banging my head against the wall.

    I'm currently trying to use a Mega and a Motor Shield, I want to add in an ethernet shield but small steps.

    I've downloaded the BaseStation code from GIT hub:

    https://github.com/DccPlusPlus/BaseStation

    I've noticed that the code says "uno" not "mega" is this an problem?

    Having watched Gregg's Mega video a million and one times, I can find no reference to Mega specific software or any config changes that need to be made when using a Mega.:



    I have compiled the code and loaded it up onto the Mega. I can connect to the Mega through Gregg's software:

    https://github.com/DccPlusPlus/Controller

    and I can turn the track power on and off, so I'm guessing that I've compiled and installed the code correctly.

    However I can't interface with the Mega from the serial monitor in the Ardunio IDE, simple commands like < s > or < 1 > or < 0 > don't do anything, they don't return any messages nor does < 1 > turn on the output LEDs on the motor shield (they turn on & off fine when pressing the power button on Gregg's Controller software.

    Have I missed something?
     
    Scott Eric Catalano likes this.
  2. Trusty

    Trusty TrainBoard Member

    52
    33
    6
    There is nothing to do or configurate for the Mega. It works directly. But have you set the right com port, the right serial speed in your sketch (Serial.begin(115200); for instance) and the same in the console? It's seems to be a serial communication problem...
     
    Scott Eric Catalano likes this.
  3. Rob H

    Rob H TrainBoard Member

    22
    15
    2
    Thanks, having looked at SerialCommand.h and SerialCommand.cpp I can't see any reference to com port or serial speed, however if I go into Serial Monitor in the Ardunio IDE and change the baud rate from 9600 to 115200 I now get the following message:

    <iDCC++ BASE STATION FOR ARDUINO MEGA / ARDUINO MOTOR SHIELD: BUILD Dec 30 2017 18:53:20><N0: SERIAL>

    but I still don't get any response when I try typing commands.

    EDIT:

    Just found the following in the main DCCpp_UNO:

    void setup(){

    Serial.begin(115200); // configure serial interface
    Serial.flush();

    #ifdef SDCARD_CS
    pinMode(SDCARD_CS,OUTPUT);
    digitalWrite(SDCARD_CS,HIGH); // Deselect the SD card
    #endif

    EEStore::init(); // initialize and load Turnout and Sensor definitions stored in EEPROM

    Serial.print("<iDCC++ BASE STATION FOR ARDUINO "); // Print Status to Serial Line regardless of COMM_TYPE setting so use can open Serial Monitor and check configurtion
    Serial.print(ARDUINO_TYPE);
    Serial.print(" / ");
    Serial.print(MOTOR_SHIELD_NAME);
    Serial.print(": BUILD ");
    Serial.print(__DATE__);
    Serial.print(" ");
    Serial.print(__TIME__);
    Serial.print(">");

    Time for a bit more experimentation
     
    Last edited: Dec 30, 2017
    Scott Eric Catalano likes this.
  4. Trusty

    Trusty TrainBoard Member

    52
    33
    6
    Good, the first step is to establish the communication. At least, you reveice information from the Arduino.
    The next step is to send your commands. You should modify the comboBox at the bottom of the console Window to set the line ending characters. You have the choice between 'No line ending', 'Newline', 'Carriage Return' or 'Both NL and CR'. Try all the last three alternatively, you should find the right one !
     
    Scott Eric Catalano likes this.
  5. Rob H

    Rob H TrainBoard Member

    22
    15
    2
    Thanks again, I'm slowly getting there, now able to turn the power on and off using the <1> and <0> commands, the LEDs on the motor shield yurn on and off as they should and I get the <p1> and <p0> messages back from the DCC++ base station. However for some reason the <D> command doesn't seem to work, not sure why.
     
    Scott Eric Catalano likes this.
  6. Keith Ledbetter

    Keith Ledbetter TrainBoard Member

    279
    195
    12
    Did you make sure your jumper pins are correct? They are outdated in the videos but correct in the GitHub pinout.
     
    Scott Eric Catalano likes this.
  7. Rob H

    Rob H TrainBoard Member

    22
    15
    2
    It works!

    Turns out to be a combination of wrong jumper wire as Keith pointed out and a dodgy decoder chip on one of my locomotives. Good thing about this time of year is plenty of time to work on projects bad thing is the local model shop is closed so I can’t pop out and get parts.


    Sent from my iPhone using Tapatalk
     
    Scott Eric Catalano likes this.

Share This Page