CapnBry / HeaterMeter

HeaterMeter and LinkMeter Arduino BBQ Controller
https://tvwbb.com/forums/heatermeter-diy-bbq-controller.85/
MIT License
502 stars 83 forks source link

[hm] ADC Change #8

Closed R-Burk closed 9 years ago

R-Burk commented 9 years ago

Changes to the ADC oversampling as 4096 samples is needed to get 16 bit accuracy with no loss of accuracy in the lower bits. Added rounding to gain 1/2 LSB back.

https://github.com/R-Burk/HeaterMeter/commit/1efaefe5fd73c55cd772123cd49bdf0060d65585

CapnBry commented 9 years ago

You're right, it is supposed to be 4^N and I seem to have somehow ended up with 2^N through all the code revisons. I'll definitely fix that but I'm not going to add the code to do the rounding. There's more than 1 LSB of noise so measuring it to more decimal places isn't useful. The only reason the OVERSAMPLEBITS constant is so high is because the data was available if it isn't available then there's no point in adding math to create a more precise measurement, because it is already overkill.

In addition you can't use TEMP_OVERSAMPLE_BITS in the calculation because that is supposed to be independent of the ADC base. If the temp wants 14 bit precision it gets it, the button and fanfeedback gets 8 bit precision. If you lower the temp precision to 10 bit but want 11 bit for fanfeedback you couldn't.

Fixed in master.