Show Posts
Pages: [1] 2 3 ... 64
1  Using Arduino / Sensors / Current sensor Module on: September 20, 2014, 01:05:32 am
Dear all,

I am looking for current sensor that can measure 2A min current with  better accuracy. I have tried with ACS712 5A rated from sparkfun  both version . But i found inspite of using it has distortion . I tried to stablize using average and SD of sample. output . But it seems out is not stabilize. SO anyone can suggest me PCB mount current sensor with better accuracy .

https://www.sparkfun.com/products/8882

I wanted to try with shunt basis model. But those are expensive costing me around 850RS(13$)


Quote
My specification as below
input to sensor IC: 0~5v
out put of sensor: analog 0~5v linear will be better
measuring range :2A~5A
PCB mount
accuracy:1%
2  Using Arduino / Interfacing w/ Software on the Computer / Re: VIsual basic with arduino on: September 18, 2014, 07:09:41 am
@ paul
1)Thanks for suggestions. These mistakes are already mentioned  by me in starting thread itself. As i said i am beginner to visual Basic. I have used the function based on example

2) If you know the answer , You could have given solution instead of suggesting . And not allowed me to post other theads

3)If i cant use this method How to send the data to text box repeatedly without using buttons???
Quote
This method is called when the text in the text box changes.

4) Give me small and simple example getting data from Serialy and displayed on VB.
http://tiktakx.wordpress.com/2010/11/21/serial-port-interfacing-with-vb-net-2010/
I have already tried this. But not working.
3  Using Arduino / Project Guidance / Software to Control IOS and Serial port arduino on: September 18, 2014, 03:55:56 am
Dear all,
I am doing simple project with arduino. Project working fine. Now i  am looking for software Where i can control the data of arduino.

I have current sensor That keep monitoring the analog value . If current exceed predefined limit relay got tripped. currently
in automatic mode after 30s  relay will activate again  or through serial command i can control the relay output.

SO instead of controlling through serial port . I am looking for software where i can view my Serial monitor output data and control the relay via software.

I tried with VB and processing but they are not working. Controlling of relay working fine problem i am facing Getting update current values.

SO is any software available that gives  me current value and control data serially port of arduino 
4  Using Arduino / Interfacing w/ Software on the Computer / Re: VIsual basic with arduino on: September 18, 2014, 03:11:44 am
Dear Robin,
Thanks for concern. Since i have made already these effort on VB i dont proceed with python untill unless there complete executable script. If you have already done please share compelte zip file.

W.r. t My code
Since i am receiving data once first time .after that it not updating. Still it pending.for my code
Code:
Current_Read.Text = SerialPort1.ReadLine()
            Current_Read.Refresh()
if i add in button statement i can see current value being updating. But Here i am forcing externally to display.
Since i can control relay through Vb and also getting data into VB .
Means to me Serial communication happening well. But In my code i cant able to figure out Why it not updating automatically.

I have tried almost all example code by now. I need Only text box need to get modify such data get read repeatedly
5  Using Arduino / Interfacing w/ Software on the Computer / Processing code for arduino on: September 17, 2014, 08:27:40 am
Dear all,
I am trying to processing code with arduino UNO.I tried with VB but seems data not being updating, But in processing the i tried below code where i can get serial data. Now i wanted to create button Which activate and deactivate relay like in VB, Is it possible to create in Processing.
I tried simple example code coming With processing But i could not able to control output. SO let me know Where i can find More example for digital io control and processing software.

I have attached Both image and link for references


http://forum.arduino.cc/index.php?topic=267122.msg1885398#msg1885398
Processing code
Code:
import processing.serial.*;
Serial myPort;
String sensorReading="";
PFont font;
int val = 0;

void setup() {
  size(400,200);
  myPort = new Serial(this, "COM3", 9600);
  myPort.bufferUntil('\n');
  font = createFont(PFont.list()[2],32);
  textFont(font);
}

void draw() {

}
void serialEvent (Serial myPort){
 sensorReading = myPort.readStringUntil('\n');
  if(sensorReading != null){
    sensorReading=trim(sensorReading);
  }

  writeText("Current_Reading: " + sensorReading);
}


