iNavFlight / inav

INAV: Navigation-enabled flight control software
https://inavflight.github.io
GNU General Public License v3.0
3.09k stars 1.46k forks source link

Massive error in i2c #724

Closed gendebeat closed 7 years ago

gendebeat commented 7 years ago

I flash the latest 1.3 RC2 , because the earlier have a problem to detect the magnetometer (BMP280) on my naze. i think this issue may be corrected. but now after 1 minute (aprox) the i2c error increase from 4 to a masive number (aprox +200 error per second) and Cycletime goes from 2000 to 11000. An of couse the FC freeze. thanks to all people who work to make inav/cleanfligth better

digitalentity commented 7 years ago

@brooksymike I've took my (working) Chinese cloned SPRacingF3 and measured pull-up resistors found on board - they are 1K. So it's possible that some cloned boards have actually random resistors which is causing issues.

Waltec commented 7 years ago

Konstantin,

Can you post a picture or description of where/how you did this? I'm not getting a clear picture of whether I should be adding resistors or removing them but I would like to be able to identify them.

Sent from my iPhone

On May 2, 2017, at 7:56 AM, Konstantin Sharlaimov notifications@github.com wrote:

@brooksymike I've took my (working) Chinese cloned SPRacingF3 and measured pull-up resistors found on board - they are 1K. So it's possible that some cloned boards have actually random resistors which is causing issues.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

peakhunt commented 7 years ago

I measured mine too and 1K pull-up was there.

brat002 commented 7 years ago

But why 1.3 version has worked fine?

brooksymike commented 7 years ago

Ok my issue has not gone. It appeared to be ok when connected to my Android phone (EZ-GUI) but now I'm connected to iNav the problems are still there, but different. I'm getting different things depending on which firmware I use. Some firmware greys out the "Calibrate Magnetometer". On others it will calibrate but the heading is wrong. On another the heading continually drifted. Today I took the top off the quad and laid the mag down. It was only then that I noticed that the board appears to be still using the internal compass rather than the external (even though the FC is set to HMC5883). The internal compass is reported as the AK8963 so I thought that I wouldn't need to cut traces to get the external one to work. I really have no clue what to do next. Any thoughts?

Waltec commented 7 years ago

How about disconnecting the external mag and testing with only internal. At least that way you've taken one potential conflict source out of if the equation.

Also, are you positive the internal compass is "active". You've probably seen this but to be sure, I've been tripped up in the past when I've mistaken gyro swings for compass indications.

Sent from my iPhone

On May 2, 2017, at 5:27 PM, brooksymike notifications@github.com wrote:

Ok my issue has not gone. It appeared to be ok when connected to my Android phone (EZ-GUI) but now I'm connected to iNav the problems are still there, but different. I'm getting different things depending on which firmware I use. Some firmware greys out the "Calibrate Magnetometer". On others it will calibrate but the heading is wrong. On another the heading continually drifted. Today I took the top off the quad and laid the mag down. It was only then that I noticed that the board appears to be still using the internal compass rather than the external (even though the FC is set to HMC5883). The internal compass is reported as the AK8963 so I thought that I wouldn't need to cut traces to get the external one to work. I really have no clue what to do next. Any thoughts?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

peakhunt commented 7 years ago

@brat002, not sure this is relevant for you but to sum it up,

as far as I2C error is concerned, in my experience so far, my presumed ( oh yeah I got hell lot of stuffs to talk about this from my pcb manufacturing experience but next time) faulty chinse SP Racing F3 clone works just fine up to 1.4. And there was a major rewrite on I2C bus driver since 1.5 and my clone stops working with default 400 Khz I2C clock speed.

So far, after I reduced the clock speed to 200 Khz, everything has been working fine although I am trying to sort out my toilet bowling issue ( I am narrowing it down to gps auto config issue but darn.... I broke one of my esc trying to wrap it with aluminum foil... so gotta wait a month for a new chinese one). I have never seen any I2C error for a week and all the blackbox log data looks just okay.

Waltec commented 7 years ago

peakhunt.

I used your firmware with the i2c clock change and while my mag, gps and baro all seemed to work I also got erratic gps hold performance and seemingly limited to non existent altitude hold performance.

