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

    The range of values from an ANGLE between directly connected to PORT B and connected to PORT A via PbHUB is different

    Units
    2
    3
    3.7k
    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.
    • K
      kotobuki
      last edited by

      Hi,

      I'm testing my PbHUB with my M5GO and ANGLE, and I have a question.

      When I connect the ANGLE to port B of the M5GO, the range of values from the ANGLE is between 0 and 4095.

      However, when I connect the ANGLE to port A via the PbHUB of the M5GO, the range of values from the ANGLE is between 15 and 745 (when connected to between ch0 and ch3) or 0 and 715 (when connected to between ch4 and ch5).

      I confirmed with both Arduino and UIFlow. Is this normal, or my PbHUB seems to be broken?

      from m5stack import *
      from m5ui import *
      from uiflow import *
      import time
      import unit
      
      setScreenColor(0x222222)
      pbhub0 = unit.get(unit.PBHUB, unit.PORTA)
      
      label0 = M5TextBox(10, 10, "Text", lcd.FONT_DejaVu18, 0xFFFFFF, rotate=0)
      
      while True:
        label0.setText(str((str('ANGLE: ') + str((pbhub0.analogRead(0))))))
        wait_ms(100)
        wait_ms(2)
      

      Best,
      Shigeru

      1 Reply Last reply Reply Quote 0
      • m5stackM
        m5stack
        last edited by

        of cause, they are different IC to read the raw ADC.

        Pbhub use mage328

        PortB use ESP32 built-in ADC

        ESP32 and mega328 has different ADC resolution

        1 Reply Last reply Reply Quote 0
        • K
          kotobuki
          last edited by

          @m5stack said in The range of values from an ANGLE between directly connected to PORT B and connected to PORT A via PbHUB is different:

          ESP32 and mega328 has different ADC resolution

          Thank you very much for your reply.

          Yes, the ADC module on mega328 has a 10-bit resolution, whereas ESP32 has a 12-bit resolution. If this issue is just a resolution issue, the result should be 0 - 1023 instead of 15 - 745 or 0 - 715. If nobody can reproduce this issue, the PbHUB may be broken...

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