void writeText(String textToWrite){
  background(255);
  fill(0);
  text(textToWrite, width/20, height/2);   
}


Arduino COde
Code:
#include <MsTimer2.h>
int Analog_Pin=5;
int newaverage;
float Output_Current;
#define RELAY1  7
int Serial_Status=0;



void TakeReading()
{
  newaverage = analogRead(A5);
  Output_Current = 0.0336666666667*newaverage - 17.17;
}


void setup()
{
  Serial.begin(9600);
  MsTimer2::set(1000, Print_Result); // 500ms period
  MsTimer2::start();

}

void loop()
{
  TakeReading();

  int val = Serial.read() - '0';
  if (val == 1)
  {
    digitalWrite(RELAY1, LOW); // turn on LED

  }
  else if (val == 0)
  {

    digitalWrite(RELAY1, HIGH); // turn off LED

  }
  delay(500);
}

void Print_Result()
{
 // Serial.print("Output_Current:");
  Serial.println(Output_Current);

}

6  Using Arduino / Interfacing w/ Software on the Computer / Re: VIsual basic with arduino on: September 17, 2014, 08:19:34 am
SInce i am new to this . can you tell Me how to declare the below.
Code:
SerialPort1.Open()
          SerialPort1.Close()
How to check this
Quote
My understanding of your function Sub Current_Read_TextChanged() is that it is called whenever the text in the box changes. But I think what you really need is something that checks for new input and THEN changes the text.
7  Using Arduino / Interfacing w/ Software on the Computer / Re: VIsual basic with arduino on: September 17, 2014, 08:01:38 am
Arduino code
Code:
#include <MsTimer2.h>
int Analog_Pin=5;
int newaverage;
float Output_Current;
#define RELAY1  7
int Serial_Status=0;



void TakeReading()
{
  newaverage = analogRead(A5);
  Output_Current = 0.0336666666667*newaverage - 17.17;
}


void setup()
{
  Serial.begin(9600);
  MsTimer2::set(1000, Print_Result); // 500ms period
  MsTimer2::start();

}

void loop()
{
  TakeReading();

  int val = Serial.read() - '0';
  if (val == 1)
  {
    digitalWrite(RELAY1, LOW); // turn on LED

  }
  else if (val == 0)
  {

    digitalWrite(RELAY1, HIGH); // turn off LED

  }
  delay(500);
}

void Print_Result()
{
  Serial.print("Output_Current:");
  Serial.println(Output_Current);
  Serial.print("OUTPUT:");
  if(digitalRead(RELAY1)==LOW)
  {
    Serial.println("ON");
  }
  else if(digitalRead(RELAY1)==HIGH)
  {
    Serial.println ("OFF");
  }

}

VB Code
Code:


Imports System.IO
Imports System.IO.Ports
Imports System.Threading

Public Class Form1
   



    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)


        SerialPort1.PortName = "COM3"

        SerialPort1.BaudRate = 9600
        SerialPort1.DataBits = 8
        SerialPort1.Parity = IO.Ports.Parity.None
        SerialPort1.StopBits = IO.Ports.StopBits.One
        SerialPort1.Handshake = IO.Ports.Handshake.None
        SerialPort1.Encoding = System.Text.Encoding.Default 'very important!


    End Sub


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        SerialPort1.Open()
        SerialPort1.Write("1")
        Relay_Status.Text = "ON"
        SerialPort1.Close()
    End Sub


    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        SerialPort1.Open()
        SerialPort1.Write("0")
        Relay_Status.Text = "OFF"
        SerialPort1.Close()
    End Sub


    Private Sub Current_Read_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        SerialPort1.Open()
        Dim s As String
        s = SerialPort1.ReadTo(SerialPort1.ReadExisting())
        Current_Read.Text = s
        's = Val(SerialPort1.ReadChar()) * k
        'Current_Read.Text = Format(s, "Standard")

        SerialPort1.Close()
    End Sub


End Class

I am facing problem while updating Current_Read.text values. I can control the relay with this code through buttons. As i said  i can see the data when first time run. Later only i can control  through button. But Not seeing update value Current