Basically my quad would vaguely hover while drifting off ten or fifteen feet and then snapping back in the opposite direction as if the gps just noticed it had let the copter drift way out of position.

At that point I had pretty much run out of weekend and patience so choose to put the quad away.

I'm sure I'll get reinvigorated at some point but right now I'm considering admitting defeat and putting my apm 2.5 back in to do some mission flying.

I'm thinking that your modified firmware is the right path but that I've not got my copter set up properly. That being said, my F3 boards have never flown out of the box on inav like others say theirs have. The latter makes me wonder if these boards just have a ton of variability in their quality and we're all chasing similar issues that have different causes.

peakhunt commented 7 years ago

@Waltec, agree with you to some level. In my case altitude hold works pretty well after I put a small foam on top of barometer. When it comes to magnetometer, I am seeing about 30 degree deviation when I run the motors so I tried to shield the magnetometer and other components with some aluminum foil as suggested in the internet to no avail, which led me to one broken esc. I even changed location of my fc for minumum magnetic interference. Nothing worked so far.

From my pcb experience, I can say that chinese clones are cheap for a reason. Many times if you don't pay particular attention to some pcb traces during pcb manufacturing, you cannot achieve the full speed. Once this occurs in a massive manufacturing, we usually end up reducing clock speed since we can't just throw away tens of thousands of pcbs manufactured. Often times what worked perfectly on my dev platform suddenly stops working in manufacturing environment. As an engineer I've seen this so many times.

brooksymike commented 7 years ago

Regarding whether the FC is using the internal compass or not, I removed the external Gps/mag from the quad and rotated it whilst leaving the quad still. The heading did not change. Then I moved the quad and it does change. I believe the qyro measures rorational force but doesn't know which direction it's pointing so presumed that what I was seeing was the internal compass still being active? I'm thinking I will try and revert to the internal compass to check that works ok.

Waltec commented 7 years ago

I've not tried this but I expect it would work...grab a magnet that has reasonable strength (I suppose you could use a spare motor) and move it around the flight controller while you again have the gps module of to the side. I'm expecting you'll see compass movements that will verify the internal composed is active. Also do this to the gps module/puck to verify that mag is active ad well.

If you get swings on both when they're connected to the FC then of course there's your answer... Each mag is feeding the flight controller.

One other thing I'd try to verify is the orientation of the mag on the gps puck...you probably know this but they're not all the same. Often my mag chips are inverted and rotated 180 degrees which can be VERY confusing to sort out.

brooksymike commented 7 years ago

Ok I'll try this. Thanks for the suggestions. One question though - is it possible to have both the internal and external mags active (and working) at the same time?

Waltec commented 7 years ago

Do you mean working well together and giving a better or more reliable mag reading or do you mean both operating at the same time sending data to the flight controller?

I'm not qualified to answer the first option but my guess would be that the the software doesn't know how to handle two inputs at the same time. If youre asking the latter t think doing the magnet experiment will tell you if both mag chips are sending signals when you have the god puck connected. Hope that helps.

brooksymike commented 7 years ago

I meant whether the flight controller would be able to cope with two inputs at the same time, which I think it would not. When you select which compass you are using, I have read that you can connect the external and that somehow the FC can ignore the internal one even though it is still connected (only if the ext and internal compasses are different). This doesn't seem to be what's happening to me but I'll do further testing with a magnet. One thing I noticed tonight (after I disconnected external compass and selected correct internal compass), was that the compass was greyed out and wouldn't allow me to calibrate. Tried some different versions of firmware but it still failed but in different ways. More testing required! Might give up and try a different FC soon! Thanks for the suggestions.

Tops76 commented 7 years ago

I had the exact same probleme on my BG Omnibus F3 AIO clone. To resolve this issu I just added 1k pull up resistor on the SDA and SCL line (on the ublox 8 GPS).

Waltec commented 7 years ago

Is a pull up resistor a special type of resistor or is it a standard resistor put in place in a certain way to deliver the "pull up" function?

If you can take a photo of the installation and maybe provide a link to a resistor I can order in the U.S. I can probably sort the rest out myself.

