jayanth.devarayanadurga
Banned
- Joined
- Dec 4, 2012
- Messages
- 4,280
- Helped
- 822
- Reputation
- 1,654
- Reaction score
- 791
- Trophy points
- 1,393
- Location
- Bangalore, India
- Activity points
- 0
// LCD module connections
sbit LCD_RS at RB5_bit;
sbit LCD_EN at RB7_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 TRISB5_bit;
sbit LCD_EN_Direction at TRISB7_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;
// End LCD module connections
char look(int a)
{
switch(a)
{
case 0:
return '0';
case 1:
return '1';
case 2:
return '2';
case 3:
return '3';
case 4:
return '4';
case 5:
return '5';
case 6:
return '6';
case 7:
return '7';
case 8:
return '8';
case 9:
return '9';
default:
return '.';
}
}
void main()
{
unsigned int v,vp,ip,i;
char *volt = "00.0";
char *current = "0.00";
TRISA = 0xFF;
Lcd_Init();
Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF);
do
{
ADCON1 = 0x00;
v = ADC_Read(2);
i = ADC_Read(3);
i = (i*4.8828)/0.47;
v = ((v*4.8828)/2)*12;
if(v!=vp || i!=ip )
Lcd_Cmd(_LCD_CLEAR);
vp = v;
ip = i;
volt[0] = look(v/10000);
volt[1] = look((v/1000)%10);
volt[3] = look((v/100)%10);
Lcd_Out(1,1,"Voltage = ");
Lcd_Out(1,11,volt);
Lcd_Out(1,16,"V");
current[0] = look(i/1000);
current[2] = look((i/100)%10);
current[3] = look((i/10)%10);
Lcd_Out(2,1,"Current = ");
Lcd_Out(2,11,current);
Lcd_Out(2,16,"A");
Delay_ms(250);
} while(1);
}
Code C - [expand] 1 2 3 4 TRISB = 0x00; TRISC = 0x00; PORTB = 0x00; PORTC = 0x00;
// LCD module connections
sbit LCD_RS at RB5_bit;
sbit LCD_EN at RB7_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 TRISB5_bit;
sbit LCD_EN_Direction at TRISB7_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;
// End LCD module connections
char look(int a)
{
switch(a)
{
case 0:
return '0';
case 1:
return '1';
case 2:
return '2';
case 3:
return '3';
case 4:
return '4';
case 5:
return '5';
case 6:
return '6';
case 7:
return '7';
case 8:
return '8';
case 9:
return '9';
default:
return '.';
}
}
void main()
{
unsigned int v,vp,ip,i;
char *volt = "00.0";
char *current = "0.00";
TRISA = 0xFF;
Lcd_Init();
Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF);
do
{
ADCON1 = 0x00;
v = ADC_Read(2);
i = ADC_Read(3);
i = (i*4.89)/0.47;
v = ((v*4.89)/1)*4.5;
if(v!=vp || i!=ip )
Lcd_Cmd(_LCD_CLEAR);
vp = v;
ip = i;
volt[0] = look(v/10000);
volt[1] = look((v/1000)%10);
volt[3] = look((v/100)%10);
Lcd_Out(1,1,"Voltage = ");
Lcd_Out(1,11,volt);
Lcd_Out(1,16,"V");
current[0] = look(i/1000);
current[2] = look((i/100)%10);
current[3] = look((i/10)%10);
Lcd_Out(2,1,"Current = ");
Lcd_Out(2,11,current);
Lcd_Out(2,16,"A");
Delay_ms(250);
} while(1);
}
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 char *volt = "00.0"; char *current = "00.0"; //v and i should be float type v = v * 30.0 / 1023.0; i = v * 10.0 / 1023.0; volt[0] = (v / 10) + 48; volt[1] = (v % 10) + 48; volt[3] = ((v * 10) % 10) + 48; current[0] = (i / 10) + 48; current[1] = (i % 10) + 48; current[3] = ((i * 10) % 10) + 48;
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 #define RELAY PORTD.F0 //RD0 is Relay pin. if(v < 12.0){ RELAY = 1; } else if(v >= 12.0){ RELAY = 0; }
// LCD module connections
sbit LCD_RS at RB5_bit;
sbit LCD_EN at RB7_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 TRISB5_bit;
sbit LCD_EN_Direction at TRISB7_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;
// End LCD module connections
sbit rel at trisb.b1;
char look(int a)
{
switch(a)
{
case 0:
return '0';
case 1:
return '1';
case 2:
return '2';
case 3:
return '3';
case 4:
return '4';
case 5:
return '5';
case 6:
return '6';
case 7:
return '7';
case 8:
return '8';
case 9:
return '9';
default:
return '.';
}
}
void main()
{
unsigned int v,vp,ip,i;
char *volt = "00.0";
char *current = "0.00";
TRISA = 0xFF;
TRISB = 0x00;
Lcd_Init();
Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF);
do
{
ADCON1 = 0x00;
v = ADC_Read(2);
i = ADC_Read(3);
i = (i*4.89)/0.47;
v = ((v*4.89)/1)*4.5;
if(v!=vp || i!=ip )
Lcd_Cmd(_LCD_CLEAR);
vp = v;
ip = i;
volt[0] = look(v/10000);
volt[1] = look((v/1000)%10);
volt[3] = look((v/100)%10);
Lcd_Out(1,1,"Voltage = ");
Lcd_Out(1,11,volt);
Lcd_Out(1,16,"V");
current[0] = look(i/1000);
current[2] = look((i/100)%10);
current[3] = look((i/10)%10);
Lcd_Out(2,1,"Current = ");
Lcd_Out(2,11,current);
Lcd_Out(2,16,"A");
Delay_ms(250);
if(v=13.7,i=6.51)
rel=0;
else if(v<13.7,i<6.51)
rel=1;
} while(1);
}
// LCD module connections
sbit LCD_RS at RB5_bit;
sbit LCD_EN at RB7_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 TRISB5_bit;
sbit LCD_EN_Direction at TRISB7_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;
// End LCD module connections
sbit rel at trisb.b1;
char look(int a)
{
switch(a)
{
case 0:
return '0';
case 1:
return '1';
case 2:
return '2';
case 3:
return '3';
case 4:
return '4';
case 5:
return '5';
case 6:
return '6';
case 7:
return '7';
case 8:
return '8';
case 9:
return '9';
default:
return '.';
}
}
void main()
{
unsigned int v,vp,ip,i;
char *volt = "00.0";
char *current = "0.00";
TRISA = 0xFF;
TRISB = 0x00;
Lcd_Init();
Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF);
do
{
ADCON1 = 0x00;
v = ADC_Read(2);
i = ADC_Read(3);
i = (i*4.89)/0.47;
v = ((v*4.89)/1)*4.5;
if(v!=vp || i!=ip )
Lcd_Cmd(_LCD_CLEAR);
vp = v;
ip = i;
volt[0] = look(v/10000);
volt[1] = look((v/1000)%10);
volt[3] = look((v/100)%10);
Lcd_Out(1,1,"Voltage = ");
Lcd_Out(1,11,volt);
Lcd_Out(1,16,"V");
current[0] = look(i/1000);
current[2] = look((i/100)%10);
current[3] = look((i/10)%10);
Lcd_Out(2,1,"Current = ");
Lcd_Out(2,11,current);
Lcd_Out(2,16,"A");
Delay_ms(250);
if(v=13.7,i=6.51)
rel=0;
else if(v<13.7,i<6.51)
rel=1;
} while(1);
}
// LCD module connections
sbit LCD_RS at RB5_bit;
sbit LCD_EN at RB7_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 TRISB5_bit;
sbit LCD_EN_Direction at TRISB7_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;
// End LCD module connections
sbit rel at trisb.b1;
char look(int a)
{
switch(a)
{
case 0:
return '0';
case 1:
return '1';
case 2:
return '2';
case 3:
return '3';
case 4:
return '4';
case 5:
return '5';
case 6:
return '6';
case 7:
return '7';
case 8:
return '8';
case 9:
return '9';
default:
return '.';
}
}
void main()
{
unsigned int v,vp,ip,i;
char *volt = "00.0";
char *current = "0.00";
TRISA = 0xFF;
TRISB = 0x00;
Lcd_Init();
Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF);
do
{
ADCON1 = 0x00;
v = ADC_Read(2);
i = ADC_Read(3);
i = (i*4.89)/0.47;
v = ((v*4.89)/1)*4.5;
if(v!=vp || i!=ip )
Lcd_Cmd(_LCD_CLEAR);
vp = v;
ip = i;
volt[0] = look(v/10000);
volt[1] = look((v/1000)%10);
volt[3] = look((v/100)%10);
Lcd_Out(1,1,"Voltage = ");
Lcd_Out(1,11,volt);
Lcd_Out(1,16,"V");
current[0] = look(i/1000);
current[2] = look((i/100)%10);
current[3] = look((i/10)%10);
Lcd_Out(2,1,"Current = ");
Lcd_Out(2,11,current);
Lcd_Out(2,16,"A");
Delay_ms(250);
if(v=13.7,i=6.51)
rel=0;
else if(v<13.7,i<6.51)
rel=1;
} while(1);
}
Code C - [expand] 1 2 3 4 if((v >= 13.7) && (i >=6.51)) rel=0; else if((v < 13.7) && (i < 6.51)) rel=1;
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?