cancel
Showing results for 
Search instead for 
Did you mean: 

ADC problems on the STR71

sburck
Associate II
Posted on November 04, 2006 at 18:09

ADC problems on the STR71

4 REPLIES 4
sburck
Associate II
Posted on November 03, 2006 at 08:04

I'm working on a project which measures it's own temperature to detect overheat. It's using National's LM94021 temperature sensor, set up to give us 0-2.5V for a temperature range of -50-+150. When we measure it's output voltage, it seems to be correct.

However, we have 8 different boards. We are using the ADC in single channel mode to read the ADC about once a second. On each board, the values are more or less stable, but only one board is reading the values correctly. For a temperature which is nominally around 25-30 degrees, we see values on one board around 11, another board around 100, two boards in range, and 4 boards in the 40's. Some of the boards start at lower values and steadily climb as well.

If we chill or heat the boards, we do see changes in the direction expected, but when measuring at absolute values which we know, we are seeing large errors.

The C-code (using Rowley tools, which is the GNU compiler) looks like this:

ADC_CPR = 0x00C0;

ADC_CSR = 0x0040;

PRCCU_BOOTCR |= PRCCU_BOOTCR_ADCEN_MASK;

while ((holdreg & 0xFF) != 0x41)

holdreg = ADC_CSR;

ADC_CSR = ADC_CSR_AXT; // shut off ADC before read.

PRCCU_BOOTCR &= ~PRCCU_BOOTCR_ADCEN_MASK;

...

test[0] = ((ADC_DATA0 >> 5) & 0x7FF);

The 'test' array is then used as a filter. The values we see should be around 0x140, which corresponds to 1.8V. Actual values run the gamut from 1.9V to 1.6V (and on one board, 1V), we use a scope and measure the voltage, it is very close to 1.8.

Any suggestions would be greatly appreciated.

kleshov
Associate II
Posted on November 03, 2006 at 08:18

The microcontroller reference manual says that each MCU's ADC has unpredictable gain and offset error, so you have to calibrate them individually.

Also note that ADC conversion result has to be adjusted to make it a linear function of voltage. In my program, I do it like this:

result = ADC_DATA0 ^ 0x8000;

See page 335 of revision 7 (November 2005) of the microcontroller reference manual for details.

Regards,

- mike

hichem2
Associate II
Posted on November 03, 2006 at 12:45

Hello,

Within the STR71x software library there is an ADC12 example which explain how to calibrate the STR71x ADC12 cell and get a linear conversion result.

With regards,

Hich

sburck
Associate II
Posted on November 04, 2006 at 18:09

Volius/Hich -

Thanks for the advice. First and foremost, I found I was using an old revision of the datasheet (revision 6). There are three problems, which I will look into in the morning. The first is that the differences are greater (at least on the board reading 100) than the +-5% in gain and offset. It's borderline worst case for the boards in the 40's (since the range is 0-2500mv, and we should be reading 1800mv and see, instead something like 1600; with +-5% in both gain and offset we would see a +-10% difference, or 250mv difference - if I understand the +-5% correctly). The second are the boards which ''start at lower values and steadily climb as well'' - calibration will not fix this, unless the measured gain is WAY off (far more than 5%). Finally, the HW is such that I cannot give on the channel that the temperature chip is connected to 0 and +2.5 V, only on another channel, and hope the gain/offset are the same for the channel I'm using.