Seeed-Studio / Mutichannel_Gas_Sensor

This Arduino library is used for driving "Xadow - Mutichannel Gas Sensor" and "Grove - Mutichanel Gas Sensor"
Other
25 stars 25 forks source link

Correct VCC voltage for the factory calibration usage ?? #10

Open paulvha opened 7 years ago

paulvha commented 7 years ago

While the Grove board specifications state it can operate between 3.3V and 5V, the choice has serious implication on the reading.

The concern is the result of using the supplied VCC as the reference voltage for the ATMEGA168 ADC, instead of using the 3.3V that is is generated by the ETA3401 (step down converter). This 3.3V is used for driving the MiCS-6814 heaters and also the maximum voltage to the extract the sensing resistance in air. The input voltage on an ADC channel to calculate the sensing resistance in air from the MiCS-6814 can NOT be more than 3.3V, based on the Grove schematics.

The ADC in the ATMEAGA168 is 10 bits and it can provide a sensed value in steps between 0 and 1024 (2^10). The number is based on reading the ADC value and divide that by a reference value for each step. The reference value for each step is based on AREF / 1024. AREF (pin 20) has a capacitor, so either the ATMEGA168 is programmed to use AVCC or an internal 1.1V. It is logical, and determined, that AVCC (pin 18) is used which is sourced through a low pass filter (R11/C3) from VCC.

If the board is connected to 5V the reference value for each step is 5V/1024 = 4.8mV. If the board is connected to 3.3V the reference value is each step is 3.3V/1024 = 3.2mV.

According to the Grove board specification the board is calibrated before leaving the factory. The ADC value is obtained under special controlled conditions (data sheet MiCS-6814, page 2). The results are stored in the EEPROM as an indicator of clean air value. This R0 is used as a factory reference to determine the pollution in the air measured later.

Reading the EEPROM values, my Grove board gives me: FACTORY_ADC_NH3 = 0x35c (860 decimal) FACTORY_ADC_CO = 0x3b6 (950 decimal) FACTORY_ADC_NO2 = 0x9b (155 decimal)

If we then translate the ADC value to voltage (depending on the VCC) ..............| VCC = 5 Volt................ | VCC = 3.3V NH3.....| 860 4.8mV = 4.2V....| 860 3.2mV = 2.7V CO........| 950 4.8mV = 4.64V | 950 3.2mV = 3.06V NO2....| 155 4.8mV = 0.76.....| 155 3.2mV = 0.5V

The voltage however can NOT be larger than 3.3V (given the schematics), thus one should assume the calibration is done with VCC 3.3V. Is that correct ?

If so, shouldn't the board not only be used on 3.3V (when using the factory setting) or otherwise do always do local calibration if on 5V or divide the factory values by 1.5 when using on 5V?

Wouldn't it not be better to have the AVCC connect to the 3.3V output from the ETA3401 to make the ADC reading independent from the VCC and aligned with max voltage from the sensors?

P.s. if you want to test this yourself, read the current ADC values (after a warmup) on either 5V supply or 3.3V supply. You will find that the ADC reading is about a factor of 1.5 different depending on the VCC voltage you apply. (lower when at 5V). However the factory reference is a stored value in the EEPROM and does not change of course) regards, Paul