Post circuit. Use opto isolator for relay. Relay circuit should be isolated from MCU circuit. Relay switching is hanging the MCU as relay and MCU use the same power supply. Give details about relay used.
Post circuit. Use opto isolator for relay. Relay circuit should be isolated from MCU circuit. Relay switching is hanging the MCU as relay and MCU use the same power supply. Give details about relay used.
if battery voltage was the case it should have had trouble during ignition but if the generator does not start it keeps trying for the limited attempts and then waits up for the reset and if AC become available during starting process it stop the ignition attempts and waits till the light go again there is no issue with the main or ignition issue starts after the generator is functioning.During starting (cranking time) battery voltage may go down too much and can be the cause of the trouble. So measure the battery voltage at that time using a voltmeter.
#include<REG51.h>
sbit ac=P3^7;
sbit gen=P3^6;
sbit sw=P0^4;
sbit ign=P0^3;
sbit del=P0^0;
sbit chk=P0^1;
sbit rs=P1^2;
sbit ro=P1^3;
sbit ato=P1^0;
sbit man=P1^1;
sbit acrel=P0^2;
void delay(unsigned int msec )
{
int i ,j ;
for(i=0;i<msec;i++)
for(j=0; j<124; j++);
}
void main()
{
int acstate=1;
int genstate=0,ngs=0,nacs=0,i; //setting generator initial state to off ngs and nacs are new states of generator and ac
int atos=1,mans=0;
//int rss=0,ros=0,stt,mid,end;
ac=1; gen=1;// setting input pins
sw=0;ign=0;del=0;chk=0;acrel=0;man=1;ato=1;//setting auto and manual to input
while(1)
{
if(atos==1&&mans==0)//when generator is on auto state
{
while(1)
{
if(!man)//if manual button is pushed it will check the state of the button for 2 second to make sure state remains same
{
for(i=0;i<200;i++)
{
if(!man)
{
delay(10);
continue;
}
else
break;
}
if(i>19)
{mans=1;atos=0;break;}
}
for(i=0;i<100;i++)//sampling the state of the AC and Generator for any change for 2 second to make sure state remains same
{
ngs=!gen; nacs=!ac;//storing new generator and ac states
delay(10);
if(ngs==!gen&&nacs==!ac)//if previous state is same as before delay keep it
continue;
nacs=acstate;ngs=genstate;break;
}
if(acstate!=nacs||genstate!=ngs)
{ acstate=nacs;genstate=ngs;
if(!(acstate)&&!(genstate))
{int x=1;sw=0;chk=0;ign=0;delay(2000);
do
{
del=1;sw=1;chk=1;
delay(3000);
ign=1;
for(i=0;i<20;i++)
{
if(!gen||!ac)
{ign=0;chk=0;break;}
delay(100);
}
chk=0;
for(i=0;i<20;i++)
{
if(!gen||!ac)
{ign=0;break;}
delay(100);
}
ign=0;
delay(3000);
while(x>=4&&gen){del=0;sw=0;}
x++;
}while(gen&&ac);
}
else if(acstate&&genstate)
{
del=1;
delay(5000);
sw=0;
del=0;
}
else if(acstate&&!(genstate))
{sw=0; del=0;}
else if(!acstate&&genstate)
{
delay(60000);
del=0;
}
}
}
}
else if(mans && ! (atos))
{
while(1)
{ if(!ato)
{
for(i=0;i<20;i++)
{
if(!ato)
{
delay(100);
continue;
}
else
break;
}
if(i>19)
{mans=0;atos=1;}
}
if(atos&&!ac)
{ atos=1;mans=0;del=1; delay(5000);sw=0;del=0;acrel=0;
break;
}
else if(atos&&ac)
{ atos=1;mans=0;acrel=0;break;}
//rss=!rs;ros=!ro;
sw=1;
/*if(!gen)
acrel=1;
else
acrel=0;
if(rss&&!ros)
{
if(gen)
{int x=1;
do
{
del=1;sw=1;chk=1;ign=1;
delay(2500);
chk=0;
delay(1000);
ign=0;
delay(3000);
while(x>=4&&gen){del=0;sw=0;}
x++;
}while((gen));
delay(60000);
del=0;
}
}
else if(ros&&!rss&&!gen)
{
del=1;
delay(10000);
sw=0;
del=0;
acrel=0;
}
}
}*/
}
}
}
}
but after some a while MCU seems to have stuck up as it turn of the switch relay causing the generator to shutoff.
i changed the sampling time for ac and generator to 5 sec i.e. it reads the ac and generator state and then compares these values with current state after 5 seconds. for once i thought that my problem is resolved as generator worked until the light came back. but now once again it works for 4 5 minutes and then stops.If there is a bug, then your system should not work during test operation, which you already have done successfully.
Yes the generator is not diesel its small 2.5KW stand by generator and how to rectify the EMI issue any suggestions ?????As you said about ignition, so your generator has spark plugs (not a diesel generator). EMI from spark plug cables also needed to be considered.
the zener was from previous design where i used arduino uno as cpu but then i shifted to cheaper 89s51 and it can cause any issue as voltage is on .7 volts at VBE and transistor is working fine.You don't need 5.1V zener at the base of transistors because 0.7 to 0.8 V VBE is enough for transistor to get forward biased. Why 5.1V zener when you don't have to apply more than 0.8V to forward bias BC547 ?
ic works fine in test circuits and when ic is connect VCC is 4.05 volts which is within working range.Agree with post #12.
Besides supply current of AT89C51 can be maximum 20mA (from datasheet). So 100 ohms at output of U2 can not be accepted due to unacceptable IR drop (2V).
Also connecting a suitable resistor between base and emitter of Q1 and also Q2 will make them immune to weak signals.
See the suggested part of the circuit below.
#include<REG51.h>
sbit ac=P3^7;
sbit gen=P3^6;
sbit sw=P0^4;
sbit ign=P0^3;
sbit del=P0^0;
int count=0;
void acok();
void noac();
void delay(unsigned int msec )
{
int i ,j ;
for(i=0;i<msec;i++)
for(j=0; j<124; j++);
}
void main()
{
int acstate,i=0;
ac=1; gen=1;
sw=0;ign=0;del=0;
while(1)
{
if(!ac)//sampling when AC is ok
{
for(i=0;i<20;i++)
{ delay(100);
if(!ac)
continue;
acstate=0;
}
if(i==20)
acstate=1;
}
if(ac)//sampling when there is no light
{
for(i=0;i<20;i++)
{ delay(100);
if(ac)
continue;
acstate=0;
}
if(i==20)
acstate=0;
}
if(acstate)
acok();
else if(!acstate)
noac();
}
}
void acok()
{
if(!count)//enters this part only once when count is zero
{ del=1; delay(5000);
sw=0;del=0;
}
count=1;
}
void noac()
{
if(count)// attemps to start only once when AC is off
{
sw=0;chk=0;ign=0;delay(2000);
del=1;sw=1;ign=1;
delay(8000);//8 second for one time ignition
ign=0;
delay(60000);
count=0; del=0;
}
}
ic works fine in test circuits and when ic is connect VCC is 4.05 volts which is within working range.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?