Idea: using shift-registers for additional inputs, and outputs.

Travis Farmer Mar 3, 2018

  1. Travis Farmer

    Travis Farmer TrainBoard Member

    352
    320
    14
    Scott Eric Catalano and Atani like this.
  2. Travis Farmer

    Travis Farmer TrainBoard Member

    352
    320
    14
    (16-bit I/O) X (8 addresses) X (8 I2C multiplexed ports) = 1024 I/O pins. double that if your ESP32 has two I2C ports. :eek:

    ~Travis
     
    Scott Eric Catalano and Atani like this.
  3. sachsr1

    sachsr1 TrainBoard Member

    60
    23
    5
    Here's some info on shift registers working on Arduino. It's based on CMRI, and it plays well with JMRI. I use the nodes on my layout, but I decided to use more nodes rather than expand the outputs and inputs.
    http://www.utrainia.com/tag/cmri
     
    Scott Eric Catalano likes this.
  4. Travis Farmer

    Travis Farmer TrainBoard Member

    352
    320
    14
    i have banged together a library for multiple MCP23017s, based on the adafruit library. it is here: https://github.com/travisfarmer/tjf_mcp23017, for anyone interested. i haven't finished the comments and documentation, but it compiles (i don't have the hardware to verify it yet. feel free to test if you happen to have one or more MCP23017).

    i think i have moved past shift-registers, but i will take a look when i get a minute. thanks for the info.

    ~Travis
     
    Scott Eric Catalano and Atani like this.
  5. Atani

    Atani TrainBoard Member

    1,466
    1,736
    37
    The i2c multiplexers are pretty cool things for sure.

    I thought the mcp chip you could control individually the pins to be input or output. There are a few libraries out there for it and some allow that level of control. I haven't tested it yet to confirm though.

    I'll check out your library and see if it works for the esp32 as well, I imagine it will as long as it uses standard Arduino calls.

    Sent from my ONEPLUS A5010 using Tapatalk
     
    Scott Eric Catalano likes this.
  6. Travis Farmer

    Travis Farmer TrainBoard Member

    352
    320
    14
    Perhaps i miss-typed, you can control the pins individually.

    ~Travis
     
    Scott Eric Catalano and Atani like this.
  7. Travis Farmer

    Travis Farmer TrainBoard Member

    352
    320
    14
    I seem to have had an epiphany regarding inputs and outputs. from my own research and planning of my future layout (a real one, not just my circle test-track), for the average layout, is there really a need for more than 128 pins of I/O? perhaps if you have a lot of block-detection.

    my original plans were to control everything, but due to the epiphany, i can sub-group the tasks that are just scripted automation, to separate static scripted Arduinos. in other words, rather than controlling, say, all house/building lighting individually, i can group them together, and automate them with a possibly standalone arduino.

    i do tend to over-complicate my ideas, at times. ;)

    oh, i just ordered some MCP23017 from China, so in a month or two, i can test my library directly.

    ~Travis
     
    Scott Eric Catalano and Atani like this.
  8. Atani

    Atani TrainBoard Member

    1,466
    1,736
    37
    There is certainly a possible need for more than 128 IO pins, think of signals and block detection :) It can easily grow to really big numbers. But, as you have found, this can be segmented into groups and have a dedicated handler. I am looking at a few options on how to handle this for my layout, right now I am looking at using S88 to handle detection and then use MCP23017 for signals only. I will use one IO pin per signal (simple red/green logic) and split it so I can have east/west be inverse logic (red east, green west, etc) from that one pin.
     
    Scott Eric Catalano likes this.
  9. Travis Farmer

    Travis Farmer TrainBoard Member

    352
    320
    14
    Hmm, so if i alter the library a bit more, i can possible set it up for automatic control of an I2C multiplexer. in my library, a write (or read) to pin 0 auto-selects the first added MCP, pin 0. and if you perform a R/W to pin 16, it auto-selects the second added MCP, pin 0.
    it may be possible to auto select through a multiplexer. i will read the multiplexer datasheet, and see if it is an easy integration, as i think it is. presumably, if you want to read multiplexer port 1, MCP 0, pin 0, you would just read pin 129. and if you only have one set of 8 MCPs, it will just signal to read the multiplexer port 0, and if it is not attached, it will just perform transparently. at least that is my plan of attack. ;)

    ~Travis
     
    Scott Eric Catalano and Atani like this.
  10. Travis Farmer

    Travis Farmer TrainBoard Member

    352
    320
    14
    I just updated my MCP23017 library to support the use of a TCA9548A breakout from Adafruit: https://www.adafruit.com/product/2717
    it compiles, but not yet tested on hardware. it is still poorly documented, but the examples should give a rough idea of how to use it. I have also included support for it in my copy of the DCC++Arduino (my copy requires the library, even if not used. i am working on that...) as an example of how to possibly integrate it.

    I eagerly await delivery of my MCP23017 chips for testing, and i have not yet ordered a TCA9548A breakout from Adafruit yet. so i can't fully test the library, except "in theory" ;)

    keep in mind, my copy of DCC++Arduino is too large to run on an UNO, i think. i think this new library may be a touch heavy. ;)

    ~Travis
     
    Scott Eric Catalano likes this.
  11. WillemT

    WillemT TrainBoard Member

    55
    40
    7
    Thanks for that link. I downloaded and had a look. Problem is it is all online and I dislike that. It did however give me some ideas and I then started a Access database and entered all my current stock. What a pleasure to check if I have a certain value cap or resistor in either "Through Hole" or SMD. Now need to add project facilities. It provided the proverbial kick to do something (I am the worlds greatest procrastinator).

    Regards
    Willem.
     
  12. Travis Farmer

    Travis Farmer TrainBoard Member

    352
    320
    14
    Perhaps we are related. ;)

    as my laptop is nearing the end of it's useful life, i preferred the online version, in case of a hard-drive failure. my computer had a stroke a little while back, and i had to recover it from near scratch. since then, i have been doing regular off-laptop backups, just in case it happens again.

    ~Travis
     

Share This Page