All I know of resistors is to follow directions such as, "solder an x ohm resistor in line with x led to ensure the correct voltage."

So...any newbie direction you can provide would be much appreciated.

Sent from my iPhone

On May 25, 2017, at 12:56 PM, Tops76 notifications@github.com wrote:

I had the exact same probleme on my BG Omnibus F3 AIO clone. To resolve this issu I just added 1k pull up resistor on the SDA and SCL line (on the ublox 8 GPS).

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

DzikuVx commented 7 years ago

It;s a normal resistor. But I would not use 1kOhm. That is pretty low value. I'd begin with 4.7kOhm pullups

Waltec commented 7 years ago

Thx.

Sent from my iPhone

On May 25, 2017, at 3:31 PM, Paweł Spychalski notifications@github.com wrote:

It;s a normal resistor. But I would not use 1kOhm. That is pretty low value. I'd begin with 4.7kOhm pullups

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

Tops76 commented 7 years ago

Yes just a normal resistor. To calculate the right pull up resistor for I2C fast mode on 3v3 you can check this documentation : I2C Bus Pullup Resistor Calculation

For Fast-mode I2C communication with the following parameters, calculate the pullup resistor value. Cb = 200 pF, VCC = 3.3 V... Check page 4 Therefore, we can select any available resistor value between 966.667 Ω and 1.77 kΩ. The value of the pullup resistor can be selected based on the trade-off for the power consumption and speed.

DzikuVx commented 7 years ago

@Tops76 this is lowest possible pullup resistance that is still inside toleration of devices.

Tops76 commented 7 years ago

@DzikuVx Yes. With this value I had 0 I2C error during a 4h test but I will try a bigger value like 1k5 just to be safe. But I think 4k7 is to high for fast-mode and 3v3.

DzikuVx commented 7 years ago

PLease remember, that there already are pullups on FC. To overall resistance will be lower than that

Tops76 commented 7 years ago

You are right ! I will check thanks.

brooksymike commented 7 years ago

I'm sorry to say I've given up (with gps on this fc). I'll still use the quad but not as a gps build. I bought an APM 2.8 and a whole new frame (F450) and I'm in the middle of building this now. When I tested with the sp racing with pull up resistors it appeared to work but then started doing random things again. I've since confirmed the gps is definitely working as it works on the apm.

Waltec commented 7 years ago

Can't say I blame you. Was debating whether to bother with the pull up bit. I've a Pixhawk clone coming in the mail today. That is where I was landing. The whole debate about clone vs OEM boards was bugging me. In truth I think they all originate in China and even the "approved" vendors' boards got bad reviews.

If I try the pull up fix I'll post results here. Not a high priority though.

Sent from my iPhone

On May 26, 2017, at 12:11 PM, brooksymike notifications@github.com wrote:

I'm sorry to say I've given up (with gps on this fc). I'll still use the quad but not as a gps build. I bought an APM 2.8 and a whole new frame (F450) and I'm in the middle of building this now. When I tested with the sp racing with pull up resistors it appeared to work but then started doing random things again. I've since confirmed the gps is definitely working as it works on the apm.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

digitalentity commented 7 years ago

@brooksymike "working" doesn't necessarily mean "working reliably". APM has no hardware failure detection whatsoever, so you may find yourself in a very unplesant situation one day with that GPS module regardless of flight controller and firmware. I'd start RMA on that GPS module of yours.

I've found HMC5883 to be the most problematic compass sensor. MAG3110 is my current design choice - unfortunately they are not widely used...

GTorreil commented 7 years ago

I'm using MAG3110 as well, as an external compass on SP3 clone. Surprisingly, it works flawlessly , unlike the original on-board magnetometer (I completely removed it). 400KHz i2c is ok with this sensor.

peakhunt commented 7 years ago

okies. it's been so long. got a new ESC from china and had a chance to test. Moved my faulty flight controller away from PDB. I2C is still running at 200 KHz. Worked almost perfectly. Sometimes due to EMI on compass my quad was kinda circling in roughly 1 meter radius but mostly almost stayed still. Pretty much happy with it now.

