View previous topic :: View next topic |
Author |
Message |
artohautala
Joined: 17 Nov 2011 Posts: 187
|
how setup_ports() for RA2 to REF- and RA3 to REF+ PIC16F88 |
Posted: Mon Nov 13, 2017 8:44 am |
|
|
Hello,
I'm trying to setup analog port RA0 to measure analog signal betveen 2...3
V instead of 'normal' 0...5V...
...because that way I can get 1023 steps for 1V instead of getting if I use
5V reference I get only 1023/5 steps ... about 205 steps when using 10 bit
AD-conversion ...
... but is it possible to define REF- pin RA2 to be 2V and pin RA3 to be 3V
so I can get 2...3 V ... 2V = AD-result 0 and 3v is AD-result 1023 ?
Please advise me ... I'll be very pleased if you will.
Best regards for you all
is this OK:
Code: | setup_adc_ports(sAN2 | VREF_VREF | VREF_LOW);
setup_adc_ports(sAN3 | VREF_VREF | VREF_HIGH); |
-arto-
Last edited by artohautala on Mon Nov 13, 2017 9:05 am; edited 1 time in total |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19518
|
|
Posted: Mon Nov 13, 2017 8:56 am |
|
|
It is possible to apply 2v to RA2, and 3V to RA3, and set the ADC to use these as it's reference. Needs you to have an accurate voltage source to do this.
However, won't work.
There is a minimum voltage span for the ADC. Data sheet for your chip. Try to operate below this, and monotonicity of the ADC is no longer guaranteed. Vref (min). 2.2v (rising to 2.5v for the full temperature range).
You need to amplify your signal. |
|
|
artohautala
Joined: 17 Nov 2011 Posts: 187
|
|
Posted: Mon Nov 13, 2017 9:29 am |
|
|
Ttelmah wrote: | It is possible to apply 2v to RA2, and 3V to RA3, and set the ADC to use these as it's reference. Needs you to have an accurate voltage source to do this.
However, won't work.
There is a minimum voltage span for the ADC. Data sheet for your chip. Try to operate below this, and monotonicity of the ADC is no longer guaranteed. Vref (min). 2.2v (rising to 2.5v for the full temperature range).
You need to amplify your signal. |
Thanks Ttelmah for your very professional knowledge,
and get better way.
So I have 5V reference ic REF02 and I use that for PIC REF+ to RA3 and REF- is GND and I use opamp (LMC662 rail to rail opamp) to be as differential amplifier.
So I can convert 2...3V to 0...5V for getting 10 bits AD-result 0...1023.
Did I understood right ?
Thank you and all the best.
-arto- |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19518
|
|
Posted: Mon Nov 13, 2017 11:16 am |
|
|
Yes. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9229 Location: Greensville,Ontario
|
|
Posted: Mon Nov 13, 2017 11:28 am |
|
|
also...
be sure to use real good filtering of the opamp power supply as well as inputs. ANY 'ripple' WILL get read by the ADC.
Digital is easy...analog is 'fun'
JAy |
|
|
|