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 CCS Technical Support

ADC Vref and ISCP-CLK on PIC16F68x need some input

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



Joined: 08 Sep 2003
Posts: 105
Location: New Castle, DE

View user's profile Send private message

ADC Vref and ISCP-CLK on PIC16F68x need some input
PostPosted: Fri May 19, 2006 9:49 am     Reply with quote

This is what I'm trying to do is measure the VDD to the PIC. I'm not in control of the supply voltage that is being controlled by another vender.
I'm working with the 16F688 or 16F68x to 16F690.
Mad And I see that in Microchip in there infinite wisdom they put the analog V ref pin on the same pin as the ICSP-CLK pin.
Will I need the ICSP-CLK pin for programming and in the final product it will be RS232 and field up-grade programming.
Ok I can move my 232 and put the Vref back on the ICSP-CLK pin but I will need to isolate the ISCP-CLK from the Vref during programming some way hardware wise. This can not be a jumper because the unit will be sealed from the customer.
Any ideas out there? Question
Idea The only think that I came up with is to leave my 232 and ICSP-LCK the same and put a voltage ref on one of the other ANx input and on another ANx input my voltage divider for VDD then set the PIC to use VDD for ref.
Then in software read the ANx with the Vref on it and divide the Vref voltage by the reading getting a floating point number and use that to multiply the reading by from the ANx of the divider.

Vref Voltage = 2.5V
ANx Vref reading = 511
ANx Vdivider = 716 (3.5Vdc)
Voltage divider factor = 1.4285

2.5V/511 = .004892
.004892 X 716 = 3.5026Vdc
3.0526 X 1.4285 = 5.00346 VDD

Is there a smilpler way to do this? Question
Can this be done with int math? Question

Thanks in advance All Exclamation
Tom
rnielsen



Joined: 23 Sep 2003
Posts: 852
Location: Utah

View user's profile Send private message

PostPosted: Fri May 19, 2006 10:18 am     Reply with quote

If you're trying to read what level the supply VCC is and simply using VCC as the reference, why not just have it internally referenced? This will leave your other pins available to use. Just remember, as your VCC drops so will your measured value and you could end up with the same bit reading. Make sure your divider network is designed so you will get different readings as your voltage shifts.

Ronald
newguy



Joined: 24 Jun 2004
Posts: 1909

View user's profile Send private message

PostPosted: Fri May 19, 2006 11:05 am     Reply with quote

http://www.ccsinfo.com/forum/viewtopic.php?t=24560&start=15

If you scroll down that page a bit, you'll find a method of detecting battery voltage that will give an increase in A/D reading as the battery/power supply voltage falls. No external A/D reference voltage is necessary.

Just look for the post by me, and then the basic idea was improved by the suggestions of others in following posts.
steve_elliott



Joined: 20 May 2006
Posts: 2

View user's profile Send private message

how to determine PIC's supply voltage
PostPosted: Sat May 20, 2006 10:48 am     Reply with quote

If you have another analog input avaliable, use the pic's VCC as a reference and tie a cheap lower voltage reference to the unused pin and measure what the PIC thinks the voltage is. The PIC's VCC is:
the ideal VCC*(a/d count for the reference voltage at ideal VCC)/(a/d count you actually measure).

So if you have an ideal supply of 5V, an actual supply of 4.6V and a 2.5V reference (ideal counts = 2.5V/5V*1023 = 511), your pic will convert the 2.5V to 2.5/4.6*1023 = 556 counts. Then your program determines the VCC to be 5V*511/556 = 4.595V.

If your temperature is moderately stable, you can use an LED for the voltage reference instead, since a $0.10 green LED has about a 2.4V drop. If you use an LED or a really low cost zener diode you may have to calibrate each unit, depending on the accuracy you need to measure the input 5V. 5% accurate zener diodes are pretty common, too.
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