CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug Reports on this forum. Send them to support@ccsinfo.com

how setup_ports() for RA2 to REF- and RA3 to REF+ PIC16F88

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
artohautala



Joined: 17 Nov 2011
Posts: 167

View user's profile Send private message Send e-mail

how setup_ports() for RA2 to REF- and RA3 to REF+ PIC16F88
PostPosted: Mon Nov 13, 2017 8:44 am     Reply with quote

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

Smile

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: 13391

View user's profile Send private message

PostPosted: Mon Nov 13, 2017 8:56 am     Reply with quote

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: 167

View user's profile Send private message Send e-mail

PostPosted: Mon Nov 13, 2017 9:29 am     Reply with quote

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: 13391

View user's profile Send private message

PostPosted: Mon Nov 13, 2017 11:16 am     Reply with quote

Yes. Smile
temtronic



Joined: 01 Jul 2010
Posts: 6219
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Mon Nov 13, 2017 11:28 am     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group