I have attached image for reference
8  Using Arduino / Programming Questions / <SOLVE>: Delaying process on: September 17, 2014, 06:07:22 am
Thanks for support . solved.
9  Using Arduino / Programming Questions / Delaying process on: September 17, 2014, 05:08:05 am
Dear all,

I wanted to know how to delay a process without affecting main code.

Code:
#include <MsTimer2.h>


int Analog_Pin=5;
int newaverage;
float Output_Current;
#define RELAY1  7
#define MAX_TRIP_COUNT  5
float Current_Limit=0.6;
static int Trip_Count=0;
static int Tripped_Flag=1;
int Serial_Status=0;



void TakeReading()
{
  newaverage = analogRead(A5);
 
//  Serial.print("newaverage:");
  //Serial.println(newaverage);
  Output_Current = 0.0336666666667*newaverage - 17.17;
}


void Chk_Relay_Tripped()
{
  if(Output_Current>=Current_Limit)
  {
    Trip_Count=Trip_Count+1;
    if((Trip_Count>=MAX_TRIP_COUNT) &&(Serial_Status==0))
    {

      Trip_Count=0;
     
  MsTimer2::set(30000, Relay_Activate); // 500ms period
  MsTimer2::start();
     // Relay_Activate();
    }
    else
      if(Serial_Status==1)
      {
        Serial.println("> MODE");
        Relay_Deactivate();
      }

  }
  else
  {
    Trip_Count=Trip_Count-1;
    if(Trip_Count<0)
    {
      Trip_Count=0;
    }

    if(Trip_Count<MAX_TRIP_COUNT && Serial_Status==1)
    {
      Relay_Deactivate();
      Serial_Status=0;
    }

  }

}




void Relay_Activate()
{
   // MsTimer2::stop();
   
   for (unsigned long start = millis(); millis() - start < 10000;)
  {
    digitalWrite(RELAY1,HIGH);
    Serial_Status=1;
  }
   
    digitalWrite(RELAY1,HIGH);
    Serial_Status=1;
 
}

void  Relay_Deactivate()
{
  digitalWrite(RELAY1,LOW);
 // Serial_Status=0;
}

void Relay_Intialize()
{
  digitalWrite(RELAY1,LOW);
}

void setup() {
  Serial.begin(9600); // set serial speed
  pinMode(RELAY1, OUTPUT); // set LED as output
  //digitalWrite(RELAY1, LOW); //turn off LED

  pinMode(Analog_Pin,INPUT);
  Relay_Intialize();
}




void loop(){
  TakeReading();
  Chk_Relay_Tripped();
  Serial.println(Output_Current);
   //while (Serial.available() == 0); // do nothing if nothing sent
  int val = Serial.read() - '0';
  if (val == 1) { // test for command 1 then turn on LED
    Serial.println("RELAY on");
    digitalWrite(RELAY1, LOW); // turn on LED
    Serial_Status=1;

  }
  else if (val == 0) // test for command 0 then turn off LED
  {
    Serial.println("RELAY OFF");
    digitalWrite(RELAY1, HIGH); // turn off LED
    Serial_Status=0;
  }
  delay(500);
}

In below code , In below function It will wait for 30S to execute once 30s elapsed other thing s will be printed. But i wanted to print even in 30s . What need to change in below code.

Code:
void Relay_Activate()
{
  for (unsigned long start = millis(); millis() - start <30000;)
  {
    digitalWrite(RELAY1,HIGH);
    Serial_Status=1;
  }

}
10  Using Arduino / Programming Questions / Re: Relay Checking on: September 17, 2014, 03:11:13 am
Code:

int Analog_Pin=5;
int newaverage;
float Output_Current;
#define RELAY1  7
#define MAX_TRIP_COUNT  5
float Current_Limit=0.6;
static int Trip_Count=0;
static int Tripped_Flag=1;
int Serial_Status=0;



void TakeReading()
{
  newaverage = analogRead(A5);
 
  Serial.print("newaverage:");
  Serial.println(newaverage);
  Output_Current = 0.0336666666667*newaverage - 17.17;
}


