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

    StickC - SH200Q Acceleration Range

    Micropython
    3
    8
    13.1k
    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.
    • Z
      zhufu86
      last edited by zhufu86

      How to init the acceleration range to 16g for Sh200q on StickC with the MicroPython code?

      Z 1 Reply Last reply Reply Quote 0
      • Z
        zhufu86 @zhufu86
        last edited by zhufu86

        @zhufu86

        I tried the code blow. But I don't know whether it is correct.

        from hardware import sh200q
        imu = sh200q.Sh200q(accel_fs=sh200q.ACCEL_FS_SEL_16G)
        
        Z K 2 Replies Last reply Reply Quote 0
        • Z
          zhufu86 @zhufu86
          last edited by

          @zhufu86 said in StickC - SH200Q Acceleration Range:

          imu = sh200q.Sh200q(accel_fs=sh200q.ACCEL_FS_SEL_16G)

          I tried the codes in the StickC and got the acceleration value four times as big as the value before. So I suppose SH200Q is initiated with 4g range if lack of accel_fs setting.
          For temporary solution I devide the returned acceleration value by 4.

            x = imu.acceleration[0]/4
            y = imu.acceleration[1]/4
            z = imu.acceleration[2]/4
          

          I also did some tests as below. No clue...

          >>> imu = sh200q.Sh200q()
          >>> imu._accel_so
          8192
          >>> imu.acceleration[2]
          0.995
          >>> imu = sh200q.Sh200q(accel_fs=sh200q.ACCEL_FS_SEL_16G)
          >>> imu._accel_so
          2048
          >>> imu.acceleration[2]
          4.058
          >>> imu.acceleration[2]/4
          0.9985
          >>> imu._accel_so=8192
          >>> imu.acceleration[2]
          0.999
          >>>
          
          Z 1 Reply Last reply Reply Quote 0
          • Z
            zhufu86 @zhufu86
            last edited by

            @zhufu86 said in StickC - SH200Q Acceleration Range:

            imu._accel_so=8192

            Update...
            No matter how I initiate SH200Q, I can not get the range larger than 4g.
            Need more investigation.

            Z 1 Reply Last reply Reply Quote 0
            • Z
              zhufu86 @zhufu86
              last edited by zhufu86

              @zhufu86

              Finally, I had it solved.

              It seems I need to write the correct configuration into the SH200Q register manually.

              0_1559615580846_8a54c136-0046-4424-b9d2-026b230adbd8-image.png

              Here is how to....

              MicroPython ESP32_LoBo_v3.2.24 - 2018-09-06 on M5Stack with ESP32
              Type "help()" for more information.
              >>> from hardware import sh200q
              >>> imu = sh200q.Sh200q(accel_fs=sh200q.ACCEL_FS_SEL_16G)
              >>> imu.acceleration[0]
              4.332
              >>> imu.i2c.readfrom_mem(108,0x16,1)
              b'\x10'
              >>> imu.i2c.writeto_mem(108,0x16,'\x12')
              1
              >>> imu.acceleration[0]
              1.086
              >>>
              

              Is it a bug in module "hardware.sh200q"?

              1 Reply Last reply Reply Quote 0
              • H
                heybin
                last edited by

                @property
                def acceleration(self):
                    so = self._accel_so
                    data = self._regThreeShort(0x00)
                    return tuple([round(value / so, 3) for value in data])
                

                output data is not raw data, and ACCEL_FS_SEL_16G only measuring range, does not affect the value of acceleration

                1 Reply Last reply Reply Quote 0
                • H
                  heybin
                  last edited by

                  I know, it a bug..., will fix it

                  1 Reply Last reply Reply Quote 0
                  • K
                    khz @zhufu86
                    last edited by

                    @zhufu86 Hey, I came along to look for python support for the sh200q. Seems that you use it in python with the hardware module.
                    May sound stupid but I'm unsure where to find the module... (Very new to m5Stick / m5Stack) I am using the m5Stick.

                    Best regards,
                    klaas

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