# Automatic Battery Charger Help Needed

1. ## Automatic Battery Charger Help Needed

I am designing an Automatic Battery Charger using PIC16F73. I am using a 9-0-9V 5A transformer for it. I will be designing a Buck Converter. The input voltages to the Buck Converters are as below.

The input voltage range to the transformer (230V to 9-0-9V 5A) is 170V to 245V

230V to 24V (9-0-9V)

N = Vsec/Vpri = 0.0783

Vsec = N * Vpri

Vsec(L) = 0.783 * 170 = 13.311

Vsec(M) = 0.104 * 245 = 19.1835

Vpk(L) = 13.311 * 1.1412 = 18.82

Vpk(M) = 19.1835 * 1.4142 = 27.13

So, my voltages are above 14.4V needed for boost charging and 13.8V used for trickle charging.

How should I proceed further ? PWM duty will be adjusted to get boost voltage and trickle charge voltages but how to detect the voltage needed to be applied to the battery that is 14.4V or 13.8V ?

I am designing like this.

When battery is not connected or battery is removed then charging stops and there will be no output voltage.
When battery is connected, it will measure the battery voltage and if battery voltage is less than 10.4V then charger will start in boost mode and while charging if battery voltage reaches 13.8V then charger will shift to trickle charge mode.

Is this method correct ?

I am using ACS712 5A type to monitor the battery current. If high current is drawn then charger will be switched off.

There will be saftey fuses.

Here is the rough schematic. I have not yet calculated the buck converter inductor and capacitor values.

- - - Updated - - -

This is the mosfet I will be using. This is the best mosfet I found.

FDP8860

or

STI260N6F6

or

STP260N6F6

Very low Rds(on) < 0.003 Ohms

My charging current will not exceed 2.5A.

So, power dissipated in mosfet

Pd(mosfets) will be 2 x 2.5 * 2.5 * 0.003 = 37.5 mW

2. ## Re: Automatic Battery Charger Help Needed

Consider to increase C1 to at least 4700 µF.

1 members found this post helpful.

3. ## Re: Automatic Battery Charger Help Needed

@FvM

Ok. Done.

I am trying to get information about charging current for 12V and 6V (max 12Ah) batteries but not getting.

What is the safe charging current for 6V and 12V max 12Ah batteries for boost charging and trickle charging ?

ADC interface circuit resistor values have not yet calculated. Here is new schematic. There was a mistake in 5V power Led connection. Have fixed it. Also I have to calculate Buck Inductor and Capacitor values.

This charger should be able to charge both 6V and 12V SLA batteries.

- - - Updated - - -

Edit: Sorry, the post got updated.

Please check the latest simulation. Also attached schematic in PDF format and simulation video without battery connected.

PWM and LO signal levels are correct but HO and VS signals are not correct. Why ? I still have to find the values of Buck Inductor and Capacitor. I am just checking the signals.

4. ## Re: Automatic Battery Charger Help Needed

Hi,

What is the safe charging current for 6V and 12V max 12Ah batteries for boost charging and trickle charging ?
Manufacturers of high qualitiy batteries provide thos informations in the battery datasheets. Or they provide global battery information on their web site.

Another good place for informations: http://batteryuniversity.com/

Klaus

1 members found this post helpful.

•

5. ## Re: Automatic Battery Charger Help Needed

What should I choose for duty ?

D = Vout / Vin

D(M - Boost) = 14.4 / 27.13 = 0.53

Should I choose 1% duty ?

I am referring this.

http://www.daycounter.com/LabBook/Bu...quations.phtml

Edit:

I got it. It is in percentage.

So, 53%

53% of 255 = 135.15 (255 duty value gives 100% duty in mikroC PWM library function).

6. ## Re: Automatic Battery Charger Help Needed

This is the final circuit. Buck Inductor and capacitor values have been calculated. PWM frequency is 84 KHz. I couldn't reduce this frequency.

Peak to Peak output ripple voltage is 50 mV.

Required current is 3A.

27.13V has to be dropped to 14.4V.

PWM duty is 53%.

Now I am writing code for the Automatic Battery Charger.

7. ## Re: Automatic Battery Charger Help Needed