void Chk_Relay_Tripped()
{
  if(Output_Current>=Current_Limit)
  {
    Trip_Count=Trip_Count+1;
    if((Trip_Count>=MAX_TRIP_COUNT) &&(Serial_Status==0))
    {

      Trip_Count=0;
      Relay_Activate();
    }
    else
      if(Serial_Status==1)
      {
        Serial.println("> MODE");
        Relay_Deactivate();
      }

  }
  else
  {
    Trip_Count=Trip_Count-1;
    if(Trip_Count<0)
    {
      Trip_Count=0;
    }

    if(Trip_Count<MAX_TRIP_COUNT && Serial_Status==1)
    {
      Relay_Deactivate();
      Serial_Status=0;
    }

  }

}




void Relay_Activate()
{
  for (unsigned long start = millis(); millis() - start < 30000;)
  {
    digitalWrite(RELAY1,HIGH);
    Serial_Status=1;
  }

}

void  Relay_Deactivate()
{
  digitalWrite(RELAY1,LOW);
 // Serial_Status=0;
}

void Relay_Intialize()
{
  digitalWrite(RELAY1,LOW);
}

void setup() {
  Serial.begin(9600); // set serial speed
  pinMode(RELAY1, OUTPUT); // set LED as output
  //digitalWrite(RELAY1, LOW); //turn off LED

  pinMode(Analog_Pin,INPUT);
  Relay_Intialize();
}




void loop(){
  TakeReading();
  Chk_Relay_Tripped();
  Serial.println(Output_Current);
  Serial.print("out count:");
  Serial.println(Trip_Count);
  Serial.print("Serial_Status:");
  Serial.println(Serial_Status);

  //while (Serial.available() == 0); // do nothing if nothing sent
  int val = Serial.read() - '0';
  if (val == 1) { // test for command 1 then turn on LED
    Serial.println("RELAY on");
    digitalWrite(RELAY1, LOW); // turn on LED
    Serial_Status=1;

  }
  else if (val == 0) // test for command 0 then turn off LED
  {
    Serial.println("RELAY OFF");
    digitalWrite(RELAY1, HIGH); // turn off LED
    Serial_Status=0;
  }
  delay(500);
}




This code working fine for me . But problem in automatic mode. It wait for 30s execute . I wanted to data must be printed like current value even Until 30S elapsed.
11  Using Arduino / Programming Questions / Re: Relay Checking on: September 17, 2014, 01:17:45 am
My testing CODe Here .  which is working

I dont know How to keep status High always for serial
if i comment these line send command serially it work always  relay on continously.


Quote
TakeReading();
  Chk_Relay_Tripped();
  Serial.println(Output_Current);
Code:

int Analog_Pin=5;
int newaverage;
float Output_Current;
#define RELAY1  2
#define MAX_TRIP_COUNT  5
float Current_Limit=0.60;
static int Trip_Count=0;
static int Tripped_Flag=1;

void TakeReading()
{
  newaverage = analogRead(A5);
  // Serial.print("count:");
  // Serial.println(newaverage);
  Output_Current = 0.0336666666667*newaverage - 17.17;
}


void Chk_Relay_Tripped()
{
  if(Output_Current>Current_Limit)
  {
    Trip_Count=Trip_Count+1;
    // Serial.print("Trip_Count:");
    //Serial.println(Trip_Count);
    if(Trip_Count>=5)
    {
      Relay_Activate();
    }
  }
  else
  {
    if(Trip_Count<=0)
    {
      Trip_Count=0;
    }
    else
    {
      Trip_Count=Trip_Count-1;
    }

    Relay_Deactivate();
    // Serial.print("Trip_Count:");
    // Serial.println(Trip_Count);

  }

}



void Relay_Activate()
{
  for (unsigned long start = millis(); millis() - start < 10000;)
  {
    digitalWrite(RELAY1,HIGH);
    if (Serial.available() == 0); // do nothing if nothing sent
    int val = Serial.read() - '0'; // deduct ascii value of '0' to find numeric value of sent number

    if (val == 1) {
      digitalWrite(RELAY1, LOW); // turn on LED
    }
    //Serial.println("RELAY GOT TRIPPED");
    Tripped_Flag=0;
    Trip_Count=0;
  }

}

