Quantcast
Channel: MEL PICBASIC Forum
Viewing all articles
Browse latest Browse all 4746

ADC values above 4095 for 12 bit ADC

$
0
0
seeing some readings when doing ADC on a channel giving a dec value 5534, 5144, ect when using ADCIN

have defines set to 12 bit

the adc channel is grounded via 26k resistor for testing


problem is i cant see why the reading is there at such a high value , and the value should not exceed 4095

any thoughts on why this may be happening ?????????




cheers


sheldon

Code:

  DEFINE OSC 32              ' Timing referance for pause , pauseus commands
    DEFINE ADC_BITS 12        ' Number of bits in ADCIN result - Required for adcin command



 ADCON1 =  %00100000          ' bit 7-6 = TRIGSEL 11= triger from RTCC, 10 = trigger from timer1 ,01 = trigger from CTMU, 00= trigger from ECCP2
                                ' Bit 5-4 - VCFG+ 11= Internal VREF+(4.096v) ,10= Internal VREF+ (2.048v) 01=External VREF+ ,00= AVDD
                                ' Bit3 - VNCFG-  1= External Vref- ,  0= AVSS Vref/A ,
                                ' Bit 2-0 = Analoge Neg Ch Select ( Differential measurement )
                                ' 111 = AN6, 110 = AN5, 101 = AN4,100 = AN3,011 = AN2, 010 = AN1, 001 = AN0,000 = AVSS,
 
  ADCON2 =  %10010010          ' bit 7 = 1 ADFM ( ADRESH, ADRESL - right justify ) , Bit6 n/a ,
                                ' Bits 5-3 ACQT ( acquision time ) 111 = 20TAD ,110=16TAD,101-12TAD,100=8TAD,011=6TAD,010=4TAD,001=2TAD,000=0TAD
                                ' Bit 2-0 ADCS ( AD clock sel) x11 =FRC , 110=Fosc/64,101= FOSC/16 ,100=FOSC/4 ,010=FOSC/32 ,001=FOSC/8, 000=FOSC/2
                                ' Note:  define ADCIN clock  and define ADcin sample overide this setting 





 ANCON2.1 = 1              ' Set PortG.3 = 1 - Select portG.3 to Analog  - AN17 - AD touch switch input 1R-TX mode
    TRISG.3  = 1              ' Set TRISG.3 = 1 - Select portG.3 to Input  - AN17 - AD touch switch input 1R-TX mode
    ADCON0 = %01000111        ' Select the A/D channel - AN17 turn on a/d


  adcin 17,value1            ' do ADC reading on AN17 - touch switch input
    HSEROUT2 ["value1 = ",dec4 value1,13,10]

  ADCON0 = %01000100        ' Select the A/D channel - AN17 and turn off A/D module



Code:


value1 = 0003
value1 = 0004
value1 = 0002
value1 = 0011
value1 = 0005
value1 = 0003
value1 = 0004
value1 = 0004
value1 = 0005
value1 = 0006
value1 = 0004
value1 = 0003
value1 = 0005
value1 = 0004
value1 = 0004
value1 = 0004
value1 = 0003
value1 = 0005
value1 = 0002
value1 = 0002
value1 = 0005
value1 = 0005
value1 = 5535
value1 = 5525
value1 = 0004
value1 = 0008
value1 = 0002
value1 = 0001
value1 = 0004
value1 = 0002
value1 = 5534
value1 = 5532
value1 = 0005
value1 = 0077
value1 = 5529
value1 = 0004
value1 = 0008
value1 = 0020
value1 = 5524
value1 = 5229
value1 = 0025
value1 = 0057
value1 = 0002
value1 = 5283


Viewing all articles
Browse latest Browse all 4746

Trending Articles