Please help me on my Project

my project is to build a fault detection system for a STAR-DELTA motor controling system.
I want below funtions,

  1. when one of the phase misses(pin 2 or 3 or 4 is low) then show alarm message informing the exact phase no. and pin 13 goes high

  2. when star contact is on(pin6=high), then show message

  3. when delta contact is on show message

  4. when delta contac (pin 7) is not on (high) within 15 seconds then show alarm message and pin 13 goes high

  5. when reset button is pressed (pin 12 = high) then pin 13 goes low and and show message

I have written a sketch but it loops for ever doesnt work

my code is as below

#include <LiquidCrystal.h>
LiquidCrystal lcd(0, 1, 8, 9, 10, 11); /// REGISTER SELECT PIN,ENABLE PIN,D4 PIN,D5 PIN, D6 PIN, D7 PIN

unsigned long WaitAutoOff = millis();


const int R = 2; // Pin no Define
const int Y = 3;   // Pin no Define
const int B = 4;    // Pin no Define
const int OL = 5;    // Pin no Define
const int STAR = 6; // Pin no Define
const int DELTA = 7;   // Pin no Define
const int RESET = 12;    // Pin no Define
const int RELAY1 = 13;    // Pin no Define


void setup()

{



   lcd.begin(16, 2); // set up the LCD's number of columns and rows:
  
   pinMode(R,INPUT); // Pin 2 as input from R phase
   pinMode(Y,INPUT); // Pin 3 as input from Y phase
   pinMode(B,INPUT); // Pin 4 as input from B phase
  
   pinMode(OL,INPUT); // Pin 5 as input from overload NO(98)
   pinMode(STAR,INPUT); // Pin 6 as input form star contact NO(54)
   pinMode(DELTA,INPUT); // Pin 7 as input form delta contact NO(54) 
  
   pinMode(RESET,INPUT); // Pin 12 as input from restet button NO
   
   pinMode(RELAY1,OUTPUT); // Pin 4 as output to relay ch1
  
 
}


