how to reduce ADC conversion time?

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Post Reply
poweronhand
Posts: 21
Joined: Mon Sep 07, 2009 7:09 am
Has thanked: 3 times
Been thanked: 1 time
Contact:

how to reduce ADC conversion time?

Post by poweronhand »

Hi there
can any one tell me if there is any way to change the ADC conversion time? and what is the acquisition time calculated?
it is default 40 cycles , i am using a 16f716 internale clock with RC OSC and i used to test the conversion complete flag "BTFSS "before i record the converted value to a register
i check the flowcode uses lot of lines to do the ADC so i tried to use my old asm code that works and enter the below code in the c block and got error

Code: Select all


asm
{
;adcon=================================================
            BCF     STATUS,Z
            MOVLW   0XC1
            MOVWF   ADCON       ;SELET CHO/IN CLK
            BSF     ADCON,2     ;start conversion
;===========enter sensor dig====================
ADLOOP     
            BTFSC   ADCON,2     ;check  convertion is done
            GOTO    ADLOOP      ;wait
            MOVF    ADRES,0     ;PLACE RESULT IN W
            BCF     ADCON,0     ;turn off adcon
            MOVWF   data1     ;record to data1

;targetLo===========enter ref signel=============================
            BCF     STATUS,Z
            MOVLW   0XC9
            MOVWF   ADCON       ;SELET CH1/IN CLK
            BSF      ADCON,2        ;start conversion
ADLOOP2    
            BTFSC   ADCON,2     ;check convertion is done
            GOTO    ADLOOP2    ;wait
            MOVF    ADRES,0     ;PLACE IN W
            BCF       ADCON,0     ;turn off adcon
            MOVWF   data2     ;record to data2

;targethi========================================
            BCF         STATUS,Z
            MOVLW   0XD1
            MOVWF   ADCON       ;SELET CH2/IN CLK
            BSF        ADCON,2        ;start conversion
ADLOOP3     
            BTFSC    ADCON,2     ;check  convertion is done
            GOTO    ADLOOP3    ;wait
            MOVF    ADRES,0      ;PLACE IN W
            BCF      ADCON,0      ;turn off adcon
           MOVWF   data3        ;record to data3
            

;throttle=================================================
            MOVLW   0XD9
            MOVWF   ADCON           ;SELET CH2/IN CLK
            BSF         ADCON,2        ;start conversion
ADLOOP4    
            BTFSC    ADCON,2      ;check  convertion is done
            GOTO     ADLOOP4     ;wait
            MOVF     ADRES,0      ;PLACE IN W
            MOVWF  data4          ;record to data5
            BCF       ADCON,0      ;turn off adcon
            
}

any suggestion and direction will help thanks much.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: how to reduce ADC conversion time?

Post by Benj »

Hello,

In the assembler code you provided you are referencing the register ADCON, however the register name on the 16F716 is either ADCON0 or ADCON1.

ADC conversion time is the time to convert the signal from an analogue value to a digital value. Normally the faster you do this the less precise your ADC reading. Have a play with this and see what speeds you can get without the samples being effected.

The ADC acquisition time is the time before the conversion to charge the ADC capacitor measured in CPU cycles. Again have a play and see what you can get down to without ADC channels bleeding into one another.

poweronhand
Posts: 21
Joined: Mon Sep 07, 2009 7:09 am
Has thanked: 3 times
Been thanked: 1 time
Contact:

Re: how to reduce ADC conversion time?

Post by poweronhand »

thanks for your reply please advice if i can access to the flash memory with out a programmer i mean if i want record some data in the chip's rom?
also where can i set the pwm output on port b bit 7?
thanks

Post Reply