firoz_gpcl
Newbie level 4
- Joined
- Jul 31, 2010
- Messages
- 7
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Location
- Bangladesh
- Activity points
- 1,341
Dear friend Binay bs
I try in mikroC. No error but not simulations. Would u please up load ISIS file for me.
Firoz
[syntax = mikroC]
//Solar Charge Controller
#define batfullled PORTC.F5
#define batlowled PORTA.F4
#define solarsense PORTC.F2
#define spulse PORTA.F5
#define olsense PORTC.F3
#define load PORTA.F2
#define solarled PORTC.F4
#define charging PORTA.F1
#define batsense PORTC.F1
#define tempsense PORTC.F0
//main
void main()
{
unsigned long int ssvalue,olvalue;
unsigned long int bsvalue,tsvalue;
unsigned long int lon_value = 409; //(for 2V)
unsigned long int htvalue = 665; //(for 3.25V)
unsigned long int ltvalue = 563; //(for 2.75)
unsigned long int olvoltage = 819; //(for 4V)
unsigned long int hbat = 778; //(for 3.8V)
unsigned long int lbat = 594; //(for 2.9V)
unsigned long int htemp = 196; //(for 49 C)
TRISA = 0b001011; // 0x0B;
TRISC = 0b001111; // 0x0F;
ANSEL = 0xF0; // analog channel i/p o/p config
ADCON1 = 0x20; // select conversion clock
CMCON = 0x07; //comparator off
solarled = 1; //led ON to show uc working
while(1)
{
ssvalue = ADC_Read(6);
olvalue = ADC_Read(7);
bsvalue = ADC_Read(5);
ADCON0.VCFG = 1;
tsvalue = ADC_Read(4);
ADCON0.VCFG = 0;
if ((ssvalue >= ltvalue) && (ssvalue <= htvalue) && (bsvalue < hbat) && (tsvalue < htemp))
{
spulse = 1;
}
else if (tsvalue >= htemp || bsvalue >= hbat)
{
spulse = 0;
}
else
{ spulse = 0;
}
if ((ssvalue <= lon_value) && (olvalue < olvoltage) && (bsvalue > lbat) && (tsvalue < htemp))
{
load = 1;
}
else if ((ssvalue >= lon_value) || (olvalue >= olvoltage) || (bsvalue <= lbat) || (tsvalue >= htemp))
{
load = 0;
}
if (bsvalue >= hbat)
{
batfullled = 1;
}
else if(bsvalue <= lbat)
{
batlowled = 1;
}
else
{
batfullled = 0;
batlowled = 0;
}
}
}
I try in mikroC. No error but not simulations. Would u please up load ISIS file for me.
Firoz
[syntax = mikroC]
//Solar Charge Controller
#define batfullled PORTC.F5
#define batlowled PORTA.F4
#define solarsense PORTC.F2
#define spulse PORTA.F5
#define olsense PORTC.F3
#define load PORTA.F2
#define solarled PORTC.F4
#define charging PORTA.F1
#define batsense PORTC.F1
#define tempsense PORTC.F0
//main
void main()
{
unsigned long int ssvalue,olvalue;
unsigned long int bsvalue,tsvalue;
unsigned long int lon_value = 409; //(for 2V)
unsigned long int htvalue = 665; //(for 3.25V)
unsigned long int ltvalue = 563; //(for 2.75)
unsigned long int olvoltage = 819; //(for 4V)
unsigned long int hbat = 778; //(for 3.8V)
unsigned long int lbat = 594; //(for 2.9V)
unsigned long int htemp = 196; //(for 49 C)
TRISA = 0b001011; // 0x0B;
TRISC = 0b001111; // 0x0F;
ANSEL = 0xF0; // analog channel i/p o/p config
ADCON1 = 0x20; // select conversion clock
CMCON = 0x07; //comparator off
solarled = 1; //led ON to show uc working
while(1)
{
ssvalue = ADC_Read(6);
olvalue = ADC_Read(7);
bsvalue = ADC_Read(5);
ADCON0.VCFG = 1;
tsvalue = ADC_Read(4);
ADCON0.VCFG = 0;
if ((ssvalue >= ltvalue) && (ssvalue <= htvalue) && (bsvalue < hbat) && (tsvalue < htemp))
{
spulse = 1;
}
else if (tsvalue >= htemp || bsvalue >= hbat)
{
spulse = 0;
}
else
{ spulse = 0;
}
if ((ssvalue <= lon_value) && (olvalue < olvoltage) && (bsvalue > lbat) && (tsvalue < htemp))
{
load = 1;
}
else if ((ssvalue >= lon_value) || (olvalue >= olvoltage) || (bsvalue <= lbat) || (tsvalue >= htemp))
{
load = 0;
}
if (bsvalue >= hbat)
{
batfullled = 1;
}
else if(bsvalue <= lbat)
{
batlowled = 1;
}
else
{
batfullled = 0;
batlowled = 0;
}
}
}