• Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Iterate through UniPi1 digital IN/OUTs

    Mervis
    2
    5
    447
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • C
      CKB last edited by

      Hi,

      I want to operate a 4x4 switch matrix with the UniPi1

      digital IN/OUT 1-4: matrix rows 1-4
      digital IN/OUT 5-8: matrix columns 1-4

      I want to iterate now through the digital_IO 1-4, so to check the switch status of each row by reading digital_IO 5-8.

      My simple question is: how to code this in ST??
      I mean, how to call the unipi digital_IO using a variable?

      Thanks a lot for support!

      Martin Kudláček 1 Reply Last reply Reply Quote 0
      • Martin Kudláček
        Martin Kudláček @CKB last edited by

        Hi @ckb,
        this is not possible, since digital inputs are only inputs, not outputs. For scanning switch matrix, you need to apply voltage to each column separately, and then read rows (or vice versa). Theoretically it can be done with relay outputs (4 ROs to columns, 4 DIs to rows), but relays are really not the right components for this type of application.

        If you know a bit of electronics, try looking into this: https://www.eleccircuit.com/16-key-encoder-using-ic-74c922n/

        Reading the BCD code in FBD or ST is a piece of cake.

        Best regards,
        Martin

        C 2 Replies Last reply Reply Quote 0
        • C
          CKB @Martin Kudláček last edited by

          @martin-kudláček

          Thanks for reply and for the link!
          I assumed the digital INs could also act as OUTs.. pitty.. :/

          Do you know if there's any product that I can buy of the shelve or a product that uses the I2C? It's just a time issue...

          1 Reply Last reply Reply Quote 0
          • C
            CKB @Martin Kudláček last edited by

            @martin-kudláček

            I found a capacitive keypad here: https://www.robotshop.com/uk/16-button-capacitive-keypad-module.html
            and a module that can connect the keypad via I2C here: https://www.robotshop.com/uk/16-keys-capacitive-touch-ttp229-i2c-module.html

            Before I buy it - can UniPi1 cope with this?

            Thanks
            CB

            Martin Kudláček 1 Reply Last reply Reply Quote 0
            • Martin Kudláček
              Martin Kudláček @CKB last edited by

              @ckb

              It can be theoretically connected to the UniPi 1.1, you will not get it working directly in the Mervis. Mervis doesn't have any support for custom I2C devices. You would have to write some I2C - Modbus bridge in Python for example.

              1 Reply Last reply Reply Quote 0
              • First post
                Last post