Mithun_K_Das
Advanced Member level 3
- Joined
- Apr 24, 2010
- Messages
- 899
- Helped
- 24
- Reputation
- 48
- Reaction score
- 26
- Trophy points
- 1,318
- Location
- Dhaka, Bangladesh, Bangladesh
- Activity points
- 8,254
unsigned int battery, main, over_load, temp, sw;
void main()
{
int i ;
long int charg, flash, alarm, main_ok;
DDRD = 0xFF;
DDRB = 0xFF;
DDRC= 0b0000010;
while(1)
{
battery = ADC_Read(1); // battery stasus check
main = ADC_Read(4); // main status check
over_load = ADC_Read(0); // o\L check
temp = ADC_Read(2); // temp check
sw = ADC_Read(3); // switch check.
if(sw < 512)
{
main_ok = 0;
charg = 0;
if((main <= 860) &&(main >= 737)) // main status check . main is ok.
{
main_ok++;
if(main_ok >= 10000) // main delay for surge protection.
{
PORTB2_bit = 1; //output triac on
PORTB5_bit = 1; // output indication on, non flashing
if(battery < 223) // check battery under 12V
{
charg++;
if(charg >= 100000)
{
PORTB0_bit = 1; // charging on by relay on.
flash++ ;
if(flash >= 10000)
{
PORTB5_bit = ~PORTB5_bit; // charging indication by toggleing main indicator.
flash = 0;
}
}
}
if(battery >= 275) // battery full charge.
{
PORTB0_bit = 0; // setting relay off.
PORTB5_bit = 1; // setting main indicator on, non flashing.
}
}
}
else
{
PORTB2_bit = 0; // setting output triac off.
PORTB5_bit = 0; // main indicator off.
if((battery < 195)&&(over_load > 150)&&(temp < 350))// check battery if lowr than 10.5V & overload & temperature
{
PORTD = 0x00; // main sinewave oscillator off.
PORTB3_bit = 1; // osc # 1 off.
PORTB4_bit = 0; // backup indicator off.
alarm++;
if(alarm > 10000)
{
PORTC5_bit = ~PORTC5_bit; // generating alarm
alarm = 0;
}
}
else // if all conditions are suitable then run the inverter.
{
PORTB3_bit = 0; // osc # 1 on.
PORTB5_bit = 0; // alarm off
PORTB4_bit = 1; // backup indicator on.
PORTB1_bit = 1; // inverter output switch(Triac) on.
// osc sinewave on
{
for(i=0;i<15;i++)
{
PORTD = (i);
Delay_us(32);
}
for(i=15;i>0;i--)
{
PORTD = (i);
Delay_us(32);
}
for(i=0;i<15;i++)
{
PORTD = (16*i);
Delay_us(32);
}
for(i=15;i>0;i--)
{
PORTD = (16*i);
Delay_us(32);
}
}
}
}
}
else
{
if(main > 737) // main is over 150V
{
PORTB5_bit = 1; // main availability indication on.
if(battery >= 275)
{
PORTB0_bit = 0; // charging off.
}
else // charging on...
{
PORTB0_bit = 1; // charging on.
flash++ ;
if(flash >= 10000)
{
PORTB5_bit = ~PORTB5_bit; // charging indication on by toggling main LED.
flash = 0;
}
}
}
}
}
}
///////////////////////////////////////////////////////////
Errors are shown in line 2.
please help me, I can't find any error... but still can't make it error free.
void main()
{
int i ;
long int charg, flash, alarm, main_ok;
DDRD = 0xFF;
DDRB = 0xFF;
DDRC= 0b0000010;
while(1)
{
battery = ADC_Read(1); // battery stasus check
main = ADC_Read(4); // main status check
over_load = ADC_Read(0); // o\L check
temp = ADC_Read(2); // temp check
sw = ADC_Read(3); // switch check.
if(sw < 512)
{
main_ok = 0;
charg = 0;
if((main <= 860) &&(main >= 737)) // main status check . main is ok.
{
main_ok++;
if(main_ok >= 10000) // main delay for surge protection.
{
PORTB2_bit = 1; //output triac on
PORTB5_bit = 1; // output indication on, non flashing
if(battery < 223) // check battery under 12V
{
charg++;
if(charg >= 100000)
{
PORTB0_bit = 1; // charging on by relay on.
flash++ ;
if(flash >= 10000)
{
PORTB5_bit = ~PORTB5_bit; // charging indication by toggleing main indicator.
flash = 0;
}
}
}
if(battery >= 275) // battery full charge.
{
PORTB0_bit = 0; // setting relay off.
PORTB5_bit = 1; // setting main indicator on, non flashing.
}
}
}
else
{
PORTB2_bit = 0; // setting output triac off.
PORTB5_bit = 0; // main indicator off.
if((battery < 195)&&(over_load > 150)&&(temp < 350))// check battery if lowr than 10.5V & overload & temperature
{
PORTD = 0x00; // main sinewave oscillator off.
PORTB3_bit = 1; // osc # 1 off.
PORTB4_bit = 0; // backup indicator off.
alarm++;
if(alarm > 10000)
{
PORTC5_bit = ~PORTC5_bit; // generating alarm
alarm = 0;
}
}
else // if all conditions are suitable then run the inverter.
{
PORTB3_bit = 0; // osc # 1 on.
PORTB5_bit = 0; // alarm off
PORTB4_bit = 1; // backup indicator on.
PORTB1_bit = 1; // inverter output switch(Triac) on.
// osc sinewave on
{
for(i=0;i<15;i++)
{
PORTD = (i);
Delay_us(32);
}
for(i=15;i>0;i--)
{
PORTD = (i);
Delay_us(32);
}
for(i=0;i<15;i++)
{
PORTD = (16*i);
Delay_us(32);
}
for(i=15;i>0;i--)
{
PORTD = (16*i);
Delay_us(32);
}
}
}
}
}
else
{
if(main > 737) // main is over 150V
{
PORTB5_bit = 1; // main availability indication on.
if(battery >= 275)
{
PORTB0_bit = 0; // charging off.
}
else // charging on...
{
PORTB0_bit = 1; // charging on.
flash++ ;
if(flash >= 10000)
{
PORTB5_bit = ~PORTB5_bit; // charging indication on by toggling main LED.
flash = 0;
}
}
}
}
}
}
///////////////////////////////////////////////////////////
Errors are shown in line 2.
please help me, I can't find any error... but still can't make it error free.
Last edited: