Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Strange behaviour on pic ADc input

Status
Not open for further replies.
It gets us all at some point Thunderchild, I remember first working with a PIC12, took me absolutely ages to figure out that GP3 was input only, and that everything else needed to be switched off and to set the direction register correctly.

Glad you have finally got it sorted out.
 
Funny how a chip with just 8 pins can be so hard to work with. Baseline chips are even harder. Like 12f510 LOL
 
yep it is rewarding to see it working at last, now i just need to calibrate it
If you can afford the pin, put a precision 4.096V reference IC (i.e. 4mV per bit in 10 bit a-d mode) on the Vref pin. You would be very happy with the correlation to a DVM.

Having a battery fuel guage lit up with some t1 (low current) green, yellow, red led(s) has been indispensable for the truck camper battery. Fit the voltage windows to the battery discharge chart.

For a Deka AGM intimidator battery:
Code:
;
...
...
...
40% Green led
If (BatVolt > 1210 And BatVolt <= 1230) Then
 Set PortD.7 Off:Set PortD.6 Off:Set PortD.5 Off
  PortB = b'00011111'
End if
;30% Yellow led
If (BatVolt > 1185 And BatVolt <= 1210) Then
 Set PortD.7 Off:Set PortD.6 Off:Set PortD.5 Off
  PortB = b'00001111'
End if
;20% Yellow led
If (BatVolt > 1175 And BatVolt <= 1185) Then
 Set PortD.7 Off:Set PortD.6 Off:Set PortD.5 Off
  PortB = b'00000111'
End if
;10% Yellow led
If BatVolt > 1140 And BatVolt <= 1175 Then
 Set PortD.7 Off:Set PortD.6 Off:Set PortD.5 Off
 PortB = b'00000011'
 End if
;0% Red led
If BatVolt < 1140 Then
  Set PortD.7 Off:Set PortD.6 Off:Set PortD.5 Off
  PortB = b'00000001'
End if
 
well i was also after the lowest possible part count and with 15.6 mV resolution (on a 0-16 volt scale) i think it leaves enough margin to play with as accuracy to 0.1 v is fine, the original design is meant for a motobike so space is a premium, so what voltages would you suggest ?

my only worry is if it gets over 16 volts (which it should not) if it will damage the pic via the ADC pin but I'm not sure if just slapping a 5.1 v zenner on the input will help as it needs current though it to work proporly does't it ? and that will ruin the lenear working of the voltage divider to work
 
Put a current limiting resistor on the input pin like this
 

Attachments

  • like.PNG
    like.PNG
    3.4 KB · Views: 160
Your using gp4 pin 3 right . As long as you keep the pin below 20mA you should not have to worry. You probably don't need it
 
The first baseline PIC i used funnily enough was the 12F510, and yes, it is a nightmare to work with, but once you have that one sussed, the others are a breeze! Well, in terms of working out multiple pin assignment anyhow lol.
 
Thunderchild said,
well i was also after the lowest possible part count and with 15.6 mV resolution (on a 0-16 volt scale) i think it leaves enough margin to play with as accuracy to 0.1 v is fine, the original design is meant for a motobike so space is a premium, so what voltages would you suggest ?
The resolution isn't what bugged me on my battery meter, but the precision. The question being, is how do you calibrate the a-d readings, without some sophisticated lab instruments? I am all ears on this. In the end I put my faith (rightly or wrongly) in TI's precision voltage reference. The packages, I believe, are SOT23.

A reality check on this, is +/- 2 or 3% meaningful on a battery fuel guage?,....probably not.
 
Thunderchild said,The resolution isn't what bugged me on my battery meter, but the precision. The question being, is how do you calibrate the a-d readings, without some sophisticated lab instruments? I am all ears on this. In the end I put my faith (rightly or wrongly) in TI's precision voltage reference. The packages, I believe, are SOT23.

A reality check on this, is +/- 2 or 3% meaningful on a battery fuel guage?,....probably not.

Just calibrate against your multimeter - for a battery monitor it's far more accurate than you need.
 
Thunderchild said,The resolution isn't what bugged me on my battery meter, but the precision. The question being, is how do you calibrate the a-d readings, without some sophisticated lab instruments? I am all ears on this. In the end I put my faith (rightly or wrongly) in TI's precision voltage reference. The packages, I believe, are SOT23.

A reality check on this, is +/- 2 or 3% meaningful on a battery fuel guage?,....probably not.

My meter is accurate to 0.01 V (10 mV) and I want it to be accurate to 0.1 V or preferably 0.05 maybe so being +-15.6 mV is not a problem, I used a variable voltage supply and varied the voltage until the leds changed, taking a meter reading on each and then ajusting the program until i had the correct figures, a bit crude i know but it made the design a little less "scientific" and more easy
 
Nigel, Thunder,

And the consensus is.... using the precision voltage reference is overdoing it. Agreed. I get sidetracked by insignificant details, like all the time.
 
I think the general idea of the project is to keep an eye on the battery voltage and ensure that the system does not go over 15.5 volts, apparantly my friend's friend fried his electrics and got stuck in france with a £ 3000 bill becasue the alternator was rewound wrong (insurance paid up but he was still stuck abraod)
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top