Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

ADC Timing Concepts

Status
Not open for further replies.

qtommer

Member
Hi and a happy almost new year to everyone,


I have a few questions regarding the ADC acquisition time of the PIC16F family.

From the Mid-Range Reference Manual,

The TACQ is equal to
Amplifier Settling Time+ Holding Cap Charging time +Temperature Coefficient.

The amplifier Settling Time is given as 5us . What is the amplifier settling time?

Apart from that , the holding cap charge time is given as
-(All Resistor Elements) * (Cap Value) * ln(1/511)

I understand why R and C needs to be multiplied together. As for ln( 1/511), i assume it's something to do with the 1/2 LSB error used (512 steps for A/D) . However, i don' understand how the concept of how ln(1/511) came about.

The temperature coefficient time on the other hand is given as
(temp-25deg)(0.05us/deg)

What is the reason for calculating the temperature coefficient and how did that formula come about?

Thanks in advance!=)
 
oh and one more question, each time I read the ADC, do I have to insert my own delay to wait for the minimum 12TAD or do i just wait for the GO/DONE bit to be cleared? thanks!
 
oh and one more question, each time I read the ADC, do I have to insert my own delay to wait for the minimum 12TAD or do i just wait for the GO/DONE bit to be cleared? thanks!

The delay you are discussing comes into play from the time you select a new channel on the ADC before you start the new conversion, and you have to take care of it in software. The delay while the actual conversion takes place is taken care of in hardware via the DONE bit.
 
I have observed with a 16f886, that it's simplest to just double the Tad value which compensates for the impedance and temp issues .

I have a unique case of a rapid ADC acquisition to be done on boot up, but then the ref Vdd isn't fully stabilized due to the regulator caps etc. I actually add a 1 to the sampled 8 bit MSB value I use to compensate.
 
I have observed with a 16f886, that it's simplest to just double the Tad value which compensates for the impedance and temp issues .

That is certainly an interesting approach. I'll be sure to try that when I get back to the lab=) thanks.
The delay you are discussing comes into play from the time you select a new channel on the ADC before you start the new conversion, and you have to take care of it in software. The delay while the actual conversion takes place is taken care of in hardware via the DONE bit.

That clears up the confusion in my mind:) Thanks alot!

Does anyone have any idea on the theoretical aspect I have mentioned in my first post?:)

Diverting a little, i'm actually reading sensor values from this sensor:
**broken link removed**

how do i find the output resistance of this sensor? The datasheet does not specify any value of the sort. I need the output resistance so that I can calculate the source resistance I need to determine the acquisition time as stated in my first post..

Thanks!
 
Last edited:
I'm guessing that the sensor output is a "voltage output", so will drive a 10K impedance to ground just fine. The DC input impedance to your PIC AD input pin is high enough so no buffer is necessary. However, the output voltage range of the sensor spans ~ 1/2 of the AD's the dynamic range, so you will be quantizing the sensor output to less than 1:512. Is that ok?

Since your range is changing slowly, I would put a 10K resistor in series between the sensor output and the AD input, and put a shunt 1uF to 10uF capacitor from the AD pin to ground (Vss). This creates a low-pass filter, and provides the AD input with a zero-source impedance for the Tacq calculation.
 
I'm guessing that the sensor output is a "voltage output", so will drive a 10K impedance to ground just fine. The DC input impedance to your PIC AD input pin is high enough so no buffer is necessary. However, the output voltage range of the sensor spans ~ 1/2 of the AD's the dynamic range, so you will be quantizing the sensor output to less than 1:512. Is that ok?

Although my range is changing slowly, my final digital result which I display on arbitrary Port C shows oscillating values even though the sensor is at standstill.However, the oscillating parts are only at the 4 lower LSBs..The upper 4 MSBs are stable.

Do you think the cause of it is due to what Mosaic said that I should increase my Tad value? My sensor updates at 39ms intervals. Should I configure my conversion time to be as long as 39ms as well? The conversion time currently is at 24us. I'm sorry i havent tried it out in practical yet cuz my lab only opens tomorrow.

