• AVR Freaks

dsPIC33FJ32GS406 ADC sampling time and measurement accuracy

Author
battika
New Member
  • Total Posts : 1
  • Reward points : 0
  • Joined: 2012/07/04 02:53:02
  • Location: 0
  • Status: offline
2012/07/04 04:25:21 (permalink)
0

dsPIC33FJ32GS406 ADC sampling time and measurement accuracy

 Hi Guys 

 we are designing an embedded system to control car headlamps equiped with LED. We are using the dsPIC33FJ32GS406 to build 
a DC-DC converter that provides the electrical power to the leds using the PWM channels. Additionally the dsPIC33FJ32GS406 reads several
values using the 10 bit ADC converter pairs:

AN0, AN1 ADC pair
- VIN1 voltage
- LED1 current

AN2, AN3 ADC pair
- LED1 voltage
- LED1 Temperature

AN4, AN5 ADC pair
 - VIN2 voltage7
- LED2 current

AN6, AN7 ADC pair
- LED2 voltage
- LED2 Temperature

Based on these values a PID regulator is adjusting the PWM signal. The aim is to read the ADC values with a 100kHz rate.
The ADC Setup is the following:


static inline void system_cfgADC()
{
ADCON = 0x0000;
ADCONbits.ASYNCSAMP = 1; /* Asynchronous and Simultaneous Sampling, See FamilyManual - High-Speed 10-bit ADC page 44-12 */
ADCONbits.SLOWCLK = 1; /* ADC clocked by aux PLL*/
ADCONbits.ADCS = 0b101; /* ADC clock divide by 6*/
/* ACLK/6= Tad 112.16MHz/6 = 53.4nS*/
ADCONbits.SEQSAMP = 0; /* Shared S&H sampled at the same time as dedicated*/
ADCONbits.ORDER = 0; /* Convert even analog inputs first (AN0, AN2, AN4, AN6)*/
//TODO FORM changed to 0 for debug
ADCONbits.FORM = 0; // Output in Fraction Format (shifted left by 5)
ADCONbits.EIE = 1; // Enable Early Interrupt
}

static void led_ch1_cfgMeasurements()
{
// AN0..AN3 is configured as analog input
ADPCFGbits.PCFG0 = 0;
ADPCFGbits.PCFG1 = 0;
ADPCFGbits.PCFG2 = 0;
ADPCFGbits.PCFG3 = 0;

//we trigger the AN0, AN1 conversion on the PWM1L output for VIN1, ILED1
ADCPC0bits.TRGSRC0 = 0b01110;

//we trigger the AN2, AN3 conversion on the PWM1L output for VLED1, NTC1
ADCPC0bits.TRGSRC1 = 0b01110;

//we trigger the AN4, AN5 conversion on the PWM2L output for VIN2, ILED2
ADCPC1bits.TRGSRC2 = 0b01111;

//we trigger the AN6, AN7 conversion on the PWM2L output for VLED2, NTC2
ADCPC1bits.TRGSRC3 = 0b01111;

IPC27bits.ADCP0IP = 5; /* Set ADC Pair 0 interrupt priority*/

//we use the AN0 and AN1 interrupt to process the results from all the AN0,AN1,AN2,AN3 conversions
IFS6bits.ADCP0IF = 0; /* Clear ADC Pair 0 interrupt flag*/
IEC6bits.ADCP0IE = 1; /* Enable ADC Pair 0 interrupt*/

TRGCON1bits.TRGDIV = 3u; /* Trigger output for every x trigger event*/
}


All the ADC inputs have a low impendance with Rs=50 Ohm. Although the sampling works we have problems with the sampling accuracy.

The actual problem:
On the shared ADC inputs with shared S&H (AN1, AN3, AN5...) we can detect a certan inaccuracy in the measurement.
The last sampled input somehow influences the next ADC measurement.
I suppose the problem is the sampling duration thus the charging time of the holding capacitor.
If we increase the time between the measurements the accuracy will improove (for instance ADCONbits.ADCS = 0b111; , TRGCON2bits.TRGDIV = 5u;. )

In the document Section 44. High-Speed 10-bit ADC (DS70321D) page 44 there is a description of the ADC SAMPLING REQUIREMENTS. It states:

"A minimum time period should be allowed between conversions for the sample time. For more 
details about the minimum sampling time of a device, refer to the “Electrical Characteristics”
section in the specific device data sheet."

But I was unable to find any information about the minimum sampling time in the dsPIC33FJ32GS406 datasheet.

Does anybody have an idea where can I find what is the minimum sampling time if the analog input source impedance RS = 50 Ohm? Or how to reach the speed up to 2 Msps with shared S&H?

Thank you for your help,
 greetings
 Attila
#1

