DCC++ Update Project 2020

FlightRisk Feb 16, 2020

  1. KC Smith

    KC Smith TrainBoard Member

    109
    111
    12

    David,

    I followed the link to google meet and joined but it did not connect to your meeting . I was the only one there as K .
    I added some items to the Topics Standards * Pin Links to DCC++, to the top of Trainboard thread and having discussions in the threads periodically being more verbose.

    regards
    Kevin
     
    Last edited: Jun 1, 2020
  2. David Cutting

    David Cutting TrainBoard Member

    62
    29
    3
    Sorry, please use the link from my latest post and not that link.
     
  3. KC Smith

    KC Smith TrainBoard Member

    109
    111
    12
    Dex, & Atani,

    Regarding LCD display on a Command Station.
    Is DCC++ EX ver 2.1.1 able to utilize a Liquid Crystal Display LCD PCF8574T on a Arduino Uno yet?

    I've downloaded and included Library;
    LiquidCrystal_PCF8574

    In config.h, I've undocumented it to include;
    #define ENABLE_LCD
    #ifdef ENABLE_LCD
    #define LIB_TYPE_PCF8574

    I connected the LCD PCF8574 to the Uno;
    Gnd to Gnd
    VCC to 5vdc
    SDA to SDA or A4
    SCL to SCL or A5

    I compiled and uploaded with no errors.

    The LCD is powered up but does not display commands.

    I then pinned A2 to Gnd rebooted and it shows.

    *** DCC++ EX CONFIGURATION May 18 2020***

    VERSION: 2.1.1
    COMPILED: Jun 1 2020 16:17:08
    ARDUINO: UNO

    MOTOR SHIELD: ARDUINO MOTOR SHIELD

    DCC SIG MAIN: 10
    DIRECTION: 12
    ENABLE: 3
    CURRENT: 14

    DCC SIG PROG: 5
    DIRECTION: 13
    ENABLE: 11
    CURRENT: 15

    NUM TURNOUTS: 0
    SENSORS: 2 { I set D2 and D4 as sensors earlier via <S # # 1> command}
    { along with A2 - A5 as sensors earlier, but since removed them via the <S #> command and
    then <E> to clear EEStore Before I tried to set up and install the PCF8574}
    OUTPUTS: 0

    INTERFACE(s):
    Hardware Serial - Speed:115200

    PROGRAM HALTED - PLEASE RESTART ARDUINO


    I rebooted and Sent a <D> command to verify EX code and the motor shield and all the Led's on Prog & Main blink just fine..

    Sorry for the long simpleton questions but am I missing something really simple here?

    Regards,
    Kevin
     
  4. Atani

    Atani TrainBoard Member

    1,460
    1,697
    36
    Yes it should work. I haven't tested it in a very long time but looking at the code it looks correct still. Can you double check in Config.h that you have the right I2C address for the LCD? Upon startup it should be initialized before anything else and display version details etc as it starts up.
     
  5. Jack Regan

    Jack Regan TrainBoard Member

    22
    12
    2
    Question. I have installed the DCCppex on a mega 2560 and going to hook a Pololu 33926 motor board to it. Right not the configuration has the Enable Pin Main set for pin 9. Can I change that and make it pin 6 so I can use 9 for another application?
     
  6. KC Smith

    KC Smith TrainBoard Member

    109
    111
    12
    It looks like the default in config.h is automatically set as 0x3F
    I'm not sure where else I need to set an address..??

    #define ENABLE_LCD

    #ifdef ENABLE_LCD
    #define LIB_TYPE_PCF8574

    // #define LIB_TYPE_I2C
    // This defines the I2C address for the LCD device
    #define LCD_ADDRESS 0x3F

    // This defines the number of columns the LCD device has
    #define LCD_COLUMNS 16

    // This defines the number of lines the LCD device has
    #define LCD_LINES 2
    #endif

    Thanks for your help,
    K

    Second test; Just for fun and to see what would happen
    I changed LIB_TYPE, I commented out the # define LIB_TYPE_PCF8574
    Then included # define LIB-TYPE_I2C
    Then down loaded & Included the LiquidCrystal_I2C library

    upon compiling I got this error in the DCCppEX tab:

    #ifdef ENABLE_LCD
    bool lcdEnabled = false;
    #ifdef LIB_TYPE_PCF8574
    LiquidCrystal_PCF8574 lcdDisplay(LCD_ADDRESS);
    #elif LIB_TYPE_I2C
    LiquidCrystal_I2C lcdDisplay(LCD_ADDRESS);
    #endif
    #endif

    DCCppEX:188:21: error: #elif with no expression
    #elif LIB_TYPE_I2C
    ^
    exit status 1
    #elif with no expression
     
    Last edited: Jun 2, 2020
  7. Atani

    Atani TrainBoard Member

    1,460
    1,697
    36
    Can you run an I2C scan sketch to confirm the address, not all are 0x3F unfortunately.
     
  8. KC Smith

    KC Smith TrainBoard Member

    109
    111
    12
    Atani,

    Thanks for asking ... now I've Learned how to find, download, compile upload and run a I2C scanner sketch. :^)

    Results;
    I2C Address Scanner. Scanning ...
    Found i2c Device Address: 39 (0x27)
    Done.
    Found 1 device(s).

    I changed it back to LIB_TYPE and Address to 0x27 in config.h ; and added the library comments;

    #define ENABLE_LCD
    #ifdef ENABLE_LCD
    // This defines the library type LCD device LiquidCrystal_PCF8574T
    #define LIB_TYPE_PCF8574
    // This defines the library type LCD device LiquidCrystal_I2C
    // #define LIB_TYPE_I2C
    // This defines the I2C address for the LCD device
    #define LCD_ADDRESS 0x27
    // This defines the number of columns the LCD device has
    #define LCD_COLUMNS 16
    // This defines the number of lines the LCD device has
    #define LCD_LINES 2

    Compiled and up loaded DC++EX 2.1.1 to the Uno.

    Result; No activity on the LCD. The Serial Monitor works fine

    Sorry for the interruption, I didn't know this was going to be a wth?

    Regards,
    Kevin

    FYI This is the device I'm trying to set up.

    LCD Display 16x2 HD44780 1602+IIC/I2C PCF8574T
     
    Last edited: Jun 2, 2020
  9. FlightRisk

    FlightRisk TrainBoard Member

    548
    237
    14
    I hope something didn't change in the library. I'll test it too. I have some 2 line and 4 line displays
     
  10. FlightRisk

    FlightRisk TrainBoard Member

    548
    237
    14
    Mani and KC Smith like this.
  11. Atani

    Atani TrainBoard Member

    1,460
    1,697
    36
    Where are these defines coming from, they are not part of the library that I was using for the LCD communication... https://github.com/mathertel/LiquidCrystal_PCF8574
     
  12. KC Smith

    KC Smith TrainBoard Member

    109
    111
    12
  13. Atani

    Atani TrainBoard Member

    1,460
    1,697
    36
    No worries, this is one area that needs to be documented better. With the PlatformIO files it was automatically handled and picked the right library every time. The other one you have used likely would work if you set it up for I2C.
     
  14. FlightRisk

    FlightRisk TrainBoard Member

    548
    237
    14
    Hi guys, there are references to different libraries. Mike, check the development branch.

    https://github.com/DCC-EX/BaseStation-EX/blob/development/DCCpp_EX/DCCppEX/DCCppEX.h

    There is an ifdef there to test the I2C library. So Config.h and DCCppEX.h are set so you can swap out the 2 drivers based on your display. That's not fully tested so it could be something wrong with the ifdefs or a different version of the library from Matthias
     
  15. KC Smith

    KC Smith TrainBoard Member

    109
    111
    12
    Problem Solved
    I down loaded a test LCD sketch which finds the LCD
    But the LCD didn't display anything .... Guess Why ???

    upload_2020-6-1_22-32-45.png

    Good Guess;
    When I turned the Potentiometer on the back of the LCD a 1/4 turn to the right it Displayed 'Hello there you dummy'

    I reloaded DCC++ EX and it all works fine... LCD displays "DCC++ EX v2.1.1 Serial: Ready"

    SO Two things to fix this:
    I2C Scan sketch the ports for the address which I changed in config.h from 0x3F (63) to 0x27 (39)
    Test LCD sketch and turn the Potentiometer to change the contrast on the display.

    You are a Genius Atani among wanna Be's..
    Thanks for helping me find out that If things can go wrong in the factory they will ship them out anyway.

    Kind Regards,
    Kevin
     
    Last edited: Jun 2, 2020
  16. Atani

    Atani TrainBoard Member

    1,460
    1,697
    36
    For ESP32-CS I opted for taking the guess work on the address out of the equation for the end-user. The code does a scan of known address ranges and once it finds a display it interrogates it before using it. The interrogation part is mostly for OLED displays, for LCDs there is a way to do this but I opted not to pursue it at this time. There are also better libraries out there than the original one I had used in the DCC++ code (prior to it becoming DCC++EX).
     
  17. Jack Regan

    Jack Regan TrainBoard Member

    22
    12
    2
    Just FYI, yesterday I received a Raspberry Pi ver 4 which I was going to try to get jmri going on and connect to a Mega2560. I uploaded Steve Todd's JMRI Boot Loader to a TF Card and placed in the Raspberry. It uploaded perfect and such. I was able to connect my Kindle Fire to the network. Engine Driver fired right up. I was even able to upload turnouts. The problem is that it does not seem to be communicating with the mega. I am working directly with Steve so the jmri code can be updated to automatically discover the DCC++ on the mega and correctly set up communication.
     
  18. FlightRisk

    FlightRisk TrainBoard Member

    548
    237
    14
    I've tried a couple if I2C libraries and they all work. We can even scroll the display if wanted ;) What we need is pretty basic, a 2 line or 4 line display that just prints simple text. Size would be important for the Uno. Mike, you mentioned you think there are better choices. So you or anyone have a recommendation for a different one to use? I *think* the HD44780 library. Pretty impressive. Automatically detects the display address and you can even read from the display. But it may be large with all the functions it supports. There is NEW liquidcrystal from Francisco Malpartida, and Liquidcrystal I2C. The Arduinio Master I2C library is only 140 bytes, but I haven't looked at if anything needs to be added or changed. I won't live long enough to look at all the options and compare code ;)
     
    Last edited: Jun 2, 2020
  19. FlightRisk

    FlightRisk TrainBoard Member

    548
    237
    14
    What doesn't see the Mega/DCC++? Can you elaborate which connection is not being made? Is it JMRI sending codes to DCC++ EX or using Wifi? I have the same setup as you mention and as long as the Mega is working (correct jumpers, etc.), and you tell JMRI to use DCC and go into the window to select all the round radio button looking buttons to used DCC++ EX, everything just worked for me.

    I have been wanting to find a script way to use the default local network away from home and carry a router and switch to my home network when home. It is easy to disable the local network setup and have it discover a network, but not as easy to set it back. On a PC I could just have a batch file to switch between setups. So I have more to learn about networking on the Pi so I do this. On the other hand, a want is different than a need. The chance I would actually want to travel with my setup is pretty slim ;)
     
  20. Jack Regan

    Jack Regan TrainBoard Member

    22
    12
    2
    I have the raspberry connected to the usb port of the mega and a raspberry usb port. In the DCCppEx I have the on board serial port selected. I am trying to use Engine driver and it's auto config and identify. Fo some reason it did not pick up dcc++ on the mega. Working with Steve on that and he will upgrade engine driver to respond and install correctly for dcc++ on the raspberry using a mega
     

Share This Page