The question I am going to ask now is related to this project only and hence I am asking it in this thread only.

I changed the Modfet to IRFP054N because its Rds(on) is 12 mOhms and easily available.

No I couldn't find out the pinout of this Mosfet. Please provide the pinout of this Mosfet.

8. ## Re: Automatic Battery Charger Help Needed

Hi,

No I couldn't find out the pinout of this Mosfet.
--> usually the first hit on any internet search "IRFP054N datasheet"

Klaus

9. ## Re: Automatic Battery Charger Help Needed

The problem was not in finding the datasheet. I have the datasheet but it doesn't show the pinout. I need to know which pin is G, D and S.

10. ## Re: Automatic Battery Charger Help Needed

Hi,

--> IR-datasheet --> Package outline drawing --> bottom right corner
--> Infineon-datasheet --> Package outline drawing --> right box --> Lead assignment --> HEXFET

Klaus

1 members found this post helpful.

•

11. ## Re: Automatic Battery Charger Help Needed

Thank you Klaus. I found it after you mentioned it.

12. ## Re: Automatic Battery Charger Help Needed

I had to change the PIC16F73 to PIC18F26K22 I/SP because I needed 84 KHz PWM and I/SP version of the PIC can run at 64 MHz (E/SP version runs at max 48 MHz). I checked the datasheet of the PIC18F26K22 but couldn't find the equation for calculating min and max PWM frequency for a given FOSC. Please direct me to the equation.

I read at microchip forum that if higher PWM frequency and also higher pwm resolution is needed then higher clock frequency has to be used. I am using ECCP module.

I require these PWM duties.

Buck PWM duties

6V battery

Boost Charge = 48% to 24%

Trickle Charge = 46% to 26%

12V battery

Boost Charge = 96% to 48%

Trickle Charge = 92% to 46%

- - - Updated - - -

Here I found this.

http://www.microchip.com/forums/m913239.aspx

min PWM frequency and max PWM frequency are

Fosc/16384 and Fosc/1024

So,

I can have PWM in the range of

64000000/16384 = 3906.25 Hz

and

64000000/1024 = 62.5 Khz

What should I do ? I need 84 KHz for my buck Converter for 100 uH and 68 uF buck inductor and capacitor values. I am not getting 4A or higer Ampere rated inductor for other inductance values.

13. ## Re: Automatic Battery Charger Help Needed

Problem solved. Got 1mH 2.3A Inductor from coilcraft.

Here are the calculations.

Buck Inductor and Capacitor and PWM frequency Calculations

Inductor choosen 1mH 3A

Max Charging current of 12V 12Ah battery is 10% of rated current = 0.1 * 12 = 1.2A

Peak to Peak ripple current = 30% of max Charging Current, Imax * 0.3 = 1.2 * 0.3 = 0.36A

Vin(max) = 30V

Vout = 14.4

PWM frequency = (14.4V * (30V - 14.4V)) / (0.36A * 30V * 1mH) = 224.64/0.0108 = 20800 = 20.8KHz

Capacitor Value = 0.36A / (8 * 20mV * 20800Hz) = 0.36A/3328 = 108.1731 uF

Capacitor selected is 100 uF 35V and 10uF 35V in parallel

Tpwm = 48.0769us

PWM Resolution = log10[4 * (PRx + 1)] / log10(2) = log10(4 * 96) / log10(2) = 8.5849625 bits

8.58 bits = 2^8.58 = 384

98% of 384 = 0.98 * 384 = 376.32

To get 14.4V Output from 30V input PWM duty will be

D = 384 * Vout/Vin = 384 * 14.4/30 = 184.32 = ~184

14. ## Re: Automatic Battery Charger Help Needed

I am posting in this thread because the question is related to this same project. I had mentioned that I had changed PIC18F to dsPIC33 but now I cahnged the MCU to dsPIC33FJ128MC802. I tested LCD and ADC part and they are working fine but the PWM part is not working. Attached it the Project. Also included Proteus file and Schematic in PDF format.

