🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Connecting multi TOF4m units via PA.hub - weird behaviour

    Units
    6
    15
    1.6k
    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.
    • S
      sqbaczek @felmue
      last edited by

      Greetings @felmue!
      Thank you for your reply,
      Even if I space apart both sensors and direct them in different spots - they still get weird readings. As soon as I disconnect one of them from pa.hub one label gets proper readings - and other gets very simillar reading to first label (even though it is linked with disconnected sensor).
      Below screenshot of readings with one sensor disconnected from pa.hub - and both labels change as soon as I get some object near the connected sensor.

      462582190_1192320768525964_4002535964587001502_n.jpg

      For UIflow 1 code is:

      from m5stack import *
      from m5ui import *
      from uiflow import *
      import time
      import unit
      
      
      setScreenColor(0x222222)
      tof4m_0 = unit.get(unit.TOF4M, unit.PAHUB0)
      tof4m_1 = unit.get(unit.TOF4M, unit.PAHUB2)
      
      
      
      
      
      
      label0 = M5TextBox(43, 36, "label0", lcd.FONT_Default, 0xFFFFFF, rotate=0)
      label1 = M5TextBox(45, 88, "label1", lcd.FONT_Default, 0xFFFFFF, rotate=0)
      
      
      while True:
        label0.setText(str((str('odl 1 ') + str(((str(((tof4m_0.get_single_distance_value) / 10)) + str('cm')))))))
        label1.setText(str((str('odl 2 ') + str(((str(((tof4m_1.get_single_distance_value) / 10)) + str('cm')))))))
        wait_ms(500)
        wait_ms(2)
      

      When I try to run it on UIflow 2.0 with pa.hub I get error:

      Traceback (most recent call last):
      File "<stdin>", line 29, in <module>
      File "<stdin>", line 20, in setup
      File "driver/vl53l1x.py", line 60, in init
      File "driver/vl53l1x.py", line 176, in get_model_info
      File "driver/vl53l1x.py", line 273, in _read_register
      TypeError: unexpected keyword argument 'addrsize'

      This is my code for uiflow 2 - and it does not work

      import os, sys, io
      import M5
      from M5 import *
      from hardware import *
      from unit import TOF4MUnit
      from unit import PAHUBUnit
      
      
      
      label0 = None
      label1 = None
      i2c1 = None
      pahub_0 = None
      tof4m_2 = None
      tof4m_0 = None
      
      
      def setup():
        global label0, label1, i2c1, pahub_0, tof4m_2, tof4m_0
      
        M5.begin()
        Widgets.fillScreen(0x222222)
        label0 = Widgets.Label("label0", 44, 65, 1.0, 0xffffff, 0x222222, Widgets.FONTS.DejaVu18)
        label1 = Widgets.Label("label1", 43, 111, 1.0, 0xffffff, 0x222222, Widgets.FONTS.DejaVu18)
      
        i2c1 = I2C(1, scl=Pin(22), sda=Pin(21), freq=100000)
        tof4m_0 = TOF4MUnit(PAHUBUnit(i2c=i2c1, channel=1), 0x29)
        tof4m_2 = TOF4MUnit(PAHUBUnit(i2c=i2c1, channel=0), 0x29)
      
      
      def loop():
        global label0, label1, i2c1, pahub_0, tof4m_2, tof4m_0
        M5.update()
        label0.setText(str((str('Odl1 ') + str((tof4m_2.get_distance)))))
        label0.setText(str((str('Odl2 ') + str((tof4m_0.get_distance)))))
      
      
      if __name__ == '__main__':
        try:
          setup()
          while True:
            loop()
        except (Exception, KeyboardInterrupt) as e:
          try:
            from utility import print_error_msg
            print_error_msg(e)
          except ImportError:
            print("please update to latest firmware")
      
      

      Thank you for help,
      best,
      Matt

      felmueF E 2 Replies Last reply Reply Quote 0
      • felmueF
        felmue @sqbaczek
        last edited by

        Hello @sqbaczek

        unfortunately I don't have the proper hardware, e.g. TOF4m unit, so I cannot test this myself. Sorry.

        BTW: are you aware that in UIFlow1 you use PaHUB channel 0 and 2 and in UIFlow2 you setup PaHUB channel 0 and 1.

        Thanks
        Felix

        GPIO translation table M5Stack / M5Core2
        Information about various M5Stack products.
        Code examples

        S 1 Reply Last reply Reply Quote 0
        • S
          sqbaczek @felmue
          last edited by

          Hi @felmue,
          thanks for response - yes I have tried different ports on PA.hub so between two uiflows sensors might have different port values.

          best,

          kurikoK 1 Reply Last reply Reply Quote 0
          • kurikoK
            kuriko @sqbaczek
            last edited by

            @sqbaczek
            I think this might be some weird hardware problem, like a damaged component in the PaHUB causing the transmitted information to be incorrect... etc. Maybe the best way is to find a working one to test it.

            Good morning, and welcome to the Black Mesa Transit System.

            1 Reply Last reply Reply Quote 0
            • E
              Elliptic3612 @sqbaczek
              last edited by

              Greetings everyone! I have very similar error as @sqbaczek when running 1 ToF4M via PaHUB2 with CoreS3 and also Cardputer on UIflow 2.0. The ToF4M works fine when directly connected to the I2C port of either CoreS3 or Cardputer. It appears that ToF4M cannot be initiated when connected via PaHUB2 on UIflow 2.0.

              Below is the error I get with CoreS3 when on UIflow 2.0:

              Traceback (most recent call last):
                File "<stdin>", line 24, in <module>
                File "<stdin>", line 17, in setup
                File "driver/vl53l1x.py", line 60, in __init__
                File "driver/vl53l1x.py", line 176, in get_model_info
                File "driver/vl53l1x.py", line 273, in _read_register
              TypeError: unexpected keyword argument 'addrsize'
              

              Below is my code on UIflow 2.0:

              import os, sys, io
              import M5
              from M5 import *
              from hardware import *
              from unit import TOF4MUnit
              from unit import PAHUBUnit
              
              
              
              label0 = None
              i2c0 = None
              pahub_0 = None
              tof4m_0 = None
              
              
              def setup():
                global label0, i2c0, pahub_0, tof4m_0
              
                M5.begin()
                Widgets.fillScreen(0x222222)
                label0 = Widgets.Label("label0", 0, 0, 1.0, 0xffffff, 0x222222, Widgets.FONTS.DejaVu18)
              
                i2c0 = I2C(0, scl=Pin(1), sda=Pin(2), freq=100000)
                tof4m_0 = TOF4MUnit(PAHUBUnit(i2c=i2c0, channel=0), 0x29)
              
              
              def loop():
                global label0, i2c0, pahub_0, tof4m_0
                M5.update()
                label0.setText(str(tof4m_0.get_distance))
              
              
              if __name__ == '__main__':
                try:
                  setup()
                  while True:
                    loop()
                except (Exception, KeyboardInterrupt) as e:
                  try:
                    from utility import print_error_msg
                    print_error_msg(e)
                  except ImportError:
                    print("please update to latest firmware")
              

              I tested other units via PaHUB2 with CoreS3 on UIflow 2.0. These include Gesture Unit, 8Servos Unit, ENV Pro Unit, EXT.IO2 Unit. They all appear to work fine, at least not showing any initiation error.

              S 1 Reply Last reply Reply Quote 0
              • S
                SB12345 @Elliptic3612
                last edited by

                Hello,

                My first post here. Came across this thread googling.

                I can recreate this problem, it has been driving me crazy. I have tried 2 different PAHubs to ensure that isn't the issue. Can confirm the same issue arises with both. I bought the PAHub as it claimed it could handle 2 devices with the same I2C address across different ports, but something strange is occurring.

                IMG_20241117_200450.jpg

                I have ToF4m sensors affixed 90 deg to each other, and attached to port A of a Core2 via the PAHub.

                Either ToF4m works fine when it is the only unit connected to the Core2.

                When both are connected via the PAHub, the results seem to interfere with each other. Particularly, a zero reading on one sensor always leads to a zero on the other. Also, the readings go from being stable and consistent to very noisy indeed - errors of up to 1m. I do not believe this is a laser intereference issue as if I cover one sensor, and point the other to clear air with no object for 3m, I still get a reading of 0 from both sensors.

                I am also unable to initiate ToF4M when connected via PaHUB2 on UIflow 2.0, and have had to revert to 1.0 to perform these tests.

                This has cost me a lot of time, and sadly I am unable to offer a solution at this time but I watch this thread with interest.

                Edit to add:

                If I remove one of the ToF4M modules whilst the program is running, both labels continue to update with results, further leading me to believe this is an address collision issue rather than a laser interference issue.

                felmueF 1 Reply Last reply Reply Quote 0
                • felmueF
                  felmue @SB12345
                  last edited by

                  Hi guys

                  BTW: TOF4m allows to change its I2C address (using set I2C address block in UIFlow2) so you could change the I2C address of one TOF4m, then connect both using a passive hub. This would take PaHub out of the equation.

                  Thanks
                  Felix

                  GPIO translation table M5Stack / M5Core2
                  Information about various M5Stack products.
                  Code examples

                  S 1 Reply Last reply Reply Quote 0
                  • S
                    SB12345 @felmue
                    last edited by

                    @felmue Tried this. I could not get the address change to 'stick' after a power cycle, but perhaps I'm missing something. I did this using UIFlow2.

                    felmueF 1 Reply Last reply Reply Quote 0
                    • felmueF
                      felmue @SB12345
                      last edited by

                      Hello @SB12345

                      ok, I see, hmm.

                      Have you tried to connect one TOF4m to port A and the other to port C and then setup two I2C busses?

                      Thanks
                      Felix

                      GPIO translation table M5Stack / M5Core2
                      Information about various M5Stack products.
                      Code examples

                      S 1 Reply Last reply Reply Quote 0
                      • S
                        SB12345 @felmue
                        last edited by

                        @felmue

                        Indeed yes, I get a port address error. I have a Core 2.

                        felmueF 1 Reply Last reply Reply Quote 0
                        • felmueF
                          felmue @SB12345
                          last edited by

                          Hello @SB12345

                          ok, have you tried to only connect one TOF4m to port C? Does that work?

                          Thanks
                          Felix

                          GPIO translation table M5Stack / M5Core2
                          Information about various M5Stack products.
                          Code examples

                          M 1 Reply Last reply Reply Quote 0
                          • M
                            matthewchan @felmue
                            last edited by

                            @felmue

                            I have the same issue.

                            I tried to only connect only ONE TOF4m to PA.HUB 2.1 then Port A.

                            I got " unexpected arguement 'addrsize' " when I init TOF4M

                            but if i change TOF4M to TOF, it works fine(the init funtion of TOF, not 4M version, has no argument, i.e. just init() )

                            1 Reply Last reply Reply Quote 0
                            • kurikoK
                              kuriko
                              last edited by

                              @Elliptic3612 @matthewchan @SB12345 @sqbaczek
                              We have fixed this problem, please wait for the next version of UiFlow2 firmware

                              Good morning, and welcome to the Black Mesa Transit System.

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