EEVblog Electronics Community Forum

Electronics => Projects, Designs, and Technical Stuff => Topic started by: iheb on January 19, 2022, 12:54:32 pm

Title: Achieving SAR ADC Maximum Dynamics
Post by: iheb on January 19, 2022, 12:54:32 pm
Hello i am currently having an application using C8051F06 Microcontroller and i am designing a buffer driver for its input i have been working with the Circuit from the reference design but , i can't quite manage to drive the ADC deferential mode without having to modify the gain inside the Microcontroller, that also i am having the issue that i was never able to reach the specifications in the data sheet and attain the full dynamics without distortions on the signal the input voltage across the ADC's is between 0 and +/-Vref and v ref is 2.5v, and I'm only able to reach 1.5V at one side and 1.7V at the other side of the ADC when working in differential mode. I also notice an imbalance in the internal resistance when measuring it directly for each ADC.

If its possible anyone can help me why do this imbalance is from ?
What is the best way to drive the ADC in differential mode without having to alter the code for gain and offset errors?

thank you
Title: Re: Achieving SAR ADC Maximum Dynamics
Post by: moffy on January 19, 2022, 11:03:08 pm
It is hard to respond in a constructive manner to your issue as it is probably code dependent and also development environment. I assume you are using the 'Simplicity Studio' development package by SiLabs? I have no experience with it though I have used the 8051 core before, but long ago, and I programmed in assembly, long time ago. I have found some code: which uses the 16 biy ADC, if you don't have it it might provide a good starting point for your code.
Title: Re: Achieving SAR ADC Maximum Dynamics
Post by: iheb on January 20, 2022, 02:14:05 pm
Thank you for your suggestion, i have read that application note about improving ADC resolution. it says a bit about the dynamic range but , i'm not quite sure how to prove that the ADC driver that i did would occupy the full dynamic range with minimum software calibration. i can provide the design if anyone can help 
Title: Re: Achieving SAR ADC Maximum Dynamics
Post by: moffy on January 20, 2022, 10:52:55 pm
Have you tried to compile the code in and run it? It should give you a known good starting point to work from. The configuration of the peripheral , in this case the ADC, can be difficult, so using an example that does it for you can be a big help. I prefer to modify a working example, to writing from scratch. You just have to have 1 bit in an obscure and apparently unrelated register not set and things go awry.
Title: Re: Achieving SAR ADC Maximum Dynamics
Post by: Benta on January 20, 2022, 11:48:17 pm
I suspect you're driving the input voltage beyond what the device will accept.
But without a schematic, your question flies in the wind.
Title: Re: Achieving SAR ADC Maximum Dynamics
Post by: iheb on January 21, 2022, 08:16:10 am
Here are some schematics and test that i did on the adc in Differential mode

i noticed also a non symmetry in booth ADCs when zeroing one and driving another ,The following plot shows sampled signal vs input signal peak while driving AIN0.

i use the following code to convert the sampled data to mv , its taken from the datasheet of the C8051F06 IC

Code: [Select]
    float convert_mv(long val_brute){
            float voltage_mv;
    char old_SFRPAGE = SFRPAGE;
    if ( val_brute <= 0x7FFF && val_brute > 0 )      // Positve voltage
    voltage_mv= ( (val_brute * 2500 /32768.0)/1);
    else if ( val_brute >= 0x8000 && val_brute <= 0xFFFF ) // Negative voltage
        voltage_mv= ( ((val_brute-32768) * 2500/32768.0 - 2500)/1 ) ;
    }else if(val_brute == 0x0001){
    voltage_mv= ( (val_brute * 2500 /32768.0)/1)+2;
    else if(val_brute == 0xFFFF){
    voltage_mv= -( (val_brute * 2500 /32768.0)/1)+2;
    else if ( val_brute == 0)
    voltage_mv= 0;
    return voltage_mv;


(http://Screenshot 2022-01-19 095310) When driving the ADC with the following circuit i notice an issue that is when I also reach close to VRF, the Signal attenuates and becomes distorted when I probe at the ADC input while the Operational amplifier is connected to the ADC inputs

My question is what is the best way to drive the ADCs to achieve the best dynamics (the drivers in the reference designs also comes with problems and i could never achieve the Maximum dynamics without changing the gain numerically in the conversion function in the code above convert_mv() ), and why there is a mismatch between booth ADC's when working in Differential mode ?

Note : When I measure directly the resistance between AIN0 and AIN0GND its around 35 oms and For the AIN1 and AIN1GND it's around 140 ohms, why aren't they equal because i think that imbalance is the reason for gain mismatch between booth channels
Title: Re: Achieving SAR ADC Maximum Dynamics
Post by: moffy on January 21, 2022, 09:51:55 am
You should try setting AIN1 to 0v and use a pot, not the AD8132 which you should disconnect, and the input to between 0v to Vref(2.5v) and plot the results. Then set AIN0 to 0v and vary AIN1 from 0v to Vref and plot the results. If that is fine then the problem lies somewhere with the AD8132. Are both the AIN grounds tied to 0v?