Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

GSM based three phase motor controller program problem

Status
Not open for further replies.

sribangaram

Full Member level 5
Full Member level 5
Joined
Apr 29, 2012
Messages
297
Helped
7
Reputation
14
Reaction score
7
Trophy points
1,298
Location
INDIA.:/;:'" VIJAYAWADA
Activity points
3,754
Dear Friends i need small modification for my program this program working fine but i wont to add 3 phase detection when any phase will be fail or avail then send to sms and at the same time if motor in HIGH position immediately change to LOW position

PHP:
const int analogPin1 = PIN_A0;   // pin that the eb L1 sense
const int analogPin2 = PIN_A1;   // pin that the eb L2 sense 
const int analogPin3 = PIN_A2;   // pin that the eb L3 sense
const int analogPin3 = PIN_A3;   // pin that the dry run sense
const int threshold = 1023;   // an arbitrary threshold level that's in the range of the analog input

int repeat = 0;
int LED = 8;
int motor = 9;
int buttonpushcounter =0;
int buttonstate =0;
int lastbuttonstate =0;
int temp=0;
int i=0;
char str[15];
void setup()
{
  Serial.begin(9600);
  pinMode(threshold , INPUT);
  pinMode(motor,OUTPUT);
  pinMode(LED,OUTPUT);
  digitalWrite(motor,LOW);
  digitalWrite(LED,LOW);
  delay(5000);
  delay(5000);
  delay(5000);
  Serial.println("AT+CNMI=2,2,0,0,0");
  delay(1000); 
  Serial.println("AT+CMGF=1");
  delay(1000);

  // read the value of the potentiometer:
  int analog1Value = analogRead(analogPin1);
  int analog2Value = analogRead(analogPin2);
  int analog3Value = analogRead(analogPin3);

  Serial.println("Analog pin A0: " +String(analog1Value));
  Serial.println( "Analog pin A1: " +String(analog2Value));
  Serial.println("Analog pin A2: " +String(analog3Value));
  delay(1000);
  
}

void loop()
{
buttonstate = analogRead (threshold);
if (buttonstate != lastbuttonstate)
{
  if (buttonstate == threshold){
    buttonpushcounter ++;
    Serial.println("3 PHASE OK");
    delay(1000);
    //Serial.println("number of button pushes:");
    //Serial.println(buttonpushcounter);
    Serial.println("AT+CMGS=\"+919705422218\"\r"); // Replace x with mobile number
  delay(1000);
  Serial.println("system ready three phase available");// The SMS text you want to send
  delay(1000);
  Serial.println((char)26); // ASCII code of CTRL+Z
  delay(1000);
  
   } else {
    
    if (buttonstate != lastbuttonstate)
    
    Serial.println("3 PHASE NOT OK");
    delay(1000);
    //Serial.println("number of button pushes:");
    //Serial.println(buttonpushcounter);
    digitalWrite(motor,LOW);
      digitalWrite(LED,LOW);
      delay(1000);
    Serial.println("AT+CMGS=\"+919705422218\"\r"); // Replace x with mobile number
  delay(1000);
  Serial.println("system ready but three phase not available");// The SMS text you want to send
  delay(1000);
  Serial.println((char)26); // ASCII code of CTRL+Z
  delay(1000);
      }

  lastbuttonstate = buttonstate;
  if (buttonpushcounter % 1 ==0){
  
}
    
  
 

  }

   
  if(temp==1)
  {
    check();
    temp=0;
    i=0;
    delay(1000);
  
  }
  }

 void serialEvent() 
 {
  while(Serial.available()) 
  {
    if(Serial.find("/"))
    {
      delay(1000);
      while (Serial.available()) 
      {
      char inChar=Serial.read();
      str[i++]=inChar;
      if(inChar=='/')
      {
        temp=1;
        return;
      } 
      } 
    }
   }
 }
void check()
{
   if(!(strncmp(str,"motor on",8)))
    {delay(1000);        // delay in between reads for stability

      // read the value of the potentiometer:
  int analog1Value = analogRead(analogPin1);
  int analog2Value = analogRead(analogPin2);
  int analog3Value = analogRead(analogPin3);
  Serial.println("Analog pin A0: " +String(analog1Value));
  
  Serial.println( "Analog pin A1: " +String(analog2Value));
  
  Serial.println("Analog pin A2: " +String(analog3Value));
  
   if("analog1Value  threshold", "analog2Value  threshold", "analog3Value  threshold"){
    delay(100);        // delay in between reads for stability
      digitalWrite(motor,HIGH);
      digitalWrite(LED,HIGH);
      delay(1000);  
      Serial.println("AT+CMGS=\"+919705422218\"\r"); // Replace x with mobile number
      delay(1000);
      Serial.println("Motor Activated");// The SMS text you want to send
      delay(100);
      Serial.println((char)26); // ASCII code of CTRL+Z
      delay(1000);
       } else {
        digitalWrite(motor,LOW);
      digitalWrite(LED,LOW);
      delay(1000);
      Serial.println("AT+CMGS=\"+919705422218\"\r"); // Replace x with mobile number
      delay(1000);
      Serial.println("Motor deactivated due to three phase not available");// The SMS text you want to send
      delay(100);
      Serial.println((char)26); // ASCII code of CTRL+Z
      delay(1000);  
       }
    }  
   else if(!(strncmp(str,"motor off",9)))
    {
      digitalWrite(motor,LOW);
      digitalWrite(LED,LOW);
      delay(1000);  
      Serial.println("AT+CMGS=\"+919705422218\"\r"); // Replace x with mobile number
      delay(1000);
      Serial.println("Motor deactivated");// The SMS text you want to send
      delay(100);
      Serial.println((char)26); // ASCII code of CTRL+Z
      delay(1000);
}  
else if(!(strncmp(str,"test",4)))
{
      Serial.println("AT+CMGS=\"+919705422218\"\r"); // Replace x with mobile number
      delay(1000);
      Serial.println("The System is Working Fine.");// The SMS text you want to send
      delay(100);
      Serial.println((char)26); // ASCII code of CTRL+Z
      delay(1000);
}
}
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top