Qaisar Azeemi
Full Member level 5
- Joined
- Feb 11, 2011
- Messages
- 315
- Helped
- 16
- Reputation
- 32
- Reaction score
- 15
- Trophy points
- 1,298
- Location
- Peshawar, Pakistan, Pakistan
- Activity points
- 3,829
STATUS.IRP = 0;
STATUS.IRP = 1;
STATUS.IRP = 1;
// OUTPUTS
#define GEN_CONT PORTE.f2
#define LED PORTB.f2
#define MAIN_CONT PORTC.F0
#define CHOWK PORTC.F1
#define IGNITION PORTC.F2
#define SELF PORTC.F3
// INPUTS
#define GEN PORTA.F0
#define MAIN PORTA.F1
#define ENTER PORTD.F0
#define RESET PORTD.F1
#define UP PORTD.F2
#define DOWN PORTD.F3
//CONSTANTS
#define T 100 //DELAYS
#define P 1 //FOR MAIN AND GEN INPUTS
#define A 0 //FOR MAIN AND GEN INPUTS
sbit LCD_RS at RD5_bit;
sbit LCD_EN at RD4_bit;
sbit LCD_D4 at RC4_bit;
sbit LCD_D5 at RC5_bit;
sbit LCD_D6 at RC6_bit;
sbit LCD_D7 at RC7_bit;
sbit LCD_RS_Direction at TRISD5_bit;
sbit LCD_EN_Direction at TRISD4_bit;
sbit LCD_D4_Direction at TRISC4_bit;
sbit LCD_D5_Direction at TRISC5_bit;
sbit LCD_D6_Direction at TRISC6_bit;
sbit LCD_D7_Direction at TRISC7_bit;
unsigned char cnt;
void interrupt()
{
if(TMR0IF_bit)
{ cnt++;
TMR0IF_bit=0;
if(cnt>=10)
{
LED=~LED;
cnt=0;
}
TMR0=0;
}
}
void gen(void);
void start(void);
void main()
{
unsigned int i=0,x=0,j=0; //i=loops ; x=passward ; J=While lock
//..............INITIALIZATIONS............................................
/* ANSEL = 0; // Configure AN pins as digital I/O
ANSELH = 0;
C1ON_bit = 0; // Disable comparators
C2ON_bit = 0; */
// CONFIGURING SFRs:
cnt=0;
TMR0=0; // loading vlaue of timer0 interrupt
OPTION_REG=0x87; // for timer 0; presscaller 1; 256
ADCON1=0x06; // adc reg initialization
INTCON=0xA0; // for timer0 ; interrupt reg initilization
// STATUS.F7=0;
//STATUS.IRP=0;
//asm BCF STATUS,IRP
// OUTPUTS:
TRISB.f2 = 0x00; //led out put
TRISE.F2=0; // gen cont output
TRISC=0x00; // portC output For LCD
PORTC=0X00; // initilization port c
// INPUTS:
TRISD.F0=0XFF; // ENTER
TRISD.F1=0XFF; // RESET
TRISD.F2=0XFF; // UP
TRISD.F3=0XFF; // DOWN
TRISA = 0xff; // port A as input
// TRISD.F4=0XFF; ALREADY DIRECTED AT LCD INITILIZATION
// TRISD.F5=0XFF;
//................................................................................
lcd_init();
Delay_ms(500);
if(MAIN==P) // if main is Present.
{
start();
}
while(1)
{
/* if(ENTER==0)
{
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF);
Lcd_Out(1,1,"Enter Passward");
while(ENTER==0)
{
Lcd_Out(1,x,"Enter Passward");
Lcd_Out(1,1,j);
}
Delay_ms(1000);
} */
if(MAIN==A) // if main is absent.
{
Delay_ms(4000); // wait for 4 seconds to ensure power failure
if(MAIN==P) //check again
continue;
//Delay_ms(1000);
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF);
Lcd_Out(1,1,"Mains Not Avail");
Lcd_Out(2,1,"Starting Genset");
Delay_ms(1000);
gen();
}
else // if main is present .........
{
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF);
Lcd_Out(1,1,"Mains ok.."); // Write text in first row
Lcd_Out(2,1,"Mains Overload");
Delay_ms(2000);
// GEN_CONT=0; //Turn off generator contactor
//MAIN_CONT=1; //Turn on main contactor
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Out(1,3,"Shenztech"); // Write text in first row
Lcd_Out(2,4,"Pvt Ltd");
Delay_ms(1000);
}
for(i=0; i<96; i++)
{
Lcd_Cmd(_LCD_SHIFT_RIGHT);
Delay_ms(T);
if(MAIN==A)
{
i=96;
}
}
} // while
} // main
//..............................;;;;;;;.........................................
void gen()
{
int i;
MAIN_CONT=0;
IGNITION=1;
Delay_ms(2000);
CHOWK=1;
Delay_ms(5000);//Chowk on for 5 seconds
CHOWK=0;
for(i=0; i<3; i++)
{
if(i==2)
{
CHOWK=1;
Delay_ms(5000);//Chowk on for 5 seconds
CHOWK=0;
}
SELF=1;
Delay_ms(2000); //self on for 2 seconds
SELF=0;
Delay_ms(4000); //self off for 4 seconds
if(MAIN==P) //if Main resumes
{
i=3;
GEN_CONT=0;
IGNITION=0;
SELF=0;
Delay_ms(2000); //self on for 2 seconds
MAIN_CONT=1;
}
if(GEN==P) //if generator ON
{
i=3;
}
}
if(GEN==P && MAIN==A) // if generator ON
{
Delay_ms(1000);
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF);
Lcd_Cmd(_LCD_MOVE_CURSOR_RIGHT);
Lcd_Out(1,1,"Warming Up..."); // Write text in first row
Delay_ms(5000);
GEN_CONT=1; // transfer load on genset after warmup
Delay_ms(300);
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF);
Lcd_Cmd(_LCD_MOVE_CURSOR_RIGHT);
Lcd_Out(1,1,"frequency volts"); // Write text in first row
Lcd_Out(2,1," . Hz . V");
// lcd_init();
Delay_ms(2000);
}
else
if(GEN==A && MAIN==A) // if generator is still off; i.e; can't start
{
Delay_ms(1000);
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF);
Lcd_Cmd(_LCD_MOVE_CURSOR_RIGHT);
Lcd_Out(1,2,"< ERROR >");
Lcd_Out(2,1,"Fails to start.."); // Write text in first row
IGNITION=0; //Turn off the genset
MAIN_CONT=0;
while(MAIN==A && GEN==A); //stuck here untill reset/restart the controller board (IF main and generator both are absent)
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF);
}
for(;MAIN==A;) //untill main absent
{
if (MAIN==A) // if main absent
GEN_CONT=1; // Turn on generator contactor
MAIN_CONT=0; // Turn off main contactor
while(MAIN==A); // stay here until main resumes
if (MAIN==P) //if main presents or after main resumes
{
GEN_CONT=0;
Delay_ms(1000);
IGNITION=0; //Turn off the genset
Delay_ms(2000);
MAIN_CONT=1;
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Out(1,3,"Shenztech"); // Write text in first row
Lcd_Out(2,4,"Pvt Ltd");
}
}
}
void start()
{
//STATUS.IRP=1;
// asm BSF STATUS,RP1
// asm BSF STATUS,RP0 // ACCESS BANK 2
GEN_CONT=0;
MAIN_CONT=0;
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF);
Lcd_Out(1,1,"Mains ok.."); // Write text in first row
Lcd_Out(2,1,"Please Wait.....");
Delay_ms(3000);
MAIN_CONT=1;
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF);
Lcd_Out(1,1,"Mains ok.."); // Write text in first row
Lcd_Out(2,1,"Mains Overload");
Delay_ms(2000);
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
Lcd_Out(1,3,"Shenztech"); // Write text in first row
Lcd_Out(2,4,"Pvt Ltd");
}
void start()
{
//STATUS.IRP=1;
// asm BSF STATUS,RP1
// asm BSF STATUS,RP0 // ACCESS BANK 2
GEN_CONT=0;
MAIN_CONT=0;
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF);
Lcd_Out(1,1,"Mains ok.."); // Write text in first row
Lcd_Out(2,1,"Please Wait.....");
Delay_ms(3000);
MAIN_CONT=1;
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF);
Lcd_Out(1,1,"Mains ok.."); // Write text in first row
Lcd_Out(2,1,"Mains Overload");
Delay_ms(2000);
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
Lcd_Out(1,3,"Shenztech"); // Write text in first row
Lcd_Out(2,4,"Pvt Ltd");
}
Will check your code later. Can you explain clearly what the buttons have to do? and why do you want to select banks? The warnings about IRP bit is something related to the mikroC Compiler. Have you checked wheather the code runs properly? Are you using any ATS.c file in your project. Have you included it?
// OUTPUTS
#define GEN_CONT PORTE.f2
#define LED PORTB.f2
#define MAIN_CONT PORTC.F0
#define CHOWK PORTC.F1
#define IGNITION PORTC.F2
#define SELF PORTC.F3
// INPUTS
#define GEN PORTA.F0
#define MAIN PORTA.F1
#define ENTER PORTD.F0
#define RESET PORTD.F1
#define UP PORTD.F2
#define DOWN PORTD.F3
//CONSTANTS
#define T 100 //DELAYS
#define P 1 //FOR MAIN AND GEN INPUTS
#define A 0 //FOR MAIN AND GEN INPUTS
sbit LCD_RS at RD5_bit;
sbit LCD_EN at RD4_bit;
sbit LCD_D4 at RC4_bit;
sbit LCD_D5 at RC5_bit;
sbit LCD_D6 at RC6_bit;
sbit LCD_D7 at RC7_bit;
sbit LCD_RS_Direction at TRISD5_bit;
sbit LCD_EN_Direction at TRISD4_bit;
sbit LCD_D4_Direction at TRISC4_bit;
sbit LCD_D5_Direction at TRISC5_bit;
sbit LCD_D6_Direction at TRISC6_bit;
sbit LCD_D7_Direction at TRISC7_bit;
void gen(void);
void start(void);
unsigned char cnt;
void interrupt()
{
if(TMR0IF_bit)
{ cnt++;
TMR0IF_bit=0;
if(cnt>=10)
{
LED=~LED;
cnt=0;
}
TMR0=0;
}
}
void gen()
{
int i;
MAIN_CONT=0;
IGNITION=1;
Delay_ms(2000);
CHOWK=1;
Delay_ms(5000); //Chowk on for 5 seconds
CHOWK=0;
for(i=0; i<3; i++)
{
if(i==2)
{
CHOWK=1;
Delay_ms(5000); //Chowk on for 5 seconds
CHOWK=0;
}
SELF=1;
Delay_ms(2000); //self on for 2 seconds
SELF=0;
Delay_ms(4000); //self off for 4 seconds
if(MAIN==P) //if Main resumes
{
i=3;
GEN_CONT=0;
IGNITION=0;
SELF=0;
Delay_ms(2000); //self on for 2 seconds
MAIN_CONT=1;
}
if(GEN==P) //if generator ON
{
i=3;
}
}
if(GEN==P && MAIN==A) // if generator ON
{
Delay_ms(1000);
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF);
Lcd_Cmd(_LCD_MOVE_CURSOR_RIGHT);
Lcd_Out(1,1,"Warming Up..."); // Write text in first row
Delay_ms(5000);
GEN_CONT=1; // transfer load on genset after warmup
Delay_ms(300);
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF);
Lcd_Cmd(_LCD_MOVE_CURSOR_RIGHT);
Lcd_Out(1,1,"frequency volts"); // Write text in first row
Lcd_Out(2,1," . Hz . V");
Delay_ms(2000);
}
else if(GEN==A && MAIN==A) // if generator is still off; i.e; can't start
{
Delay_ms(1000);
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF);
Lcd_Cmd(_LCD_MOVE_CURSOR_RIGHT);
Lcd_Out(1,2,"< ERROR >");
Lcd_Out(2,1,"Fails to start.."); // Write text in first row
IGNITION=0; //Turn off the genset
MAIN_CONT=0;
while(MAIN==A && GEN==A); //stuck here untill reset/restart the controller board (IF main and generator both are absent)
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF);
}
for(;MAIN==A;) //untill main absent
{
if (MAIN==A) { // if main absent
GEN_CONT=1; // Turn on generator contactor
MAIN_CONT=0;
} // Turn off main contactor
while(MAIN==A); // stay here until main resumes
if (MAIN==P) //if main presents or after main resumes
{
GEN_CONT=0;
Delay_ms(1000);
IGNITION=0; //Turn off the genset
Delay_ms(2000);
MAIN_CONT=1;
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Out(1,3,"Shenztech"); // Write text in first row
Lcd_Out(2,4,"Pvt Ltd");
}
}
}
void start()
{
//STATUS.IRP=1;
// asm BSF STATUS,RP1
// asm BSF STATUS,RP0 // ACCESS BANK 2
GEN_CONT=0;
MAIN_CONT=0;
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF);
Lcd_Out(1,1,"Mains ok.."); // Write text in first row
Lcd_Out(2,1,"Please Wait.....");
Delay_ms(3000);
MAIN_CONT=1;
Lcd_Cmd(_LCD_CLEAR); // Clear display
//Lcd_Cmd(_LCD_CURSOR_OFF);
Lcd_Out(1,1,"Mains ok.."); // Write text in first row
Lcd_Out(2,1,"Mains Overload");
Delay_ms(2000);
Lcd_Cmd(_LCD_CLEAR); // Clear display
//Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
Lcd_Out(1,3,"Shenztech"); // Write text in first row
Lcd_Out(2,4,"Pvt Ltd");
}
void main() {
unsigned int i=0,x=0,j=0; //i=loops ; x=passward ; J=While lock
//..............INITIALIZATIONS............................................
/*ANSEL = 0; // Configure AN pins as digital I/O
ANSELH = 0;
C1ON_bit = 0; // Disable comparators
C2ON_bit = 0;*/
// CONFIGURING SFRs:
cnt=0;
TMR0=0; // loading vlaue of timer0 interrupt
OPTION_REG=0x87; // for timer 0; presscaller 1: 256
ADCON1=0x06; // adc reg initialization
INTCON=0xA0; // for timer0 ; interrupt reg initilization
// STATUS.F7=0;
//STATUS.IRP=0;
//asm BCF STATUS,IRP
// OUTPUTS:
TRISB.f2 = 0; //led out put
TRISE.F2 = 0; // gen cont output
TRISC = 0x00; // portC output For LCD
PORTC = 0X00; // initilization port c
// INPUTS:
TRISD.F0= 1; // ENTER
TRISD.F1= 1; // RESET
TRISD.F2= 1; // UP
TRISD.F3= 1; // DOWN
TRISA = 0xFF; // port A as input
// TRISD.F4=0XFF; // ALREADY DIRECTED AT LCD INITILIZATION
// TRISD.F5=0XFF;
//................................................................................
Lcd_Init();
Delay_ms(500);
//if(MAIN==P) // if main is Present.
//{
start();
//}
while(1) {
/*if(ENTER==0)
{
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF);
Lcd_Out(1,1,"Enter Passward");
while(ENTER==0)
{
Lcd_Out(1,x,"Enter Passward");
Lcd_Out(1,1,j);
}
Delay_ms(1000);
} */
if(MAIN==A) // if main is absent.
{
Delay_ms(4000); // wait for 4 seconds to ensure power failure
if(MAIN==P) //check again
continue;
//Delay_ms(1000);
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF);
Lcd_Out(1,1,"Mains Not Avail");
Lcd_Out(2,1,"Starting Genset");
Delay_ms(1000);
gen();
}
else // if main is present .........
{
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF);
Lcd_Out(1,1,"Mains ok.."); // Write text in first row
Lcd_Out(2,1,"Mains Overload");
Delay_ms(2000);
// GEN_CONT=0; //Turn off generator contactor
//MAIN_CONT=1; //Turn on main contactor
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Out(1,3,"Shenztech"); // Write text in first row
Lcd_Out(2,4,"Pvt Ltd");
Delay_ms(1000);
}
for(i=0; i<96; i++)
{
Lcd_Cmd(_LCD_SHIFT_RIGHT);
Delay_ms(T);
if(MAIN==A)
{
i=96;
}
}
} // while
}
is this for a generator automation?
Can you step by step explain what the buttons have to do, so that I can code it. Also you don't have to use the IRP bit for your program.
Check the attachment. It is displaying "Starting Genset"
-------------------------update-------------------------
Now it is displaying the messages. If you give me the step by step flow of the program, I will try to code.
Code:// OUTPUTS #define GEN_CONT PORTE.f2 #define LED PORTB.f2 #define MAIN_CONT PORTC.F0 #define CHOWK PORTC.F1 #define IGNITION PORTC.F2 #define SELF PORTC.F3 // INPUTS #define GEN PORTA.F0 #define MAIN PORTA.F1 #define ENTER PORTD.F0 #define RESET PORTD.F1 #define UP PORTD.F2 #define DOWN PORTD.F3 //CONSTANTS #define T 100 //DELAYS #define P 1 //FOR MAIN AND GEN INPUTS #define A 0 //FOR MAIN AND GEN INPUTS sbit LCD_RS at RD5_bit; sbit LCD_EN at RD4_bit; sbit LCD_D4 at RC4_bit; sbit LCD_D5 at RC5_bit; sbit LCD_D6 at RC6_bit; sbit LCD_D7 at RC7_bit; sbit LCD_RS_Direction at TRISD5_bit; sbit LCD_EN_Direction at TRISD4_bit; sbit LCD_D4_Direction at TRISC4_bit; sbit LCD_D5_Direction at TRISC5_bit; sbit LCD_D6_Direction at TRISC6_bit; sbit LCD_D7_Direction at TRISC7_bit; void gen(void); void start(void); unsigned char cnt; void interrupt() { if(TMR0IF_bit) { cnt++; TMR0IF_bit=0; if(cnt>=10) { LED=~LED; cnt=0; } TMR0=0; } } void gen() { int i; MAIN_CONT=0; IGNITION=1; Delay_ms(2000); CHOWK=1; Delay_ms(5000); //Chowk on for 5 seconds CHOWK=0; for(i=0; i<3; i++) { if(i==2) { CHOWK=1; Delay_ms(5000); //Chowk on for 5 seconds CHOWK=0; } SELF=1; Delay_ms(2000); //self on for 2 seconds SELF=0; Delay_ms(4000); //self off for 4 seconds if(MAIN==P) //if Main resumes { i=3; GEN_CONT=0; IGNITION=0; SELF=0; Delay_ms(2000); //self on for 2 seconds MAIN_CONT=1; } if(GEN==P) //if generator ON { i=3; } } if(GEN==P && MAIN==A) // if generator ON { Delay_ms(1000); Lcd_Cmd(_LCD_CLEAR); // Clear display Lcd_Cmd(_LCD_CURSOR_OFF); Lcd_Cmd(_LCD_MOVE_CURSOR_RIGHT); Lcd_Out(1,1,"Warming Up..."); // Write text in first row Delay_ms(5000); GEN_CONT=1; // transfer load on genset after warmup Delay_ms(300); Lcd_Cmd(_LCD_CLEAR); // Clear display Lcd_Cmd(_LCD_CURSOR_OFF); Lcd_Cmd(_LCD_MOVE_CURSOR_RIGHT); Lcd_Out(1,1,"frequency volts"); // Write text in first row Lcd_Out(2,1," . Hz . V"); Delay_ms(2000); } else if(GEN==A && MAIN==A) // if generator is still off; i.e; can't start { Delay_ms(1000); Lcd_Cmd(_LCD_CLEAR); // Clear display Lcd_Cmd(_LCD_CURSOR_OFF); Lcd_Cmd(_LCD_MOVE_CURSOR_RIGHT); Lcd_Out(1,2,"< ERROR >"); Lcd_Out(2,1,"Fails to start.."); // Write text in first row IGNITION=0; //Turn off the genset MAIN_CONT=0; while(MAIN==A && GEN==A); //stuck here untill reset/restart the controller board (IF main and generator both are absent) Lcd_Cmd(_LCD_CLEAR); // Clear display Lcd_Cmd(_LCD_CURSOR_OFF); } for(;MAIN==A;) //untill main absent { if (MAIN==A) { // if main absent GEN_CONT=1; // Turn on generator contactor MAIN_CONT=0; } // Turn off main contactor while(MAIN==A); // stay here until main resumes if (MAIN==P) //if main presents or after main resumes { GEN_CONT=0; Delay_ms(1000); IGNITION=0; //Turn off the genset Delay_ms(2000); MAIN_CONT=1; Lcd_Cmd(_LCD_CLEAR); // Clear display Lcd_Out(1,3,"Shenztech"); // Write text in first row Lcd_Out(2,4,"Pvt Ltd"); } } } void start() { //STATUS.IRP=1; // asm BSF STATUS,RP1 // asm BSF STATUS,RP0 // ACCESS BANK 2 GEN_CONT=0; MAIN_CONT=0; Lcd_Cmd(_LCD_CLEAR); // Clear display Lcd_Cmd(_LCD_CURSOR_OFF); Lcd_Out(1,1,"Mains ok.."); // Write text in first row Lcd_Out(2,1,"Please Wait....."); Delay_ms(3000); MAIN_CONT=1; Lcd_Cmd(_LCD_CLEAR); // Clear display //Lcd_Cmd(_LCD_CURSOR_OFF); Lcd_Out(1,1,"Mains ok.."); // Write text in first row Lcd_Out(2,1,"Mains Overload"); Delay_ms(2000); Lcd_Cmd(_LCD_CLEAR); // Clear display //Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off Lcd_Out(1,3,"Shenztech"); // Write text in first row Lcd_Out(2,4,"Pvt Ltd"); } void main() { unsigned int i=0,x=0,j=0; //i=loops ; x=passward ; J=While lock //..............INITIALIZATIONS............................................ /*ANSEL = 0; // Configure AN pins as digital I/O ANSELH = 0; C1ON_bit = 0; // Disable comparators C2ON_bit = 0;*/ // CONFIGURING SFRs: cnt=0; TMR0=0; // loading vlaue of timer0 interrupt OPTION_REG=0x87; // for timer 0; presscaller 1: 256 ADCON1=0x06; // adc reg initialization INTCON=0xA0; // for timer0 ; interrupt reg initilization // STATUS.F7=0; //STATUS.IRP=0; //asm BCF STATUS,IRP // OUTPUTS: TRISB.f2 = 0; //led out put TRISE.F2 = 0; // gen cont output TRISC = 0x00; // portC output For LCD PORTC = 0X00; // initilization port c // INPUTS: TRISD.F0= 1; // ENTER TRISD.F1= 1; // RESET TRISD.F2= 1; // UP TRISD.F3= 1; // DOWN TRISA = 0xFF; // port A as input // TRISD.F4=0XFF; // ALREADY DIRECTED AT LCD INITILIZATION // TRISD.F5=0XFF; //................................................................................ Lcd_Init(); Delay_ms(500); //if(MAIN==P) // if main is Present. //{ start(); //} while(1) { /*if(ENTER==0) { Lcd_Cmd(_LCD_CLEAR); // Clear display Lcd_Cmd(_LCD_CURSOR_OFF); Lcd_Out(1,1,"Enter Passward"); while(ENTER==0) { Lcd_Out(1,x,"Enter Passward"); Lcd_Out(1,1,j); } Delay_ms(1000); } */ if(MAIN==A) // if main is absent. { Delay_ms(4000); // wait for 4 seconds to ensure power failure if(MAIN==P) //check again continue; //Delay_ms(1000); Lcd_Cmd(_LCD_CLEAR); // Clear display Lcd_Cmd(_LCD_CURSOR_OFF); Lcd_Out(1,1,"Mains Not Avail"); Lcd_Out(2,1,"Starting Genset"); Delay_ms(1000); gen(); } else // if main is present ......... { Lcd_Cmd(_LCD_CLEAR); // Clear display Lcd_Cmd(_LCD_CURSOR_OFF); Lcd_Out(1,1,"Mains ok.."); // Write text in first row Lcd_Out(2,1,"Mains Overload"); Delay_ms(2000); // GEN_CONT=0; //Turn off generator contactor //MAIN_CONT=1; //Turn on main contactor Lcd_Cmd(_LCD_CLEAR); // Clear display Lcd_Out(1,3,"Shenztech"); // Write text in first row Lcd_Out(2,4,"Pvt Ltd"); Delay_ms(1000); } for(i=0; i<96; i++) { Lcd_Cmd(_LCD_SHIFT_RIGHT); Delay_ms(T); if(MAIN==A) { i=96; } } } // while }
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?