Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems reading two barometers from version 0.3.3 onwards. #23

Closed
HWal opened this issue Jan 15, 2022 · 27 comments · Fixed by #22
Closed

Problems reading two barometers from version 0.3.3 onwards. #23

HWal opened this issue Jan 15, 2022 · 27 comments · Fixed by #22
Assignees
Labels
bug Something isn't working

Comments

@HWal
Copy link

HWal commented Jan 15, 2022

Thank you for this library, it is of good use to me. I am using it in a DIY airspeed indicator based on two GY63 ms5611 breakouts. The pressures from the pitot tube are read in succession and their values are compared, compensated for the offset between them.

Using version 0.3.2 this all worked fine. But with versions 0.3.3 to 0.3.5 I get corrupted values from the first baro that is read; that is the one with address 0x76.

@RobTillaart
Copy link
Owner

You're welcome, thank you for reporting this issue.

As I only have one sensor I am not able to recreate your setup, so I need your help to analyse.

0.3.2 works and 0.3.3 does not. OK-> compare

There is an optimization done in the timing

reset() => delay(3) replaced by delayMicroseconds(2800)

and convert()
image

These timings are from the datasheet so considered correct,

image


hypothese 1
timing is just critical for one of the sensors.

TEST 1: swap the sensors addresses to see if problem happens with the 0x76 address or with the same physical sensor?


hypothese 2
the internal timing in the sensor and of the processor are slightly different and the code in the lib is just at the edge.

TEST2: increase the delays e.g.

in convert to 3000 microseconds?

in convert, add a few 100 us per entry.


hypothese 3
RTOS blocking problem? (much less likely)

What board are you using?
In version 0.3.6 - currently in develop branch - I replaced the delayMicroseconds with a loop around yield() to allow task switching in RTOS

@RobTillaart
Copy link
Owner

If hypothese 2 solves the problem I can include it in the 0.3.6 release.
I'll check the datasheet for accuracy of the intern clock of the 5611 (might be indicative)

@RobTillaart
Copy link
Owner

Found this in the datasheet
image

The times in the array are TYPICAL times while they should have been MAX times.
So that will be adapted in the 0.3.6 version a.s.a.p. (first I need another coffee)

@RobTillaart RobTillaart self-assigned this Jan 15, 2022
@RobTillaart RobTillaart added the bug Something isn't working label Jan 15, 2022
@RobTillaart
Copy link
Owner

Updated timing added to develop branch - https://github.com/RobTillaart/MS5611/tree/develop

@RobTillaart
Copy link
Owner

Adding a simple example for two sensors to the example folder to have a minimal test.

@HWal
Copy link
Author

HWal commented Jan 15, 2022

Thank you for the reply and your work on this. I will do the testing. I am not sure if I can get this done during the evening (Norway time), I'll return with result tomorrow at the latest.

@HWal
Copy link
Author

HWal commented Jan 15, 2022

For testing I use a NodeMCU v1.0 (ESP8266). This is easy because of the USB connection. For permanent installation in my model airplane I will use an Arduino Pro Mini.

@RobTillaart
Copy link
Owner

RobTillaart commented Jan 15, 2022

Thank you for the reply and your work on this. I will do the testing. I am not sure if I can get this done during the evening (Norway time), I'll return with result tomorrow at the latest.

I'm in the same time zone (Netherlands, near EIndhoven)
Take the time you need, good testing takes time.

Good to hear you are testing the library with processors I did not test with. Helps to get it robust!

Do you have a picture of the model plane?)

@HWal
Copy link
Author

HWal commented Jan 15, 2022

20211120_142345
20211120_141029
20211120_141827

@HWal
Copy link
Author

HWal commented Jan 15, 2022

My experimental plane (among other ordinary planes). Two ms5611 connected to create differential pressure.

@RobTillaart
Copy link
Owner

My experimental plane (among other ordinary planes). Two ms5611 connected to create differential pressure.

The latest version adds support for an offset for pressure and temperature.
That allows you to calibrate them to the same reading before start ==> better differential?

@HWal
Copy link
Author

HWal commented Jan 15, 2022

I managed to do a couple of tests just a few minutes ago. For info, in my sensor sketch i read both baros, then add 200ms delay, then read both baros again, and so on...

Swapping adresses did no difference, other than to move the error to the other baro instance in my sketch.

However, i tried in the convert function to change some values:
uint16_t del[5] = {500, 1100, 2100, 4100, 8220};
changed to
uint16_t del[5] = {1000, 2000, 3000, 5000, 10000};

I have not gone deep into the library, but the changed values seem to correspond with the values used in the delay() statement in 0.3.2.

Now both baros worked fine.

@RobTillaart
Copy link
Owner

I have not gone deep into the library, but the changed values seem to correspond with the values used in the delay() statement in 0.3.2.

exact, so hypothesis 2 was the right one.

Can you verify if these values work for you?

  // values from page 3 datasheet - MAX column (rounded up)
  uint16_t del[5] = {600, 1200, 2300, 4600, 9100};

these are the rounded up MAX values from the datasheet. Would still allow to gain 10-40% waiting time compared to 0.3.2

Thanks for testing!

@HWal
Copy link
Author

HWal commented Jan 15, 2022

I just tried with the above values. Both barometers run fine now.

@RobTillaart
Copy link
Owner

OK, I will merge 0.3.6 then. That should work for you too.

@RobTillaart RobTillaart linked a pull request Jan 16, 2022 that will close this issue
@HWal
Copy link
Author

HWal commented Jan 16, 2022

Thank you very much for your help and support !

@RobTillaart
Copy link
Owner

You're welcome, please let me know how your experiments go.

@HWal
Copy link
Author

HWal commented Jan 16, 2022

I will, testing during flight is next when the flying season starts.

@RobTillaart
Copy link
Owner

@HWal

I created an issue - #26

The idea is that if you know the sensor ID you can store an calibration offset for temperature and pressure in code or in EEPROM and provide every sensor with the right offsets without calibrating every time.

The ROM constants are read in the ms5611.cpp file in the reset() function.
Can you print your ROM constants per sensor and post them here so I can compare if they are different enough?
just add a line Serial.println(readProm(reg)); will do the job.

As you have more than one sensor please provide a list per sensor.

Thanks in advance,
Rob

@HWal
Copy link
Author

HWal commented Jan 22, 2022 via email

@RobTillaart
Copy link
Owner

RobTillaart commented Jan 22, 2022

No problem, already had other source .
But still interested in your deviceID to see it works.
Thanks

@HWal
Copy link
Author

HWal commented Jan 22, 2022 via email

@RobTillaart
Copy link
Owner

RobTillaart commented Jan 22, 2022

It's perfect that they are different.
That makes them a good source to generate an "unique" device ID.

got now 5 results, all different!

0        192      2120     12      16
42813    55102    58061    52157   53012
44132    52075    55931    46715   52757
26874    34758    36591    31062   31868
24506    31777    31881    25551   29782
32060    32430    32845    33042   32409
28365    28042    28228    27419   27506

@HWal
Copy link
Author

HWal commented Jan 22, 2022 via email

@RobTillaart
Copy link
Owner

Thank you for testing, hope the plane flies soon!

now I'm pretty sure I can create a uint32_t getDeviceID() function, to uniquely (enough) identify sensors from calibration data.

@RobTillaart
Copy link
Owner

@HWal
just came across this issue, and was wondering if the plane did fly..

@HWal
Copy link
Author

HWal commented Oct 26, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants