Hi,
I am new to Arduino, my arduino codes and simulation is run without error but the problem is
Here
1.I have used 7 analog inputs (A0 to A6) and for A3 no issue,(A0 to A2 = L1,L2,L3 Voltage measurement and A4 to A6 = L1,L2,L3 current measurement method of analog input is 0 to 5V)
2.If A0 to A2 no input and from A4 to A6 analog reading value shows/LCD display(16x2) correctly according to the formula used.
3.when A0 to A2 get input and the corresponding A4 to A6 output value shows in LCD display with multiplication from A0 to A3 values even A4 to A6 No input given.
how to resolve this
Advance Thanks for your replay
When you say "no input" do you mean the pin is tied to ground, or do you simply mean random antenna mode?
my analog input is 0 to 5V (step dwon voltages for line of L1,L2 &L3 voltage and current measuring)
What does this mean, please?
means A0 =0V, A1=0V, A2=0V that is analog input is 0V
Hi, @K.K
Welcome to the forum.
Please read the post at the start of any forum , entitled "How to use this Forum".
This will help with advice on how to present your code and problems.
Can you please post your code and a circuit diagram?
What are you using to get the 3 phase voltages and current?
Thanks.. Tom...
I think it's time for code, schematic and a description of what you're seeing, and how that differs from what you expect to see
Hi,
You need to read the link on post#6, it will show you how to post your code in a scrolling window.
Or read this link.
To add code please click this link;
Thanks.. Tom...
#include <LiquidCrystal.h>
#define rs 27
#define en 26
#define d4 25
#define d5 24
#define d6 23
#define d7 22
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
int delaytime = 2;
int TimeloopR1 = 0;
int TimeloopY1 = 0;
int TimeloopB1 = 0;
unsigned long vrcurrenttime = 0;
unsigned long vycurrenttime = 0;
unsigned long vbcurrenttime = 0;
unsigned long vrprevioustime = 0;
unsigned long vyprevioustime = 0;
unsigned long vbprevioustime = 0;
int sec = 0;
int sec1 = 0;
int sec2 = 0;
const int RPhase = A0; //R Phase analog input from R phase stepdown voltage
const int YPhase = A1; //Y Phase analog input from R phase stepdown voltage
const int BPhase = A2; //B Phase analog input from R phase stepdown voltage
const int RPhaseIR = A4; //R Phase analog input from R phase stepdown current measurment to voltage
const int YPhaseIY = A5; //Y Phase analog input from R phase stepdown current measurment to voltage
const int BPhaseIB = A6; //B Phase analog input from R phase stepdown current measurment to voltage
const int Tempsensor = A3; //Tempsensor TMP35/36/37 Temprature sensor analog input
int thresholdValue = 0;
int celsius = 0;
void setup()
{
Serial.begin(9600);
lcd.begin(16, 2);
pinMode(A0, INPUT); //R Phase analog input from R phase stepdown voltage
pinMode(A1, INPUT); //Y Phase analog input from R phase stepdown voltage
pinMode(A2, INPUT); //B Phase analog input from R phase stepdown voltage
pinMode(A3, INPUT); //Temprature sensor analog input
pinMode(A4, INPUT); //R Phase analog input from R phase stepdown current measurment to voltage
pinMode(A5, INPUT); //Y Phase analog input from R phase stepdown current measurment to voltage
pinMode(A6, INPUT); //B Phase analog input from R phase stepdown current measurment to voltage
pinMode(3, INPUT); //TimeloopR1 from pin2
pinMode(5, INPUT); //TimeloopY1 from pin4
pinMode(7, INPUT); //TimeloopB1 from pin6
pinMode(2, OUTPUT); //TimeloopR1 to pin3
pinMode(4, OUTPUT); //TimeloopR1 to pin5
pinMode(6, OUTPUT); //TimeloopR1 to pin7
pinMode(8, OUTPUT); //Trip to R Phase fail VK1
pinMode(9, OUTPUT); //Trip to R Phase fail VK2
pinMode(10, OUTPUT); //Trip to R Phase fail VK3
pinMode(11, OUTPUT); //Phase fail Indication LED1 or Buzzer
pinMode(12, OUTPUT); //All phases are healthy LED2
pinMode(13, OUTPUT); //Panel Cooling Fan K7
pinMode(28, OUTPUT); //OverCurrent Trip IK4
delay(1000);
}
void loop()
{
delay(500);
lcd.clear();
int vrout = analogRead(RPhase);
int vyout = analogRead(YPhase);
int vbout = analogRead(BPhase);
int RVolt = (vrout * ( 5.0 / 1023)) * 50.55;
int YVolt = (vyout * ( 5.0 / 1023)) * 50.55;
int BVolt = (vbout * ( 5.0 / 1023)) * 50.55;
int IRin = analogRead(RPhaseIR);
int IYin = analogRead(YPhaseIY);
int IBin = analogRead(BPhaseIB);
int RCurrent = (IRin * ( 5.0 / 1023)) * 08.00;
int YCurrent = (IYin * ( 5.0 / 1023)) * 08.00;
int BCurrent = (IBin * ( 5.0 / 1023)) * 08.00;
//R Phase Voltage Condition Checks
if ( RVolt < 180)
{
digitalWrite(2, HIGH);
}
else if ( (RVolt >= 180) && (RVolt <= 240) )
{
digitalWrite(2, LOW);
}
if ( RVolt > 240)
{
digitalWrite(2, HIGH);
}
else if ( (RVolt >= 180) && (RVolt <= 240) )
{
delay(0);
digitalWrite(2, LOW);
}
vrcurrenttime = millis();
if (digitalRead(3) == HIGH && TimeloopR1 == 0 && digitalRead(8) == LOW)
{
TimeloopR1 = 1;
sec = delaytime;
}
if (TimeloopR1 == 1)
{
if ((vrcurrenttime - vrprevioustime) > 1000)
{
sec--;
vrprevioustime = vrcurrenttime;
if (sec <= 0)
{
TimeloopR1 = 0;
digitalWrite(8, HIGH);
sec = 0;
}
}
}
if (digitalRead(3) == LOW && TimeloopR1 == 0)
{
TimeloopR1 = 0;
sec = 0;
digitalWrite(8, LOW);
}
//Y Phase Voltage Condition Checks
if ( YVolt < 180)
{
digitalWrite(4, HIGH);
}
else if ( (YVolt >= 180) && (YVolt <= 240) )
{
digitalWrite(4, LOW);
}
if ( YVolt > 240)
{
digitalWrite(4, HIGH);
}
else if ( (YVolt >= 180) && (YVolt <= 240) )
{
digitalWrite(4, LOW);
}
vycurrenttime = millis();
if (digitalRead(5) == HIGH && TimeloopY1 == 0 && digitalRead(9) == LOW)
{
TimeloopY1 = 1;
sec1 = delaytime;
}
if (TimeloopY1 == 1)
{
if ((vycurrenttime - vyprevioustime) > 1000)
{
sec1--;
vyprevioustime = vycurrenttime;
if (sec1 <= 0)
{
TimeloopY1 = 0;
digitalWrite(9, HIGH);
sec1 = 0;
}
}
}
if (digitalRead(5) == LOW && TimeloopY1 == 0)
{
TimeloopY1 = 0;
sec1 = 0;
digitalWrite(9, LOW);
}
//B Phase Voltage Condition Checks
if ( BVolt < 180)
{
digitalWrite(6, HIGH);
}
else if ( (BVolt >= 180) && (BVolt <= 240) )
{
digitalWrite(6, LOW);
}
if ( BVolt > 240)
{
digitalWrite(6, HIGH);
}
else if ( (BVolt >= 180) && (BVolt <= 240) )
{
digitalWrite(6, LOW);
}
vbcurrenttime = millis();
if (digitalRead(7) == HIGH && TimeloopB1 == 0 && digitalRead(10) == LOW)
{
TimeloopB1 = 1;
sec2 = delaytime;
}
if (TimeloopB1 == 1)
{
if ((vbcurrenttime - vbprevioustime) > 1000)
{
sec2--;
vbprevioustime = vbcurrenttime;
if (sec2 <= 0)
{
TimeloopB1 = 0;
digitalWrite(10, HIGH);
sec2 = 0;
}
}
}
if (digitalRead(7) == LOW && TimeloopB1 == 0)
{
TimeloopB1 = 0;
sec2 = 0;
digitalWrite(10, LOW);
}
//Overcurrent Trip for IK4
if (RCurrent > 25 || YCurrent > 25 || BCurrent > 25)
{
digitalWrite(28, HIGH); // Overcurrent trip relay IK4
}
//Any Phase Fail Blink LED1 or Buzzer
if (digitalRead(7) == HIGH || digitalRead(5) == HIGH || digitalRead(3) == HIGH)
{
digitalWrite(11, HIGH);
delay(100);
digitalWrite(11, LOW);
}
//All Phases are OK LED2
if (digitalRead(7) == LOW && digitalRead(5) == LOW && digitalRead(3) == LOW)
{
digitalWrite(12, HIGH);
}
//LCD Display Details
Serial.println(RVolt);
Serial.println(YVolt);
Serial.println(BVolt);
lcd.setCursor(0, 0);
lcd.print(" R Y B V");
lcd.setCursor(0, 1);
lcd.print(RVolt);
lcd.setCursor(5, 1);
lcd.print(YVolt);
lcd.setCursor(10, 1);
lcd.print(BVolt);
delay(200);
Serial.println(RCurrent);
Serial.println(YCurrent);
Serial.println(BCurrent);
lcd.setCursor(0, 0);
lcd.print(" R Y B I");
lcd.setCursor(0, 1);
lcd.print(RCurrent);
lcd.setCursor(5, 1);
lcd.print(YCurrent);
lcd.setCursor(10, 1);
lcd.print(BCurrent);
delay(100);
if (digitalRead(8) == HIGH)
{
lcd.clear();
lcd.setCursor(0, 1);
lcd.print("*R Under Voltage");
delay(100);
}
// Temperature calculation and Panel Cooling Fan
celsius = map(((analogRead(A3) - 20) * 3.04), 0, 1023, -40, 125);
Serial.print(celsius);
Serial.print(" C : ");
if (celsius >= 38)
{
digitalWrite(13, HIGH);
}
else if (celsius < 38)
{
digitalWrite(13, LOW);
}
}
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.