9 Replies Related Threads

    Mike017
    Super Member
    • Total Posts : 2698
    • Reward points : 0
    • Joined: 2007/08/25 08:11:31
    • Location: Lincoln, RI, USA
    • Status: offline
    Re:dsPIC33FJ32GS406 ADC sampling time and measurement accuracy 2012/07/06 14:19:40 (permalink)
    0
    Hi,
     
    But I was unable to find any information about the minimum sampling time in the dsPIC33FJ32GS406 datasheet...
    It's not specifically spelled out. It can be backed into from using the DS & FRM:
    - DS....spec parameter AD50b for the minimum Tad (35.8 ns)
    - FRM...  states in several places that sampling takes 2 x Tad cycles (other places read 2-3 Tad cycles)
    - DS AD55b Conversion time 14 Tad.
     
    So, with that one would think that the throughput would be 1/(16 Tad + delays). But, that PIC has several conversion sequences (FRM 44.4 to 44.6) that eliminate some of the overhead i.e. continuous sampling, early interrupts, etc. So just pick one of the conversion sequences and calculate.
     
    Good Luck,
    Mike  
     
     
     
    #2
    Weydert
    Super Member
    • Total Posts : 483
    • Reward points : 0
    • Joined: 2008/07/02 04:22:40
    • Location: Aachen/Germany
    • Status: offline
    Re:dsPIC33FJ32GS406 ADC sampling time and measurement accuracy 2012/07/08 02:09:06 (permalink)
    0
    Hi,
     
    looking through all  conversion sequencies there is no sequence where the sampling-time of the shared S&H channel is other than 2 TADs. In the no "GS" devices you can selecte the number of sampling-clocks, in the "GS" devices you can't. (for the shared S&H channels).
    The datasheet of other dsPIC devices have a picture of the "A/D converter Analog Input Model" with a typical sampling capacitance of 4.4pF and a series resistor of 250 Ohm + 3000 Ohm.

    I found a calulation-example of the sampling time requirements in an old FRM for the dsPIC30F. Search for DS70064B (from 2003).
    In this document an additional charging time of 50ns/C° is required if T>25°C. Never found this value in any Electrical Characteristics nor found calculation-examples in newer FRMs.
     
    It sounds strange, that the voltage level of the previous channel can effect the ADC result of the current channel because the FRM states
    The internal holding capacitor will be in a discharged state prior to each sample operation

    But other people in this forum are speaking about this too.
     
    My assumtion:
    The shared S&H channels are connected to the ADC through an input-multiplexer. And there is no information about this multiplexer in the datasheet.
    At least it introduces an additional resistance and enlarges the charging time of the sampling capacitor.
    But it has also an (unknown) turn-off, break-before-make, and turn-on time.
    So when the new channel is selected at the start of the sampling time, the capacitor could be charged for some time whith the previous channel voltage until this channel is diconnected and only after the turn-on time has gone the new channel starts charging the capacitor.
    But this are all speculations because there is no information about the multiplexer in the datasheet.
     
    Rainer

    Attached Image(s)

    #3
    avogra
    New Member
    • Total Posts : 4
    • Reward points : 0
    • Joined: 2012/07/09 00:26:51
    • Location: 0
    • Status: offline
    Re:dsPIC33FJ32GS406 ADC sampling time and measurement accuracy 2012/07/09 09:45:27 (permalink)
    0
    Hi,
    i am also working on this project. Thank you for your replies!
    @Mike017: that is how you calculate how long sampling takes. But how long should it take to get accurate results? There seems to be no information on that.
     
    @Weydert: That is some interesting news, especially the FRM. The FRM for ..FJ..GS devices contains the same picture but without the calculations. It is surprising, that you can't chose the number ot Tad cycles with the GS devices. Especially as it can run at 2MSps. Same with reference voltage, which is fixed to AVDD, whereas the ADC in your FRM can use dedicated reference pins.
     
    Anyhow, I calculated the needed sampling time with CHold and Rss from DS70321D, all other parameters from DS70064B.
    Assuming Rss = 110 Ohms, Rs = 50 Ohms (opamp+50 Ohms), Ric = 250 Ohms, I get Tc > 22.5 ns. fine for me.
    Taking Tamp (0.5µs) from DS70064B doesn't look reasonable as the ADC is meant to complete an entire conversion in that time! d'oh!
     
    so no usable results either. anyhow, I discovered some new stuff:
    currently the adc is driven by an opamp with 50Ohms in series and external clamping diodes for protection, as the Opamp is supplied by 5V.
     
    when the last measured input has 0V and the current input has 3,3V, I can measure a short drop of almost 300mV on the pin! adding a cap with 470p improves that to 60mV. after ~500ns the pin returns to 3,3V.
    seems like this should be our sampling time, but it is no option, as we need at least 1MSpS.
    I still have to look into what effect the 50 Ohms resistor has. in the datasheet, they recommend <100 Ohms. I will replace it by 0 Ohms. I will report on the results!
     
    Thanks for the attention by the way :)
     
    Best Regards,
    Alex
     
     
     
     
    #4
    Weydert
    Super Member
    • Total Posts : 483
    • Reward points : 0
    • Joined: 2008/07/02 04:22:40
    • Location: Aachen/Germany
    • Status: offline
    Re:dsPIC33FJ32GS406 ADC sampling time and measurement accuracy 2012/07/09 11:43:52 (permalink)
    0
    Hi,
    it might be helpfull to look to the datasheets of ADC-manufacturers like Analog Devices, Linear Technologies, Maxim etc.
    They often suggest wich operational amplifier to use to get the sampling capacitor charged within the samplin time. I found one example (but  don't remember where) for a 10 bit ADC with 500kHz throughput and sampling time of 150ns. This required an OP with output resistance of <=100 Ohm in OPEN LOOP mode and at the Gain-Bandwith-Frequency. The closed loop bandwidth should be >10MHz to settle fast enough within the 150ns sampling-time.
    So even if you connect only a very slow changing voltage to the ADC this requires a high-speed OP at high sampling frequencies.
     
    Regards
    Rainer
    #5
    avogra
    New Member
    • Total Posts : 4
    • Reward points : 0
    • Joined: 2012/07/09 00:26:51
    • Location: 0
    • Status: offline
    Re:dsPIC33FJ32GS406 ADC sampling time and measurement accuracy 2012/07/10 08:22:17 (permalink)
    0
    Ok, now you got me cold :) We use a cheapo LM2904.
    Removing the resistor didn't show any effect, which is no surprise after your hints.
    S
    The closed loop bandwidth is problematic. Gain is 15 (shunt measurement). To reach settling within 70ns (for 2MSpS), i guess i need >> 300MHz GBWP. Ouch!
    Another thought: adding a feedback cap reduces gain at higher frequencies. This should help to increase closed loop bandwidth at high frequencies. Do you agree?
    I will try a MCP662 (60MHz), which seems to fit nicely apart from GBWP.
     
    Thanks for the great input!
     
    Best regards, Alex
    #6
    Weydert
    Super Member
    • Total Posts : 483
    • Reward points : 0
    • Joined: 2008/07/02 04:22:40
    • Location: Aachen/Germany
    • Status: offline
    Re:dsPIC33FJ32GS406 ADC sampling time and measurement accuracy 2012/07/10 08:56:22 (permalink)
    0
    Hi,
    I only told you what I read in the datasheets/application notes. I have no experience with these high frequencies.
    When you tell about a drop of 0,3V this is not the problem. You always have this drop without an input capacitor. But it must regulate out within the 70ns!
    Adding the 470pF capactitor can make the things even worse: The 470pF C is charged to 3,3V and when the sampling-switch closes the charge is distributed (within the time of  ~ 20 ns you calculated) to both - the 470pF and the 7,2pF C.
    If the voltage drop is  named "dU" the calculation could be:
    3,3V * 470 pf = (3,3V + dU) *(470pf + 7,2pF)  ->dU ~50mV
    But now you need to charge a capactior of 477pF instead of 7,2pF.
    For the OP I think only driving the ADC needs the high bandwith / high slew-rate device. Amplification can be done with a slower OP. (Amplification x15 with 2904 and then driving the ADC with a special OP)
    I don't agree with you in adding a capacitor in the feedback.
    I'm looking forward for your results.
    Rainer
     
     
     
    #7
    avogra
    New Member
    • Total Posts : 4
    • Reward points : 0
    • Joined: 2012/07/09 00:26:51
    • Location: 0
    • Status: offline
    Re:dsPIC33FJ32GS406 ADC sampling time and measurement accuracy 2012/07/12 08:02:24 (permalink)
    0
    Hi,
    I have good news! With the MCP622, pin voltage recovers within 40ns. The closed loop gain seems to be less important. I guess, it's mainly the slew rate making the difference.
    thanks again for the help!
     
    best wishes, Alex
     
    #8
    Mike017
    Super Member
    • Total Posts : 2698
    • Reward points : 0
    • Joined: 2007/08/25 08:11:31
    • Location: Lincoln, RI, USA
    • Status: offline
    Re:dsPIC33FJ32GS406 ADC sampling time and measurement accuracy 2012/07/13 06:22:24 (permalink)
    0
    Hi,
     
     With the MCP622, pin voltage recovers within 40ns.
    Great!  So are the accuracy results now OK? Also, you were looking for 1-2 Msps. Can you get that now? Can you post your final OP amp circuit or the component values?  Others in the forum could benefit.
     
    Good Luck,
    Mike
    #9
    avogra
    New Member
    • Total Posts : 4
    • Reward points : 0
    • Joined: 2012/07/09 00:26:51
    • Location: 0
    • Status: offline
    Re:dsPIC33FJ32GS406 ADC sampling time and measurement accuracy 2012/07/17 00:33:10 (permalink)
    0
    Hi,
    accuracy is not perfect. I still have a dependency of ~ 1..2 digits on the last measured value, but that is ok for us. Circuitry is rather simple: the MCP662 is  used as differential amplifier. input resistors are 10K, feedback resistors are 150K. Output resistor is 10 Ohms, no capacitors involved. opamp supply is 5V.
     
    Best regards,
    Alex
    #10
    Jump to:
    © 2019 APG vNext Commercial Version 4.5