I am testing in real hardware. I was waiting for my dsPIC33 development board. Today I received Easy 24-33 v6 development board from mikroElektronika. I tested the project on it and I am getting incorrect PWM frequency. I am using PWMx_Mc_Y() library of mikroC PRO dsPIC. If I use PWM_X() library then I don't get any PWM but if I use PWM motor control library then I am getting incorrect PWM frequency.
I need just one 100 KHz PWM because Inductor value has been calculated as 100 uH 10.1A which is easily available. I can't change PWM frequency now. PCB Layout is being designed for the project.

Can't I get 100 KHz and 500 KHz (I need 500 KHz PWM for another project) from dsPIC33FJ128MC802 ?

I am using XT, HS, EC / w PLL

Crystal is 10 MHz and HS is selected as AOSC type.

80 MHz is the FOSC.

You can see from the picture that PWM frequency is 26.9 KHz.

15. ## Re: Automatic Battery Charger Help Needed

I am referring dsPIC33FJ128MC802 revision G datasheet but it doesn't show which pins are OCx pins. Please tell me in dsPIC33FJ128MC802 which pins are OC1, OC2, OC3 and OC4 pins. I am using SPDIP package dsPIC33.

- - - Updated - - -

I made these changes but still getting 26.9 KHz PWM instead of 100 KHz.

Code:
`pwm_duty = PWM1_Mc_Init(100000,1, 1, 0);`
- - - Updated - - -

I think Oscillator PLL configuration is incorrect. I have not configured any registers related to Oscillator in the code but only selected HS PLL in project settings. Now in the device datasheet page no. 145 mentioned that input to PLL VCO should not be more than 8 MHz but my HS Crystal is 10 MHz. So, how to configure oscillator to get 80 MHz Fosc ?

Also in the datasheet oscillator section I read that a 1 M Ohms resistor has to be connected across crystal but there is no 1M Ohm resistor in parallel to crystal on my Easy 24-33 v6 development board.

16. ## Re: Automatic Battery Charger Help Needed

I have referred device datasheet page no. 143 to 152 and have done these configurations but still not getting the correct PWM frequency of 100 KHz for 80 MHz Fosc.

I am getting now 34.0 KHz PWM.

Code:
```OSCCON = 0b0011001110100000;
CLKDIV = 0b0000000000000000;
PLLFBD = 0b0000000000100110;
ACLKCON = 0b0010111110000000;
OSCTUN = 0x00;```
I am now using 8 MHz Crystal

It is divided by 2 to get 4 MHz for the input of VCO. It is then multiplied by 40 to get 160 MHz which is in the valid range of 100 Mhz to 200 MHz and this is further divided by 2 to get 80 MHz Fosc.

Where is the problem in configuration ?

I can't measure the Fosc because it is internal and also my Rigol OScope can only measure 50 MHz. Crystal is Ok.

17. ## Re: Automatic Battery Charger Help Needed

I don't understand how you are setting the oscillator configuration. The regular way would be to select crystal oscillator with PLL in the configuration bits, but your configuration words select FRC in FOSCSEL. Changing the configuration at runtime in OSCCON requires an unlock sequence, I wonder if you are actually performing it.

You can read the OSCCON state at runtime with a debugger.

18. ## Re: Automatic Battery Charger Help Needed

I can't write to CONFIG words because mikroC doesn't give access to Config words. I can only configure Oscillator registers. Sorry, I forgot to post the picture in my last post. Here is the picture. It shows Oscillator settings.

These are the new configurations.

Code:
```OSCCON = 0b0011001110100000;
CLKDIV = 0b0000000000000000;
PLLFBD = 0b0000000000100110;
ACLKCON = 0b0010111110000000;
OSCTUN = 0x00;```

•

19. ## Re: Automatic Battery Charger Help Needed

O.K., I read the configuration words wrongly, the correct mode is already selected. Means only CLKDIV and PLLFBD must be written (if different from default value).

20. ## Re: Automatic Battery Charger Help Needed

I don't know what is default value at POR. I just read the datasheet and configured those registers. I think 80 MHz Fosc is not generating and I can't test it because my Rigol Oscope is limited to 50 MHz. I need to get 100 KHz PWM to complete the project. Other things are working.

--[[ ]]--