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

Problem with ADC

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



Joined: 28 Oct 2010
Posts: 4

View user's profile Send private message

Problem with ADC
PostPosted: Mon Nov 29, 2010 4:17 pm     Reply with quote

Hi,

I'm building an intelligent battery charger to charge Ni-MH, Ni-Cd and iPod (Li-Ion) batteries for my final project. I'm using the PWM of the PIC16F877A in order to vary the duty cycle of the MOSFET in my buck converter to get different charging currents. The PIC controls the charging stages using the analog voltages of the battery measured with the PIC. The converted ADC battery voltage is displayed on an LCD.

I used a voltage divider with the battery in order to limit the current into ADC of the PIC. Initially, I tried to read the battery voltage directly at the point between the two resistors of the voltage divider, but my readings shown on the LCD were all over the place and it was not stable. I was using the standard Vref+ as 5V and Vref- as ground. I realized when testing separately that when I connect the negative terminal of the battery to ground, it gives me the correct stable voltage. However, the problem is that in my design I cannot ground the negative of the battery terminal, as it will affect the rest of my circuit. Anybody have an idea of what I should do?

The link to my schematic is:
http://img638.imageshack.us/img638/8562/ece445batterychargersch.jpg

The battery and the voltage divider is in the top right. I'm using resistors 3.9 K and 14.93 K ohms.

Thanks a lot.[/img]
gpsmikey



Joined: 16 Nov 2010
Posts: 588
Location: Kirkland, WA

View user's profile Send private message

PostPosted: Mon Nov 29, 2010 4:51 pm     Reply with quote

I would consider changing the design of the buck converter/drive to it so that the negative of the battery was grounded. Having both ends of the battery floating at some intermediate voltage just makes life difficult (as you have discovered). You also need to make sure your voltage sampling is synchronized with the switching so that you are measuring the voltage at the same time each time. It has been a while since I looked at charging circuits, but it seems to me that some of those chemistries are fairly critical on charge level detection (not a big change signals "full").

mikey
_________________
mikey
-- you can't have too many gadgets or too much disk space !
old engineering saying: 1+1 = 3 for sufficiently large values of 1 or small values of 3
temtronic



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

View user's profile Send private message

PostPosted: Mon Nov 29, 2010 5:44 pm     Reply with quote

I can't really see the schematic well....however... with a floating battery you could measure the +ve side with one analog input, then measure the -v of the battery with another input. Subtract the two and the difference should be the battery voltage.

Also be aware that any noise, EMI, etc. will wreck havoc with your measuring. That buck convertor will need filtering, power supply lines as well. Careful attention to grounds and returns are important.

I prefer good old linear supplies for battery charging, they are very, very quiet and easy to monitor for charging current and voltage levels.
Yes, 'old school', but it's well proven and quick to implement.
sharat68



Joined: 28 Oct 2010
Posts: 4

View user's profile Send private message

PostPosted: Mon Nov 29, 2010 10:47 pm     Reply with quote

So I changed my buck converter design so that the ground is at the negative battery terminal and I'm able to read the correct stable voltage now. However, I ran into another problem. Now that I changed my design, I need to use a high-side driver for my MOSFET. The one I'm trying to use is the IR2117. I connected it the way it says in the data sheet. But, I'm not getting anything in the output of the driver. I'm not sure if it is even turning on. Any idea of what's wrong?

Here's the datasheet:

http://electronix.org.ru/datasheet/InternationalRectifier/IR2117.PDF
gpsmikey



Joined: 16 Nov 2010
Posts: 588
Location: Kirkland, WA

View user's profile Send private message

PostPosted: Mon Nov 29, 2010 11:52 pm     Reply with quote

I can't get the datasheet to load, however, you just have to verify the gate drive looks good, then move on to checking the output. I assume you have a scope available to look at the output (or a voltmeter if you are at a low enough switching rate).If you are switching fairly fast, but want to slow it down to measure the signals with a voltmeter for example, change the clock frequency so it is slow enough to measure voltages. Put a dummy load across it if necessary so you can see switching.

mikey
_________________
mikey
-- you can't have too many gadgets or too much disk space !
old engineering saying: 1+1 = 3 for sufficiently large values of 1 or small values of 3
gpsmikey



Joined: 16 Nov 2010
Posts: 588
Location: Kirkland, WA

View user's profile Send private message

PostPosted: Wed Dec 01, 2010 5:29 pm     Reply with quote

In snooping around for something else, I came across this pdf file on a smart NiMH battery charger from Samsung. You might want to check it over and get some ideas from there - looked like some good info.
http://www.samsung.com/global/business/semiconductor/products/microcontrollers/downloads/S3F94xx_BatteryCharger_AN_REV000_060109.pdf

mikey
_________________
mikey
-- you can't have too many gadgets or too much disk space !
old engineering saying: 1+1 = 3 for sufficiently large values of 1 or small values of 3
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