Also I got another chinese SP Racing F3. This time I paid 6 dollars more for the embedded OSD. Just flashed iNav 1.7 and I2C is running at full speed with no error. Guess paying 5 bucks more pays off.

Cheers!

almln commented 7 years ago

Hi all. Like @Tops76 got the same problem with aliexpress Ublox NEO-M8N gps with integrated compass. There were a lot of i2c errors on my FC (F4 omnibus V3 pro clone). After i soldered pull-up 1K resistors to SCL-SDA wires all things go right. Cheers!

VictorBucha commented 7 years ago

After removing internal mag from my spracing f3 deluxe I have also been flooded by I2c errors with Ublox 8. I nothiced that in quadro mode there were no errors but when I changed to hexa - board got stuck with 600% CPU load. resistors did not help On inav 1.4 no errors but this version seem to neglect errors

VictorBucha commented 7 years ago

So I spent a hell of nights testing my Ublox8. I checked whether our Chinese geniuses missed SDA for SCL and I found out that on new Sp Racing F3 Acro it does not work unless downgrared to 1.4 as well. Without 1K pullup resistors it won't work even with Arduino. but with pullups everything goes fine with Arduino but not with Acro or Deluxe (you remember I desoldered compass out of it). So It is Not a hardware problem to some extent, I mean resistors, but Inav lacks some Mag drivers or whatever. Clean/Beta Flights recognise mag even without pullup. So I will go for APM or Naza. Ublox 7m was perfect on Inav 1.7.0- 1.7.1 but my F450 lost one prop and fall from about 100m. thanks for staying by.

digitalentity commented 7 years ago

Those haunted by I2C errors - you may want to have a look at https://github.com/iNavFlight/inav/pull/1934.

There are great many cloned compass/baro sensors that don't work on 400kHz bus but work perfectly good on 200kHz.

VictorBucha commented 7 years ago

Thanks.Hardly useful for me. I have no idea how to do that to give it a try.

digitalentity commented 7 years ago

@VictorBucha I can build you a firmware to test if you want to give it a shot.

VictorBucha commented 7 years ago

Sure, thanks a lot. Will try and respond.On Jul 31, 2017 8:56 AM, Konstantin Sharlaimov notifications@github.com wrote:@VictorBucha I can build you a firmware to test if you want to give it a shot.

—You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub, or mute the thread.

digitalentity commented 7 years ago

inav_1.7.3_SPRACINGF3_14c76111a1fd251c46e00fb0ed2814fb168c1e0d.zip @VictorBucha here's the hex. There's a new CLI parameter i2c_speed (defaults to 400KHZ). Try setting it to 200KHZ.

VictorBucha commented 7 years ago

img_20170722_190947 AAAaaaaaaaaaaaand now it works@200KHZ!!!!. Acro with BMP085 and HMS5883+UBLOX NEO8m with pullup 1kOhm resistors - works. Deluxe with desoldered HMS5883 fails to see the onboard baro but sees BMP085. Great job, @digitalentity !!! I think this freq change option should be added into standard firmware and wiki. Image of GPS module attached for convenience

digitalentity commented 7 years ago

@VictorBucha thanks for testing! Code will be added to next release - this is indeed a very useful option.

VictorBucha commented 7 years ago

Gave further testing: no need to power the UBLOX neo8m from 3,3 V if I2C pulled up- it shows no errors if powered from 5V

JonasCz commented 7 years ago

@digitalentity Could you also make a build with the i2c speed CLI parameter for Omnibus F3 for me to test ?

I have a similar problem - external mag (HMC5883) works for a few minutes, then lots of i2c errors, and it goes red in the configurator. The magnetometer works fine on a different FC.

I'll try adding pullup resistors, but I'd also like to try changing the i2c speed if that doesn't work.

JonasCz commented 7 years ago

Adding 3.3k pullup resistors seems to have worked - so I'll probably stick with that, and won't need to try reducing the i2c speed.

Now just need to figure out why it toiletbowls, even though the only change is new FC...

Thanks all for making inav awesome !

whakru commented 6 years ago

у меня была подобная проблема, изменил i2c_speed на 200 и подпаял резисторы 1к на шину i2c Контроллер F722 Теперь все работает =) Спасибо вам) bba7m7uaeyo