Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Battery charging firmware voltage mode problem

Status
Not open for further replies.

chanchal.chauhan

Full Member level 4
Joined
Apr 23, 2009
Messages
216
Helped
5
Reputation
10
Reaction score
1
Trophy points
1,298
Location
Hyderabad, India
Activity points
2,539
measure charging voltage

Hi,

I am using PIC 18F1330 microcontroller for my battery charging application.
Here I am controlling Battery current in CC mode & Battery voltage in CV mode in closed loop.
But here in CV mode my battery current & Pulse is varying.

Below are the details of my code.

#include<htc.h>

void osc_init();
void delay(unsigned int k);
void adc_init();
void read_volt();
void read_current();
void pwm_init();
long Multiplication16bit(int Mutiplicand, int Multiplier);

const unsigned int ref_voltage=2867; //14.0v
const unsigned int ref_voltage1=2847;//13.9v
const unsigned int ref_current=1332; //6.5Amps
unsigned int duty_cycle=9280,duty_cycle1=960;




void main()
{
long gain,gain2;
unsigned int gain1,gain3;
TRISB=0b00000000;
TRISA=0b01010011;
osc_init(); // 16Mhz internal ocillator
adc_init(); // adc init
while(1)
{
read_volt(); //Vs
gain=Multiplication16bit(adc_voltage, 666);
gain=gain*5;
gain1=gain>>10; //Battery voltage
read_current();//Is
gain2=Multiplication16bit(adc_current,360);
gain2=gain2*5;
gain3=gain2>>10; //Battery current
if(gain1>=ref_voltage) //
{
flag=1;
if(gain1==ref_voltage)
{
duty_cycle;
duty_cycle1;
}
else
{
++duty_cycle; //Decrement
--duty_cycle1;
}
}
else //CC Mode
{
if(gain3>=ref_current)
{
flag=0;
if(gain3==ref_current)
{
duty_cycle;
duty_cycle1;
}
else
{
++duty_cycle; //Decrement
--duty_cycle1;
}
}
else
{
if(flag==1)
{
duty_cycle;
duty_cycle1;
if(gain1<ref_voltage1) //ref_voltage1
{
--duty_cycle;
++duty_cycle1;
}
}
else
{
--duty_cycle;
++duty_cycle1;
}
}
}

if(duty_cycle>=9728)
{
duty_cycle=9728;
duty_cycle1=512; //480
}
if(duty_cycle<=6400)
{
duty_cycle=6400; //6399
duty_cycle1=3840;
}
pwm_init(); //Pwm initilisation
}
}

void adc_init()
{
ADCON1=0b00001100;
ADCON2=0b10001010; //Tacq=1.2usec
ADCON0=0b00000000;

}
void read_volt()
{
i=0;
for(i=0;i<16;i++) //Averaging 16 times
{
ADCON1=0b00001100;
ADCON2=0b10001010; //Tacq=1.2usec
ADCON0=0b00000000; //AN0 voltage
ADON=1;
GODONE=1;
while(GODONE) continue;
// GODONE=0;
ADIF=0;
adc_voltage=0;
adc_voltage=(ADRESH<<Cool+ADRESL;
result_temp=adc_voltage+result_temp;
}
adc_voltage=result_temp/16;
result_temp=0;

}
void read_current()
{
i=0;
for(i=0;i<16;i++) // Averaging 16 times
{
ADCON1=0b00001100;
ADCON2=0b10001010; //Tacq=1.2usec
ADCON0=0b00000100; //AN1 current
ADON=1;
GODONE=1;
while(GODONE) continue;
ADIF=0;
adc_current=0;
adc_current=(ADRESH<<Cool+ADRESL;
result_temp1=adc_current+result_temp1;
}
adc_current=result_temp1/16;
result_temp1=0;
// flag=1;
}


Any help is greatly appreciative.

Regards
Chanchal
 

pic measuring battery voltage

What is the problem you are facing??

Nandhu
 
stopped charging voltage change

Here I am controlling battery current & battery voltage by using pulse width modulation.
Battery is having three different modes of charging Constant Current, Constant Voltage & Float mode.
Presently we are using Constant current & Voltage mode.Here battery is working fine in CC mode but when its flips CC to CV mode my battery voltage, Battery current is continuously varying here my pwm pulse is also continuously varying.
The problem is battery current & voltage shouldn't be varying.
Please help me to solve this problem.
Any help is greatly appreciative.

Regards
Chanchal Chauhan
 

Hi chanchal.chauhan,

When you measure the battery voltage you cut the charging voltage with PWM or no?
You measure open circuit voltage or charge voltage on battery?
I think you should stop charging and measure the voltage very fast and then
continue charging.
 
When you measure the battery voltage you cut the charging voltage with PWM or no?
Here we are continuously monitoring the battery voltage & battery current & based on that duty cycle is changing.We are not cutting down the charging voltage with PWM.

You measure open circuit voltage or charge voltage on battery?
We are measuring charge voltage on battery. There is a difference in open circuit & charge voltage.We are controlling the battery voltage & current based on the charge voltage.

Please let me know if anything is wrong?

Thanks & Regards
Chanchal
 

In general, We should measure battery voltage, not charge voltage.
If battery is charging and we measure the voltage, we measured the charge battery voltage.
For current measurement we can't stop charging, because current will be zero.
But I think for voltage measurement we should stop charging for a moment and after measurement continue charging.

I'm not sure this problem but my opinion is it. If you say reasons of your opinion, I will be Convinced.

I want to know what is your battery? LiIon? SLA? or other?
If you have flowchart from your code please upload here for resolving your problem.
 
Is resolved your problem?
If it is possible for your, please send a flowchart from your firmware.

Regards
Hamzeh Nasajpour
 
Hi chanchal.chauhan,

I see the flowchart of your firmware.

I want to know is your problem is resolved or no?

And I have a question from you:
In CC mode system is working good. yes?
But in CV mode your Voltage and Current values are varying continuously. yes?
Now I want to know that, different between values is constant? This different value is increasing or decreasing?
 
Hi,

I want to know is your problem is resolved or no?
Not resolved, looking for solutions.

Attached are the test result for CCmode, CC-CV mode----Close loop & open loop test data for your reference.

Regards
Chanchal
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top