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.

Arduino analog input values are not stabilizing

Status
Not open for further replies.

sribangaram

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
Actually am preparing GSM based 3 phase motor controller when i am giving the miss call then motor will be start again call then off it's fine but i want to add program for 3 phase voltage monitoring so that's why i am prepared op amp circuit LM324 based it's out put giving perfectly i have checked through multi meter but when connect the arduino inputs threshold value is too much variation not stabilizing i think any problem in my code
PHP:
/*
 * Complete Project Details sripcbcreations@gmail.com
 */
 #include "SIM900.h"
#include <EEPROM.h>
#include <neotimer.h>
// Include Software Serial library to communicate with GSM
#include <SoftwareSerial.h>
#include "sms.h"
#include "call.h"

SMSGSM sms;

CallGSM call;
// Configure software serial port

bool phasecondition = true;
int value=0;

Neotimer mytimer = Neotimer(60000);
Neotimer timer1 = Neotimer(10000);
Neotimer timer2 = Neotimer(10000);
Neotimer timer3 = Neotimer(10000);

String num = " ";

char number[20];
byte stat=0;

// dont touch below code;
int numdata;
boolean started=false;
char smsbuffer[160]; //160 here
char n[20];

//debug begin
char sms_position;
char phone_number[20]; // array for the phone number string
char sms_text[100]; // 100 here
int i;

// dont touch above code

String checknumber=" ";

void SendTextMessage(String s, bool b1, bool b2);

void(* resetFunc) (void) = 0;  // declare reset fuction at address 0

// Variable to store text message
String textMessage;

// Create a variable to store Lamp state
String Motorstate = "off";

// Relay connected to pin 3
//const int relay = 9;
int currReading;
int prevReading;
int motor1 = 3; // motor pin connection
int dryRun = 2; // sensor for identifying water flow and used for dry run

int ALLPHASEOK = 5;  //ALL Phase OK LED
int PHASEMISSING = 6; //Phase missing LED
int HIGHVOLTAGE = 4; // high voltage led

int analogPin0 = A0;
int analogPin1 = A1;
int analogPin2 = A2;

int smsPinValue =0;
bool timerState = false;
int analogval0 = 0;
int analogval1 = 0;
int analogval2 = 0;
int dryRunvalue = 0;

int sms_count = 0; //count the SMS sent
int sms_count1 = 0; //count the SMS sent
int sms_count2 = 0;

int dryRunCount = 0;

//300v and analog pin shoud have 5v

int threshold_Low = 300;//180v and analog pin should have 3v

int threshold_High = 950;//270v and analog pin should have 4.5v

String changedphonenumber = "";
const int eeprom_size = 20; // values saved in eeprom should never exceed 500 bytes
char eeprom_buffer[eeprom_size];

void setup() {

  pinMode(motor1, OUTPUT);
  pinMode(ALLPHASEOK,OUTPUT);
  pinMode(PHASEMISSING,OUTPUT);
  pinMode(HIGHVOLTAGE,OUTPUT);
  pinMode(motor1,OUTPUT);
   
  // clear eeprom on new flash... just for debugging
 // for (int i = 0 ; i < EEPROM.length() ; i++) {
  //  EEPROM.write(i, 0);
 // }
  
  if (EEPROM.read(800) == 1)
  {
    read_string_from_eeprom(eeprom_buffer);
    Serial.println("check the value ");
    String storednumber(eeprom_buffer);
    Serial.println(storednumber);
    storednumber.trim();
    changedphonenumber = storednumber;

  }
  else
  {

    changedphonenumber = "9705422218";
  }
  sms_count = 0;
  sms_count1 = 0;

      //Serial connection.
    Serial.begin(9600);
    Serial.println("GSM STARTING ");
    //Start configuration of shield with baudrate.
    //For http uses is raccomanded to use 4800 or slower.
    if (gsm.begin(4800)) 
    {
        Serial.println("\nstatus=READY");
        started=true;
    } 
    else 
       Serial.println("\nstatus=IDLE");

  analogval0 = analogRead(analogPin0);
  delay(100);
  analogval1 = analogRead(analogPin1);
  delay(100);
  analogval2 = analogRead(analogPin2);
  delay(100);

 
   if (analogval0 < threshold_High &&analogval0 > threshold_Low && analogval1 < threshold_High &&analogval1 > threshold_Low && analogval2 < threshold_High &&analogval2 > threshold_Low )
  {

    //SendTextMessage("All phase are ok");
  //  //Serial.println("IN SETUP --->  All phase are ok : SMS Sent");
    delay(1000);

    SendTextMessage("SYSTEM READY", false, false,false);
    delay(100);

    digitalWrite(ALLPHASEOK, HIGH);
    digitalWrite(PHASEMISSING, LOW);
  }
  else
  {
      delay(3000);
   // //Serial.println("IN SETUP --->  PHASE MISSING AND  SMS Sent");
    delay(100);
    SendTextMessage("3 PHASE NOT AVAILABLE", false, false,false);
    delay(100);

    digitalWrite(ALLPHASEOK, LOW);
    digitalWrite(PHASEMISSING, HIGH);
     digitalWrite(HIGHVOLTAGE, LOW);
  }
}

void loop(){
  analogval0 = analogRead(analogPin0);
  delay(10);
  analogval1 = analogRead(analogPin1);
  delay(10);
  analogval2 = analogRead(analogPin2);
  delay(100);
  
   Serial.println(String(analogval0) + " " + String(analogval1) + "  " + String(analogval2));
   delay(100);
so please help me
 

Does not it seem a bit foreboding to try to give any guess without knowing the circuit you're using? It is not clear whether the problem can be due to the ripple of a rectification, the noise or even a bad layout. In short words, incomplete question so far.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top