void  Relay_Deactivate()
{
  digitalWrite(RELAY1,LOW);
  Tripped_Flag=1;

}

void Relay_Intialize()
{
   digitalWrite(RELAY1,LOW);
}

void setup() {
  Serial.begin(9600); // set serial speed
  pinMode(RELAY1, OUTPUT); // set LED as output
  digitalWrite(RELAY1, LOW); //turn off LED

  pinMode(Analog_Pin,INPUT);

}




void loop(){
  TakeReading();
  Chk_Relay_Tripped();
  Serial.println(Output_Current);

  while (Serial.available() == 0); // do nothing if nothing sent
  int val = Serial.read() - '0'; // deduct ascii value of '0' to find numeric value of sent number

  if (val == 1) { // test for command 1 then turn on LED
    Serial.println("RELAY on");
    digitalWrite(RELAY1, HIGH); // turn on LED
  }
  else if (val == 0) // test for command 0 then turn off LED
  {
    Serial.println("RELAY OFF");
    digitalWrite(RELAY1, LOW); // turn off LED
  }
  else // if not one of above command, do nothing
  {
    //val = val;
    Serial.println("Wrong command");
  }
  Serial.println(val);
  Serial.flush(); // clear serial port
}


12  Using Arduino / Programming Questions / Relay Checking on: September 17, 2014, 01:07:39 am
Dear all.
I am doing simple program Where . I am controlling on current limit of sensor. If current sensor value exceed 1A trip the relay
SImilarly via serial port. If i send command 1 activate relay if 0 deactivate relay. Indivually then are workg fine . relay got trip after 30S in automatic mode and similary if i send command serially activate and Deactivate. Now I wanted to combine both code.
either one status ie. relay or serial.receive High , Activate else deactivate.But Here relay not activate itself.

Here is my code
Code:

float Current_Limit=0.60;
int newaverage;
float Output_Current;
static int Trip_Count=0;

void Serial_Command()
{
//  while (Serial.available() == 0); // do nothing if nothing sent
int val = Serial.read() - '0'; // deduct ascii value of '0' to find numeric value of sent number
int Check_fault=Relay_Fault_Check();
if (val == 1 || Check_fault== 1) {
  // test for command 1 then turn on LED
//Serial.println("RELAY1 on");
digitalWrite(RELAY1, HIGH); // turn on LED
Relay_Status=1;
}
else if (val == 0 || Check_fault==0) // test for command 0 then turn off LED
{
//Serial.println("RELAY1 OFF");
digitalWrite(RELAY1, LOW); // turn off LED
Relay_Status=0;
}
 
 
}
int  Relay_Fault_Check()
{
 
if(Output_Current>Current_Limit)
 {
      Trip_Count=Trip_Count+1;
      if(Trip_Count>=5)
   {
     Tripped_Flag=1;
      Serial.print("Tripped_Flag:");
 Serial.println(Tripped_Flag);
  return(Tripped_Flag);
   }
 }else
 {
   if(Trip_Count<=0)
   {
     Trip_Count=0;
   }else
   {
   Trip_Count=Trip_Count-1;
   }
    Tripped_Flag=0;
     Serial.print("Tripped_Flag:");
 Serial.println(Tripped_Flag);
  return(Tripped_Flag);
 }
 
 
}

void loop()
{
Serial_Command();
delay(500);
}



13  Using Arduino / Interfacing w/ Software on the Computer / Re: VIsual basic with arduino on: September 16, 2014, 11:18:28 pm
Quote

What makes your textBox code read the serial port?

When, and how often, does that happen?
I already said my data send serially every 1S . Whatever there in Serial Buffer must be read Displayed .At current i am just sending only current value.
14  Using Arduino / Interfacing w/ Software on the Computer / Re: VIsual basic with arduino on: September 16, 2014, 07:50:56 am
Can you elobate it . Where i need call this function once Arduino or VB script.

Quote
What triggers this callback? Arrival of data on the not opened serial port? Not likely.

My data coming from Serial ny arduino. Keep accumulating. What i should here to do it work
15  Using Arduino / Interfacing w/ Software on the Computer / Re: VIsual basic with arduino on: September 16, 2014, 07:21:44 am
Arduino Code