Or could it be due to the sensor limitation? I have a 100nF bypass cap placed at the power supply rail input to the sensor. So the Vcc input to the sensor is pretty smoothened out. When measuring on a multimeter, the voltage output is stable. The oscillating result is only the displayed digital result on Port C.


Since your range is changing slowly, I would put a 10K resistor in series between the sensor output and the AD input, and put a shunt 1uF to 10uF capacitor from the AD pin to ground (Vss). This creates a low-pass filter, and provides the AD input with a zero-source impedance for the Tacq calculation.
I'm sorry but i'm unfamiliar with the orchestration. How does the low-pass filter result in a zero-impedance? Hope you could elaborate:)
 
Last edited:
hi qt,
This is a LTspice I did recently, it models the PIC's adc input circuitry.
The plot shows the effect of the signal source impedance [ resistance ].

The idea for the cap at the adc pin is that a 'high' source resistance charges up the cap and when the PIC switches on the adc, the external cap quickly charges the PIC's internal cap, which is about 5pF/120pF.
Its important that the source resistance and cap values are chosen in order to give the best performance.

What is the source of the adc voltage.?
How often do you want to sample it.?

How often do you want to display and to what resolution.
 

Attachments

  • 000esp02.gif
    000esp02.gif
    29.1 KB · Views: 268
Last edited:
ADC has jitter And you haven't said what chip your using. And the link to the pdf is broke.

And from what you posted to begin with looks like your thinking you have 8 bit ADC module on your chip?
 
Post a wiring diagram which includes the sensor, its bypassing, the connection to the PIC, including how you are regulation the VDD (reference voltage for the ADC).
 
What is the source of the adc voltage.?
How often do you want to sample it.?

thank you for your reply mr.gibbs and for your simulation:). Im actually receiving from a SHARP Analogue IR Distance Sensor
**broken link removed**

im continuously sampling it actually but the sensor updates at 26Hz so i guess that's how frequent i need to sample the sensor. As for the resolution, I need to measure in 1cm intervals and the sensor maximum range goes up to 80cm.

The idea for the cap at the adc pin is that a 'high' source resistance charges up the cap and when the PIC switches on the adc, the external cap quickly charges the PIC's internal cap, which is about 5pF/120pF.
Its important that the source resistance and cap values are chosen in order to give the best performance.

Is there any reference/table/formula to which I can refer to employ the best combination?


ADC has jitter And you haven't said what chip your using. And the link to the pdf is broke.

And from what you posted to begin with looks like your thinking you have 8 bit ADC module on your chip?

im sorry im using the 876A. and though it has an internal 10 bit resolution. I left justified the result and am taking the value of ADRESH solely. The link is reposted. Sorry for the mistake.
 
In addition to Mike's questions, what are you doing with the ADC data, displaying and/or controlling a process.?
 
• Typical response time: 39 ms
• Typical start up delay: 44 ms

Just take a reading every 39 ms less you acquisition time

If Ttime = 38 then start acquisition

For get the cap and resistor not needed for this

What language are you using C asm maybe Basic I hope I like it.?

Yes 38.46 ms looks like a good time to start acquisition (26hz)
 
Last edited:
Just take a reading every 39 ms less you acquisition time

If Ttime = 38 then start acquisition

For get the cap and resistor not needed for this

What language are you using C asm maybe Basic I hope I like it.?

Yes 38.46 ms looks like a good time to start acquisition (26hz)

i'll be trying this out in a few hours when i get lab access:) will keep everyone posted..i'm using assembly and my current routine is as follows: The Delay routine is for the acquisition time (will be readjusting the acquisition time)

Code:
;;;;;;;;;;;;;;;INITIALIZE A2D CONVERTER;;;;;;;;;;;;;;;;;;;;;;;		
InitA2D:
		BANK1
		movlw	0x01
		movwf	TRISA	;configure Port A pins as input

		BANK0
		movlw	0x41
		movwf	ADCON0	; Bit 7-6:Fosc/8, Bit5-3:Channel RA0, Bit2:GO/DONE, Bit 1:Unimplemented, Bit0:ADON 

		BANK1
		movlw	0x00	
		movwf 	ADCON1	; Bit 7-3: Unimplemented, Bit 2-0 Pin Configuration
    	BANK0
		call	DelayAD
		return

