Barometer MS5611 accuracy improvement
Barometer MS5611 accuracy improvement
I was just playing around with my MS5611 sensor and in the specs I found room for improvement in the pressure and temperature calculations. The specs of my MS5611-01BA03 from measurement specialities says the following:
At OSR 4096 the ADC gives an accuracy of 0.012 mbar
At OSR 4096 the ADC gives an accuracy of 0.002 ºC
With the provided calculations the TEMP and P (pressure) variables are defined as int32 and you have to divide the final result by 100 to get the temperature and pressure. In this case the accuracy that we get is 0.01 mbar and 0.01 ºC, so we are not really using the whole potential of the sensor, especially after doing some calculations when the decimals were truncated.
I tried to change the variables TEMP and P to float and I observed a big improvement in accuracy.
The code in Sensors.ino for this variables are like this:
float temperature = 2000 + dT * (ms561101ba_ctx.c[6] / (float) (1 >>23));
float pressure = (float) (ms561101ba_ctx.up.val * sens - off * (1 << 21)) / ((int64_t) 1 << 36);
Of course we have to divde these values after by 100 to have the appropiate measurement.
Give it a try and let me know!!!
Cheers,
NotungX
Cheers
At OSR 4096 the ADC gives an accuracy of 0.012 mbar
At OSR 4096 the ADC gives an accuracy of 0.002 ºC
With the provided calculations the TEMP and P (pressure) variables are defined as int32 and you have to divide the final result by 100 to get the temperature and pressure. In this case the accuracy that we get is 0.01 mbar and 0.01 ºC, so we are not really using the whole potential of the sensor, especially after doing some calculations when the decimals were truncated.
I tried to change the variables TEMP and P to float and I observed a big improvement in accuracy.
The code in Sensors.ino for this variables are like this:
float temperature = 2000 + dT * (ms561101ba_ctx.c[6] / (float) (1 >>23));
float pressure = (float) (ms561101ba_ctx.up.val * sens - off * (1 << 21)) / ((int64_t) 1 << 36);
Of course we have to divde these values after by 100 to have the appropiate measurement.
Give it a try and let me know!!!
Cheers,
NotungX
Cheers
-
- Posts: 2261
- Joined: Sat Feb 19, 2011 8:30 pm
Re: Barometer MS5611 accuracy improvement
What version or Development R of the MWC are you using?
AW: Barometer MS5611 accuracy improvement
Did you check the noise of signal?
Re: Barometer MS5611 accuracy improvement
Could you please provide a unified diff? That would make testing your changes a lot easier and help avoid discrepancies
Thanks.
Thanks.
Re: Barometer MS5611 accuracy improvement
Actually I was testing the sensor for my own purposes. I don't have a multiwii device ready to test (yet). However as I noticed that the Multiwii code is using the calculations provided by the specs I decided to post here as you could benefit from the improvements.
I am attaching here a patch of Sensors.ino from the 2.1 release version that I downloaded from the website (MultiWii_2_1.zip). You can apply the patch to the sensors file with the command:
Please let me know if it works for you or if you have any other question.
NotungX
I am attaching here a patch of Sensors.ino from the 2.1 release version that I downloaded from the website (MultiWii_2_1.zip). You can apply the patch to the sensors file with the command:
Code: Select all
patch < Sensors.patch
Please let me know if it works for you or if you have any other question.
NotungX
- Attachments
-
- Sensors_patch.zip
- Increased accuracy patch for Sensors.ino (multiwii release 2.1)
- (880 Bytes) Downloaded 255 times
Re: Barometer MS5611 accuracy improvement
Can't wait for dev version
Re: Barometer MS5611 accuracy improvement
anyone tested this patch already?
I am en route to vacation so testing will have to wait another 2 weeks.
I am en route to vacation so testing will have to wait another 2 weeks.
- Crashpilot1000
- Posts: 631
- Joined: Tue Apr 03, 2012 7:38 pm
Re: Barometer MS5611 accuracy improvement
I can not apply the patch because i don't have linux and don't want to install extra BS. Why not simply post the changed code here, so the DIFF LOVERS can Diff on their own??? Would be too simple. Anyway, i implemented the patch by hand and it doesn't work at all. Probably a a error on my side but diff doesn't make sense at all.
Re: Barometer MS5611 accuracy improvement
Hi NotungX, could this improvement applied to BMP085 ? 

Re: Barometer MS5611 accuracy improvement
Crashpilot1000 wrote:I can not apply the patch because i don't have linux and don't want to install extra BS. Why not simply post the changed code here, so the DIFF LOVERS can Diff on their own??? Would be too simple. Anyway, i implemented the patch by hand and it doesn't work at all. Probably a a error on my side but diff doesn't make sense at all.
haha, lunix lovers?! I despise lunix and patch files are 100000x more readable than just posting code!
in patch file, - lines are removed and + lines are added. Lines without a + or - are context, and are unchanged. Real simple! You can see exactly what changed, plus code around it to help orient.
basically all he did was make 'pressure' and 'delt' a float,
then replaced calculations with bitshifts with proper divides.
Code: Select all
-static int32_t pressure;
+static float pressure;
find line "static int32_t pressure", replace int32_t with float.
etc.
This is really easy stuff.
Re: Barometer MS5611 accuracy improvement
Crashpilot1000 wrote:I can not apply the patch because i don't have linux and don't want to install extra BS.
no need for that. Try WinMerge (and/or TortoiseMerge). Some of the good unix stuff makes it into the win world

PS: all hearsay on my part; I do not use win* as dev platform. Also, kdiff3 for win* gets active development is what I hear.
Re: Barometer MS5611 accuracy improvement
Finally after some more tests I have to say that the improvement is basically for the temp measurements. Above 20ºC The noisy readings from the pressure sensor mask the accuracy improvements. So although there is a more precise reading, it does not seem to affect the final pressure value.
However under 20ºC the temperature readings is used for some calculations to re-adjust the pressure and it could be more useful. I have some charts that I generated showing you these conlusions. I will share them here tomorrow as it's getting a bit too late for me.
I will post as well the Sensors.ino for non-patching people
However under 20ºC the temperature readings is used for some calculations to re-adjust the pressure and it could be more useful. I have some charts that I generated showing you these conlusions. I will share them here tomorrow as it's getting a bit too late for me.
I will post as well the Sensors.ino for non-patching people

Re: Barometer MS5611 accuracy improvement
Old thread, I know but I was curious because float is used in the present 2.3 dev version.
I did a comparison with integer and float using my own MS5611 code with these results:

Alt hold should be a bit steadier with integer.
I did a comparison with integer and float using my own MS5611 code with these results:

Alt hold should be a bit steadier with integer.