Code:

int Analog_Pin=5;
int newaverage;
float Output_Current;


#define RELAY1  7
#define MAX_TRIP_COUNT  5
float Current_Limit=0.60;
static int Trip_Count=0;
static int Tripped_Flag=1;

#include <avr/wdt.h>



void TakeReading()
{
  newaverage = analogRead(A5);
  // Serial.print("count:");
  //Serial.println(newaverage);
  Output_Current = 0.0336666666667*newaverage - 17.17;
}

void Relay_Activate()
{
  for (unsigned long start = millis(); millis() - start < 10000;)
  {
    digitalWrite(RELAY1,HIGH);

    //Serial.println("RELAY GOT TRIPPED");
    Tripped_Flag=0;
    Trip_Count=0;
  }

}

void  Relay_Deactivate()
{
  digitalWrite(RELAY1,LOW);

  //  Serial.println("RELAY NOT TRIPPED");
  Tripped_Flag=1;

}

void Relay_Intialize()
{
  //Serial.println("RELAY GOT INTIALISE....");
  digitalWrite(RELAY1,LOW);

}


void Chk_Relay_Tripped()
{
  if(Output_Current>Current_Limit)
  {
    Trip_Count=Trip_Count+1;
    // Serial.print("Trip_Count:");
    //Serial.println(Trip_Count);
    if(Trip_Count>=5)
    {
      Relay_Activate();
    }
  }
  else
  {
    if(Trip_Count<=0)
    {
      Trip_Count=0;
    }
    else
    {
      Trip_Count=Trip_Count-1;
    }

    Relay_Deactivate();
    // Serial.print("Trip_Count:");
    // Serial.println(Trip_Count);

  }

}

void setup() {
  Serial.begin(9600); // set serial speed

  pinMode(RELAY1,OUTPUT);
  wdt_enable(WDTO_8S);
  Relay_Intialize();

  pinMode(Analog_Pin,INPUT);

}




void loop(){

  wdt_reset();
  TakeReading();
  //Serial.println(Output_Current);
  Chk_Relay_Tripped();

  Serial.println(Output_Current);


  if (Serial.available() == 0); // do nothing if nothing sent
  int val = Serial.read() - '0'; // deduct ascii value of '0' to find numeric value of sent number

  if (val == 1) {
    digitalWrite(RELAY1, HIGH); // turn on LED
  }
  else if (val == 0) // test for command 0 then turn off LED
  {

    digitalWrite(RELAY1, LOW); // turn off LED
  }


 // Serial.flush(); // clear serial port
  delay(1000);
}

VB code
Code:
Imports System.IO
Imports System.IO.Ports
Imports System.Threading

Public Class Form1
    Shared _continue As Boolean


    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load


        SerialPort1.PortName = "COM3"

        SerialPort1.BaudRate = 9600
        SerialPort1.DataBits = 8
        SerialPort1.Parity = IO.Ports.Parity.None
        SerialPort1.StopBits = IO.Ports.StopBits.One
        SerialPort1.Handshake = IO.Ports.Handshake.None
        SerialPort1.Encoding = System.Text.Encoding.Default 'very important!

    End Sub


    Private Sub Button1_Click_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1_Click.Click
        SerialPort1.Open()
        SerialPort1.Write("1")
        SerialPort1.Close()
    End Sub



    Private Sub Button2_Click_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2_Click.Click
        SerialPort1.Open()
        SerialPort1.Write("0")
        SerialPort1.Close()
    End Sub




    Private Sub Current_Read_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        SerialPort1.Open()
        ' Dim str As String'
        ' str = SerialPort1.ReadExisting'
        Current_Read.Text = SerialPort1.ReadLine()


        SerialPort1.Close()
    End Sub


    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        TextBox1.Text = "ABCD"
    End Sub
   
End Class


This code is working  fine on VB script . I can control the LED . Problem i am facing is getting analog value. I got analog value one at time . after that in serial monitor it changing But Not in VB . Is anyone give reason here. What mistake I am doing
Pages: [1] 2 3 ... 64