AnsweredAssumed Answered

ADUC7061 PGA

Question asked by miaofng on Mar 2, 2013
Latest reply on Mar 14, 2013 by miaofng

hello,

 

I am measuring -27mv voltage through pin ADC0/1(diff mode) and primary ADC.

when i changing PGA gain from 0-7(G=128), i got result following:

PGA = 0, uv = -27772 (correct, verified by DMM fluke 15b, -27.3mV, VADC0 = 0.497V, VADC1=0.524V)

PGA = 1, uv = -27103

PGA = 2, uv = -24307 (why???)

PGA = 3, uv = -36763 (why ???)

PGA = 4, uv = -58833 (why ???)

PGA = 5, uv = +23005 (why ??? -27mv * 32 should be -864mv, which is smaller than internal vref of 1.2v)

PGA = 6, uv = over range ....

PGA = 7, uv = over range ....

 

i want to do auto bank switching with following code:

void dmm_measure_v_auto(void)

{

          aduc_adc_cfg_t new, now = {.adc0 = 1, .adc1 = 0, .iexc = 0, .ua10 = 0, .pga0 = 0, .mux0 = ADUC_MUX0_DCH01};

          new.value = now.value;

          aduc_adc_init(&new);

 

 

          while(1) {

                    if(now.value != new.value) {

                              aduc_adc_init(&new);

                              now.value = new.value;

                    }

 

 

                    int v0, ov0 = dmm_measure(ADUC_ADC0, &v0);

                    if(ov0 > 0) {

                              //forced quit

                              break;

                    }

 

 

                    int d = (v0 > 0) ? v0 : -v0;

                    if(d < vth_min) { //increase gain

                              //new.pga0 += (new.pga0 == 9) ? 0 : 1;

                    }

                    else if(d > vth_max) { //decrease gain

                              //new.pga0 -= (new.pga0 == 0) ? 0 : 1;

                    }

 

 

                    long long uv = ((long long) v0 * 1200 * 1000);

                uv >>= (23 + now.pga0);

                    dmm_ro.value = (int) uv;

                    dmm_ro.mode.ready = 1;

                    dmm_ro.mode.over = (ov0) ? 1 : 0;

          }

}

 

int dmm_measure(unsigned adc, int *value)

{

          int ecode = 0;

          do {

                    ecode = aduc_adc_get(adc, value);

                    sys_update();

                    if(reg_update()) {

                              //forced quit, ecode > 0

                              ecode = 1;

                              break;

                    }

          } while(ecode > 0);

 

 

          /*0->OK, 1->FORCED QUIT, -1->OVERRANGE*/

          return ecode;

}

 

somebody could help me??? thanks in advance

Attachments

Outcomes