;;;;;;;;;;;;;;;;READ AD LINE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

ReadA2D:
		BANK0
		BSF		ADCON0,GO
		
convWait:
		btfsc	ADCON0,GO
		goto	convWait

		movf	ADRESH,W
		
		return

;;;;;;;;;;;;;;;;;DELAY FOR AD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


DelayAD:	

		movlw	.12
		movwf	count1

repeat:
		decfsz	count1,f
		goto	repeat
		return


In addition to Mike's questions, what are you doing with the ADC data, displaying and/or controlling a process.?
im actually getting distance data to control my autonomous parallel parking car. Hence, stable results returned are most welcome :)
 
hey mike.....sorry I didn;t see your post..attached is the wiring diagram:)
 

Attachments

  • Untitled picture.png
    Untitled picture.png
    15.7 KB · Views: 216
hi qt,
Have a look at this edited version of your program.

Code:
    list      p=16f876A            ; list directive to define processor
    #include <p16f876A.inc>        ; processor specific variable definitions
    errorlevel -302, -207

count1 equ 0x20

    ;Define CONF_WORD = 0x3bf4

    __CONFIG _CP_OFF & _WDT_OFF & _BODEN_OFF & _PWRTE_ON & _XT_OSC  & _LVP_OFF & _DEBUG_OFF & _CPD_OFF 

        ORG     0x000             ; processor reset vector
        clrf    PCLATH            ; ensure page bits are cleared
          goto    main              ; go to beginning of program

        ORG     0x004             ; interrupt vector location
        nop
        retfie                    ; return from interrupt

main:

;;;;;;;;;;;;;;;INITIALIZE A2D CONVERTER;;;;;;;;;;;;;;;;;;;;;;;        
InitA2D:
        banksel TRISA
        movlw    0x01
        movwf    TRISA    ;configure Port A pins as input

        movlw     0x00
        movwf     TRISB

        movlw    0x0E    
        movwf     ADCON1    ; Bit 7-3: Unimplemented, Bit 2-0 Pin Configuration

        banksel ADCON0
        movlw    0x01
        movwf    ADCON0    ; Bit 7-6:Fosc/8, Bit5-3:Channel RA0, Bit2:GO/DONE, 
                ; Bit 1:Unimplemented, Bit0:ADON 
loop:


    call ReadA2D
    goto loop

;;;;;;;;;;;;;;;;READ AD LINE and display on PORTB ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ReadA2D:
        call    DelayAD

        banksel ADCON0
        BSF      ADCON0,GO
        
convWait:
        btfsc    ADCON0,GO
        goto    convWait

        movf    ADRESH,W
        movwf   PORTB

        return

;;;;;;;;;;;;;;;;;DELAY FOR AD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


DelayAD:    

        movlw    .12
        movwf    count1

repeat:
        decfsz    count1,f
        goto    repeat
        return

    end
 
Also, try this:

The capacitor sets the low-pass filtering. I'm guessing a time-constant of about 0.1 to 0.5sec will help.
Make sure that the sensor ground is connected back to the PIC's Vss pin without touching other "grounds" along the way.
 

Attachments

  • ADin.png
    ADin.png
    20.2 KB · Views: 230
Last edited:
You don't hook that up that way you change the timing ..

Burt,

Bad link!

The whole idea of adding the RC filter is TO CHANGE THE TIMING!!! It is not called a low-pass filter for nothing. I suggest you read up on "ANTI-ALIAS Filters"
 
The sharp infra-red detector has a 1.2 k ohm resistance by add 10 k ohm your changing that to 11.2 k ohm that would change all your timing calculations

You'll be changing it out put to 446.429 Microamps how could that be good

Is a filter used before a signal sampler, to restrict the bandwidth of a signal to approximately satisfy the sampling theorem

It has that made in it and your adding one so how will that help.

Mike ML- I'm not saying your wrong What I don't get is why the OP would want to do this when you have a chart to show output for cm. Why not use that.
 
Last edited:
Status
Not open for further replies.

Latest threads

Back
Top