2nd Draft
2nd Draft
char i;
float ac_peak_voltage = 230.0;
float adc_resolution = 5.0/1023;
void main()
{
Lcd_Init();
// Configure Port A as input
TRISA = 0xFF; // set all pins of Port A as inputs
Lcd_cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF);
while(1)
{
// READ ADC VALUES FOR THREE PHASES
float phase_a_voltage = ADC_Read(0); // Assuming ADC_Read() is a function
provided by mikroC PRO for PIC
float phase_b_voltage = ADC_Read(1); // Assuming ADC_Read() is a function
provided by mikroC PRO for PIC
float phase_c_voltage = ADC_Read(2); // Assuming ADC_Read() is a function
provided by mikroC PRO for PIC
intToStr(phase_a_voltage_whole,phase_a_voltage_text);
intToStr(phase_b_voltage_whole,phase_b_voltage_text);
intToStr(phase_c_voltage_whole,phase_c_voltage_text);
else if (phase_a_voltage_whole>240||phase_b_voltage_whole>240||
phase_c_voltage_whole>240)
{
Lcd_Out(4,1,"OVER-VOLTAGE!!");
Buzzer =1; //turn ON the buzzer
}
else
{
Lcd_Out(4,1,"NORMAL-VOLTAGE");
Buzzer =0; //turn OFF the buzzer
Motor_Relay =1; // turn ON motor relay
}
} //while loop
} //main loop