abinesh raja
Newbie level 6
hello,
I am doing a project regarding intelligent battery charger for than i am using pwm from the micro controller to change the voltage using fet. In order to obtain constant voltage i am using adc to control the voltage. But i am having problem in my program in changing the pwm signal. Can anyone help pls.
- - - Updated - - -
- - - Updated - - -
Both are working separately i need to make the pwm voltage constant foe the battery charging.
can anyone help pls its urgent for me.
I am doing a project regarding intelligent battery charger for than i am using pwm from the micro controller to change the voltage using fet. In order to obtain constant voltage i am using adc to control the voltage. But i am having problem in my program in changing the pwm signal. Can anyone help pls.
- - - Updated - - -
Code:
#include<htc.h>
#include<pic.h>
#include"delay.c"
float val;
float temp=1.5;
char pw=0;
int read_adc()
{
DelayMs(10);
GODONE=1;
DelayMs(10);
val=ADRES;
val=val;
while(GODONE);
return val;
}
void pwm()
{
TRISB=0b00000000;
PR2=0b11111001;
CCP1CON=0b00111100;
TMR2IF=0;
GIE=1;
PEIE=1;
T2CON=0b00000100;
}
void adc()
{
PORTB=0;
TRISB=0b00000000;
PORTA=0x00;
TRISA=0x01;
ADCON0=0x81;
ADCON1=0x40;
}
main()
{
adc();
pwm();
while(1)
{
read_adc();
if(val>temp)
{
pw--;
CCPR1L=pw;
}
if(val<temp)
{
pw++;
CCPR1L=pw;
}
}
}
- - - Updated - - -
Both are working separately i need to make the pwm voltage constant foe the battery charging.
can anyone help pls its urgent for me.