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

reading analogue voltage on A/D!!!

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







reading analogue voltage on A/D!!!
PostPosted: Tue Nov 01, 2005 12:20 pm     Reply with quote

hi guyz, i hope everyone is doing fine.

i want to read analogue voltage on the A/D of pic16f877. the problem is that the voltage varies from -1 --> 6 volts. now i believe that this kind of voltage can not be applied directly to the PIC as 6volts may damage it.
i had the idea of adding 1 volt to the analogue voltage so that i have a range of 0 --> 7 volts, and then half this voltage before applying it to the analogue pin of the PIC, so i would have a range of 0 --> 3.5 volts. and then i would compensate for these manipulations in the converted digital value. Now this solution seems kind of complicated for such a simple issue. can any one please suggest another simpler way of reading an analogue voltage ranging from -1 --> 6 volts.

best regards
Neutone



Joined: 08 Sep 2003
Posts: 839
Location: Houston

View user's profile Send private message

PostPosted: Tue Nov 01, 2005 12:59 pm     Reply with quote

I'm not sure but think a combination voltage divider will do it if the source can drive the resisters in this circuit. Assuming your running on 5 volts.
Code:
                 5V
                 |
                 R2
                 |
                 |
Source --- R1 ---+--- PIC in
                 |
                 |
                 R3
                 |
                GND


R1=R2*5
R2=R3
asmallri



Joined: 12 Aug 2004
Posts: 1630
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Tue Nov 01, 2005 5:39 pm     Reply with quote

Deleted - I goofed. I did not see the input was from -1 volt and the divider impedance was too high for the A/D as pointed out by PCM Programmer.
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!


Last edited by asmallri on Tue Nov 01, 2005 6:43 pm; edited 2 times in total
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Nov 01, 2005 6:01 pm     Reply with quote

Quote:
R1=20K

The impedance of the voltage divider circuit which feeds the PIC's
A/D pin must be kept under 10K, per the 16F877 data sheet.

What if he uses a voltage divider which divides the input range by 2
and then biases the bottom resistor at 1.0v so the output is 0 to 3.5v.

Code:

Vin           4.7K
-1.0v  >----/\/\/\/---------->  To PIC A/D pin 
  to                    |
+6.0v                   >
                        < 4.7K
                        >   
                        |
                      +1.0v       



------------
I just realized that my proposed solution is the Thevenin equivalent
to Neutone's circuit. Just a rough check gives approximate values
for his circuit of:

R1 = 4.7K
R2 = 27K
R3 = 6K
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