Multiple ADC with a 40X2

the old fart

Senior Member
Hi guys,

Need a bit of help with this please.

I'm using ADC0,1,2,3

Signal into ADC 1&3 is very low, millivolts.

fvrsetup can config for 1.024v

Can I setup individually?


Rough code, testing..

Code:
;40x2 test
setfreq m8
;dirsa=%00001111
dirsb=255
dirsc=255
dirsd=255
adcsetup = 4  ; adc 0,1,2,3  A.0 A.1 A.2 A.3
symbol baud=n2400
symbol oled= B.7


symbol aux1=b4
symbol aux2=b5

symbol V1=W10
symbol A1=w11
symbol V2=w12
symbol A2=w13



serout oled,baud,(254,1)

pause 100






high d.4 ;



start:
main:

high b.6


if pind.2=1 or v2>73 then ; low 2 voltage 2 >7.3 volts
	high d.1
	high d.4
	low d.5
	low d.0

endif

if pind.3=1 then ; high 2
	high d.0
	high d.5
	low d.4
	low d.1
endif






;pause 100

readadc A.0,V1
readadc10 A.1,A1
readadc A.2,V2
READADC10 A.3,A2


low b.6

SEROUT OLED,BAUD,(254,128,"ADC0=",#V1,"  ")
SEROUT OLED,BAUD,(254,138,"ADC1=",#A1,"  ")
SEROUT OLED,BAUD,(254,192,"ADC2=",#V2,"  ")
SEROUT OLED,BAUD,(254,202,"ADC3=",#A2,"  ")


v2=v2*18/23
;w12=w12/43
aux1=v2/10
aux2=v2-aux1
debug

SEROUT OLED,BAUD,(254,212,"V2=",#aux1,".",#aux2,"V  ")
a2=a2*80
SEROUT OLED,BAUD,(254,224,"A2=",#a2,"mA   ")

goto main
TOF
 

Goeytex

Senior Member
First, FVR of 1.024v cannot be used for ADC. See the note in manual 2 page 68.

Consider the code below:

Code:
INIT:

   ADCSETUP %0000000000001111  '// SET ADC channels 
   FVRSETUP  FVR2048           


MAIN:

   DO

     ADCCONFIG %1000     '// USE FVR for CH0 & Ch1
     READADC10 0,W0      
     READADC10 1,W1

     ADCCONFIG %0000    '// Do NOT USE FVR For Ch2 & CH3 
     READADC10 2,W1
     READADC10,3,W2

  LOOP
 

hippy

Technical Support
Staff member
I'm using ADC0,1,2,3
Signal into ADC 1&3 is very low, millivolts.
fvrsetup can config for 1.024v
Can I setup individually?
You can issue an FVRSETUP and other ADC configuration commands whenever you want to, so you can set the configuration appropriately to maximise resolution before each READADC or READADC10.

The only thing you might need to be careful of is ensuring the internal sample and hold capacitor isn't holding a charge greater than what any particular configuration allows. I am not even sure if that would be a problem and the PICmicro datasheet should say if it is.

If it were a problem, or you wanted to play it safe, a read of 0V or the lowest level ADC input you have should ensure the capacitor is at an acceptable level before changing configurations to a lower reference voltage. For example ...

Configure for 5V
Read ADC 0 and ADC 2
Read ADC 1 or ADC 3
Configure for 1.024V
Read ADC 1 and ADC 3
 

the old fart

Senior Member
I setup an external +reference on A3, and 0v to -reference A.2

moved ADC to A5 & A6

ADCSEtup =%0000000001100011
ADCconfig %0101, for adc1 & 6

Gives me a reading from 0 to 80, which I can work with.

A.3 1n4148 diode to 0v and 10K resistor to +5v

TOF
 
Top