Suggestion to improve the MPU6050 driver

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
mackowiakp
Normal user
Posts: 527
Joined: 07 Jun 2018, 06:47
Location: Gdynia/Poland

Suggestion to improve the MPU6050 driver

#1 Post by mackowiakp » 02 May 2022, 04:53

At the moment, MPU6050 motion detection works in such a way that the statement that motion has occurred is based on the finding that activation has occurred in ALL enabled axes.
In the case of a washing machine, it turns out that it is better to check that the stimulation occurred in ANY axis.
I wrote a script to implement this using rules. It works much better than the original motion detection included in the driver.
My suggestion is that there should be, for example, a checkbox toggling between ANY/ALL axes.
Below is a proposition of the driver part _P045_MPU6050.ino for a function that executes ANY instead of ALL axes.

Code: Select all

 boolean thresexceed = false;  // changed from true to false
            uint8_t    count       = 0; // Counter to check if not all thresholdvalues are set to 0 or disabled

            for (uint8_t i = 0; i < 3; i++)
            {
              // for each axis:
              if (PCONFIG(i + 2) != 0) { // not disabled, check threshold
                if (P045_data->_axis[i][2] > PCONFIG(i + 2)) { thresexceed = true; } // changed < to > and false to true
              } else { count++; }        // If disabled count + 1
            }
	    // the line below is not necessary now
            if (count == 3) { thresexceed = false; } // If we counted to three, all three axis are disabled.

            // If ANY (not all) enabled thresholds are exceeded the increase the counter
            if (thresexceed) { PCONFIG_LONG(0)++; }


mackowiakp
Normal user
Posts: 527
Joined: 07 Jun 2018, 06:47
Location: Gdynia/Poland

Re: Suggestion to improve the MPU6050 driver

#3 Post by mackowiakp » 02 May 2022, 11:20

THX

User avatar
Ath
Normal user
Posts: 3416
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Suggestion to improve the MPU6050 driver

#4 Post by Ath » 06 May 2022, 08:45

I have created a pull request #4042 with the intention to implement this request. You can download from the Github Actions build for testing. Please report your findings ;)
/Ton (PayPal.me)

mackowiakp
Normal user
Posts: 527
Joined: 07 Jun 2018, 06:47
Location: Gdynia/Poland

Re: Suggestion to improve the MPU6050 driver

#5 Post by mackowiakp » 06 May 2022, 11:41

OK. Will try next weekend. Now I am in a humanitarian convoy to the hospital in Winnica (Vinnitsa)/Ukraine.
Hope will be back alive Thursday evening.

User avatar
Ath
Normal user
Posts: 3416
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Suggestion to improve the MPU6050 driver

#6 Post by Ath » 06 May 2022, 14:23

mackowiakp wrote: 06 May 2022, 11:41 Now I am in a humanitarian convoy to the hospital in Winnica (Vinnitsa)/Ukraine.
Good luck :!:
/Ton (PayPal.me)

mackowiakp
Normal user
Posts: 527
Joined: 07 Jun 2018, 06:47
Location: Gdynia/Poland

Re: Suggestion to improve the MPU6050 driver

#7 Post by mackowiakp » 06 May 2022, 15:33

We say "You are shooting or they are shooting at you - what's the difference? The same bang" :)

User avatar
Ath
Normal user
Posts: 3416
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Suggestion to improve the MPU6050 driver

#8 Post by Ath » 05 Jul 2022, 12:59

Any update on testing this request (and possibly your 'trip' to Ukraine :o)?
/Ton (PayPal.me)

mackowiakp
Normal user
Posts: 527
Joined: 07 Jun 2018, 06:47
Location: Gdynia/Poland

Re: Suggestion to improve the MPU6050 driver

#9 Post by mackowiakp » 05 Jul 2022, 16:32

I was 3 times in Ukraine so I have not time to test FW. Will do it ASAP.

sobolkz
Normal user
Posts: 37
Joined: 12 Sep 2019, 16:30

Re: Suggestion to improve the MPU6050 driver

#10 Post by sobolkz » 05 Jul 2022, 20:33

mackowiakp wrote: 05 Jul 2022, 16:32 I was 3 times in Ukraine so I have not time to test FW. Will do it ASAP.
So, I'm from Kazakhstan, I'm looking about loosing Ukrainian independent, what about topic state?
Let`s don`t politise this forum.

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 20 guests