Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[PIC] Differential adc in pic16f1786

Status
Not open for further replies.

Dinuwilson

Advanced Member level 4
Joined
Aug 20, 2011
Messages
100
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,298
Activity points
1,985
i need to read -2v to +2v voltage range. i am using pic16f1786 12 bit adc in differential mode.

is it possible to do with this in this micro controller

i am using 2 v +vref from FVR buffer in the micro controller

i am confused about -vref. what it mean? should i need to use this for my application?

for testing i am configured +vref from fvr 2v reference and -vref as ground. when i check the value from the adc, if 1 put 0 mv from my differential input, adc output is 25 count when i increase +1mv,+2mv,+3v.... count increase gradually up to 4096. so i can trace up to 2v

same configuration when i put -1mv my adc count is 23
-2mv '' 20
- 3mv '' 17

-11mv '' 1

when i put -12mv ,-indication of the adc ADRESH register get activated , i am using 2's compliment method

so up to -11mv negative indication of the ADRESH is not activated (showing as in +ve side)



please help me to solve this problem. i tried a lot , but i can't find out anything....
 

You can't give -Ve voltage to ADC pin. ADC will get destroyed. Vref- is for lower reference voltage and Vref+ is for upper reference voltage. If Vref - is 2V and Vref+ is 4V then ADC range is from 2V to 4V so, 2V adc gives 0 reading and for 4V it gives 1023 if 10 bit adc. Also between Vref - and Vref+ there should be a min difference of 2.5V. Shift your voltage so that -2V becomes 0V and 2V becomes 4V and try.
 
Last edited:
thank's for our replay....+vref and -vref i understand.. is any chance to read the -values in pic16f1786? in datasheet +4096 to -4096 they are saying,that's why i am confusing
 

ADNREF: ADC Negative Voltage Reference Configuration bit
1 = VREF- is connected to external VREF- pin(1)
0 = VREF- is connected to VSS

ADPREF<1:0>: ADC Positive Voltage Reference Configuration bits
11 = VREF+ is connected internally to FVR Buffer 1
10 = Reserved
01 = VREF+ is connected to VREF+ pin
00 = VREF+ is connected to VDD


Negative reference voltage means not actually negative but if your Vref+ is 4V Vref - is 2V, then 2V is less positive than 4V. It is lower reference.
 
Last edited:

ok..i got it sir,,, thank's. if i need to read negative voltage levels what i need to do?
 

You have to shift the voltage using a Clamper. Shift the level 2.5V up so that -2V becomes 0.5V and 2V becomes 4.5V. It should not exceed 5V. If it exceeds then you have to scale the voltage. Are you measuring AC or -ve DC?


If AC is given then you can use this circuit.


Set Vref+ to 4.2V and use this


Code C - [expand]
1
2
if((val >= 0) && (val <= 1950))val = (val * (-0.001026));
else if((val >= 1950) && (val <= 3900))val = (val * 0.001026);




99501d1386408746-adc-neg-circuit_circuit.png


99502d1386408748-adc-neg-circuit_output.png
 

Attachments

  • ADC NEG Circuit_Circuit.png
    ADC NEG Circuit_Circuit.png
    18.5 KB · Views: 118
  • ADC NEG Circuit_Output.png
    ADC NEG Circuit_Output.png
    92.6 KB · Views: 110
Last edited:

ok......i wiill try it out...sir
 

See attached files. Change freq of AC to 50 Hz in Proteus. You have to set it in VSINE.



Code C - [expand]
1
2
3
4
5
6
7
//10 bit adc, Vref+ = 4.2V
 
adcval = ((ADC_Read(0) / 243.0) - 2.0);
 
//12 bit adc, Vref+ = 4.2V
 
adcval = ((ADC_Read(0) / 975.0) - 2.0);





99521d1386435756-adc-ac1.png


99523d1386437567-adc-ac-3.png
 

Attachments

  • adc o.rar
    92.6 KB · Views: 64
  • adc.rar
    141.6 KB · Views: 73
  • adc ac1.png
    adc ac1.png
    231.8 KB · Views: 113
  • ADC NEG.rar
    51 KB · Views: 61
  • adc ac 3.png
    adc ac 3.png
    239.3 KB · Views: 111
Last edited:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top