void loop(){

{
  int U1 = digitalRead(R);
  int V1 = digitalRead(Y);
  int W1 = digitalRead(B);
  int OVERLOAD = digitalRead(OL);
  int STAR = digitalRead(STAR);
  int DELTA = digitalRead(DELTA);
  int RESET = digitalRead(RESET);

  if (U1 == LOW) {

    digitalWrite(RELAY1,HIGH);  // relay ON
    
    lcd.print(" PHASE MISSING  ");//print alarm message
    lcd.setCursor(0, 1); // set the cursor to column 0, line 2
    lcd.print("CHECK PHASE U1,U2");//print solution
    //delay(750);//delay of 0.75sec
   // lcd.scrollDisplayLeft();//shifting data on LCD
    lcd.setCursor(0, 0);// set the cursor to column 0, line1
   }

   else if (V1 == LOW) {
    digitalWrite(RELAY1,HIGH);  // relay ON
    
    lcd.print(" PHASE MISSING  ");//print alarm message
    lcd.setCursor(0, 1); // set the cursor to column 0, line 2
    lcd.print("CHECK PHASE V1,V2");//print solution
    //delay(750);//delay of 0.75sec
    //lcd.scrollDisplayLeft();//shifting data on LCD
    lcd.setCursor(0, 0);// set the cursor to column 0, line1
   }
   else if (W1 == LOW){
    digitalWrite(RELAY1,HIGH);  // relay ON
    
    lcd.print(" PHASE MISSING  ");//print alarm message
    lcd.setCursor(0, 1); // set the cursor to column 0, line 2
    lcd.print("CHECK PHASE W1,W2");//print solution
    //delay(750);//delay of 0.75sec
    //lcd.scrollDisplayLeft();//shifting data on LCD
    lcd.setCursor(0, 0);// set the cursor to column 0, line1
   }
   else if (OVERLOAD == HIGH){
    digitalWrite(RELAY1,HIGH);  // relay ON
    
    lcd.print(" OVERLOAD TRIP ");//print alarm message
    lcd.setCursor(0, 1); // set the cursor to column 0, line 2
    lcd.print("CHECK MOTOR OR MECHANICAL LOAD");//print solution
    //delay(750);//delay of 0.75sec
    //lcd.scrollDisplayLeft();//shifting data on LCD
    lcd.setCursor(0, 0);// set the cursor to column 0, line1
   }
   else if (STAR == HIGH){
    
    lcd.print("MOTOR IS RUNNING");//print alarm message
    lcd.setCursor(0, 1); // set the cursor to column 0, line 2
    lcd.print("ON STAR CONNECTION");//print solution
    //delay(750);//delay of 0.75sec
   // lcd.scrollDisplayLeft();//shifting data on LCD
    lcd.setCursor(0, 0);// set the cursor to column 0, line1
   }
   else if (DELTA == HIGH){
    
    lcd.print("MOTOR IS RUNNING");//print alarm message
    lcd.setCursor(0, 1); // set the cursor to column 0, line 2
    lcd.print("ON DELTA CONNECTION");//print solution
    //delay(750);//delay of 0.75sec
   // lcd.scrollDisplayLeft();//shifting data on LCD
    lcd.setCursor(0, 0);// set the cursor to column 0, line1
   }
   
    else if (RESET == HIGH){
    
    digitalWrite(RELAY1,LOW);  // relay OFF
    
    lcd.print("PUSH THE ON BUTTON");//print alarm message
    lcd.setCursor(0, 1); // set the cursor to column 0, line 2
    lcd.print("TO START THE MOTOR");//print solution
    //delay(750);//delay of 0.75sec
   // lcd.scrollDisplayLeft();//shifting data on LCD
    lcd.setCursor(0, 0);// set the cursor to column 0, line1
    
   }
  
    else {
    //digitalWrite(RELAY1,LOW);  // relay OFF
    
    lcd.print("PUSH THE ON BUTTON");//print alarm message
    lcd.setCursor(0, 1); // set the cursor to column 0, line 2
    lcd.print("TO START THE MOTOR");//print solution
    //delay(750);//delay of 0.75sec
   // lcd.scrollDisplayLeft();//shifting data on LCD
    lcd.setCursor(0, 0);// set the cursor to column 0, line1
  
    }
} }

To make it easy for people to help you please modify your post and use the code button </> so your code looks like this and is easy to copy to a text editor. See How to use the Forum

…R

You say

  1. when one of the phase misses(pin 2 or 3 or 4 is low)

but you check them HIGH:

  if (U1 == HIGH) {
 ...
   else if (V1 == HIGH) {
 ...
   else if (W1 == HIGH){

In the loop, there are too many ‘{’ and ‘}’:

void loop(){

{   // <-- this one


...



} }  // <-- one too many here
  1. when delta contact (pin 7) is not on (high) within 15 seconds then show alarm message and pin 13 goes high

You haven’t done this yet. It’s the hardest thong, save it for later.

Do you have anything on the display? If nothing appears it may be due to 2 things :

  • LCD wrongly connected

  • code running too fast
    So…

  • Check if you can run one of the examples of your LCD library

  • Put a delay in the loop, before the end, such as delay(1000); and see what happens.

Otherwise, your code could be written as a state machine, look for libraries dealing with FSM on Arduino, they can help you.

I have intentionally read those pin as HIGH to simulate the funtion without connecting those pin to original projecct… how ever i have corrected my code upthere as I originally wanted please check @ lesept

 if (U1 == HIGH) {
 ...
   else if (V1 == HIGH) {
 ...
   else if (W1 == HIGH){

Thank you all for replying to my post :slight_smile: .

  1. the code runs very fast
  2. I have correctly connected LCD and lcd shows all messages one by one very fast and keep showing
  3. the relay keeps on and off very fast

can any one please rewrite the sketch in the manner that works as what I wanted.
it will be a big help for me.

Hi, Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

How have you got you input contacts wired to the controller? Do you have pullup or pulldown resistors?

Thanks.. Tom.. :)