EMI problem

Good eve., well I have a project that includes 2 flow meters. these 2 flow meters are attached and uses interrupts (pins 2 and 3 of arduino uno). I also have 3 DC motors and 2 ac motors attached to relays controlled by the same arduino the flow meters are attached. The readings of flow meters are displayed on the LCD, the problem is when the process starts the motors should start working also but the readings on the lcd of flow meters fluctuates, it gives large value which is normally should not happen. I also test the flow meters without the motors running and it works fine... Im assuming it is because of EMI that the motors generates.. any suggestions where I can eliminate these? ? Thank you

Im assuming it is because of EMI that the motors generates.

EMI - how did you get that silly idea follow the forum guide lines!

Mark

holmes4:
EMI - how did you get that silly idea follow the forum guide lines!

Mark

Ive consulted with other project makers and thats what they said. It is my first time encountering with this problem. Do you know what could be the problem?

Circuit diagram and code listing ...

What size of motors, voltage, inrush current?
One simple way around could be that flow meter reading is not done during a suitable time window around motor start, waiting for EMI disturbance to die out.

Railroader:
What size of motors, voltage, inrush current?
One simple way around could be that flow meter reading is not done during a suitable time window around motor start, waiting for EMI disturbance to die out.

2 DC motors are 12v motorized valves, and 1 12V DC geared motor.. 3 single phase AC motor 220V.
tried waiting for more than 10 mins of motors running before reading the flow meter but it doesnt work. does these EMI has possible filter circuit or device to eliminate or reduce? ? ?

Why have you not posted a wiring diagram and the details of the motors, motor drivers, etc.?

Do so after reading the "How to use this forum" post.

//////////////////////////LCD Library
#include <Wire.h>
#include <hd44780.h>
#include <hd44780ioClass/hd44780_I2Cexp.h>
hd44780_I2Cexp lcd;
//////////////////////////Flow Meter Library
#include <FlowMeter.h>
FlowSensorProperties MySensor1 = {30.0f, 6.5f, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1}};
FlowSensorProperties MySensor2 = {30.0f, 7.4f, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1}};
FlowMeter Meter1 = FlowMeter(2,MySensor1);
FlowMeter Meter2 = FlowMeter(3,MySensor2);
const unsigned long period = 1000;
//////////////////////////Variables
int m =0;
int s = 0;
int a,b,x,y;
static unsigned long Print = millis();
#define printInterval 500
//////////////////////////Pin Config
const int relay1 = 4;
const int relay2 = 5;
const int relay3 = 6;
const int relay4 = 7;
const int pb1 = 8;
const int pb2 = 9;
const int pb3 = 10;
const int tr3 = 13;
//////////////////////////Sensor Interrupt
void Meter1ISR() {Meter1.count();}
void Meter2ISR() {Meter2.count();}

void setup() {

//////////////////////////Initializations
lcd.begin(16,2);
Serial.begin (9600);
pinMode (pb1,INPUT_PULLUP);
pinMode (pb2,INPUT_PULLUP);
pinMode (pb3,INPUT_PULLUP);
pinMode (tr3,OUTPUT);
pinMode (relay1,OUTPUT);
pinMode (relay2,OUTPUT);
pinMode (relay3,OUTPUT);
pinMode (relay4,OUTPUT);
attachInterrupt(INT0, Meter1ISR, RISING);
attachInterrupt(INT1, Meter2ISR, RISING);
Meter1.reset();
Meter2.reset();
//////////////////////////Relays OFF (HIGH=OFF, LOW=ON)
digitalWrite (relay1,HIGH);
digitalWrite (relay2,HIGH);
digitalWrite (relay3,HIGH);
//////////////////////////Initial Display (Loading)
lcd.clear ();
lcd.setCursor (4,0);
lcd.print (“Loading”);
for(int x=0; x<=15; x++){
lcd.setCursor (x,1);
lcd.print(".");
delay (200);
}
//////////////////////////Main Menu
lcd.clear();
lcd.setCursor (1,0);
lcd.print (“Select Weight”);
lcd.setCursor (0,1);
lcd.print (“3kg 4kg 5kg”);
}

void loop() {
//////////////////////////Latch
if(!digitalRead(pb1)){a=1;}
else if (!digitalRead(pb2)){a=2;}
else if (!digitalRead(pb3)){a=3;}

if (a==0){
digitalWrite(tr3,HIGH);
}
else {
digitalWrite(tr3,LOW);
}
//////////////////////////
Meter1.tick(period);
Meter2.tick(period);
//////////////////////////Sensor Display
if (a>=1){
if(millis() - Print > printInterval){
lcd.clear();
lcd.setCursor(0,0);
lcd.print (“TANK 1 TANK 2”);
lcd.setCursor(0,1);
lcd.print (Meter1.getTotalVolume());
lcd.setCursor(5,1);
lcd.print (“L”);
lcd.setCursor(9,1);
lcd.print (Meter2.getTotalVolume());
lcd.setCursor(14,1);
lcd.print (“L”);
Print=millis();
}
digitalWrite(relay1,LOW);
digitalWrite(relay2,LOW);
}
//////////////////////////Conditions (change a to specified conditions)
float sensor1 = Meter1.getTotalVolume();
float sensor2 = Meter2.getTotalVolume();

if ((a==1)&&(sensor1>=0.4)) {x=1; digitalWrite(relay1,HIGH);}
else if ((a==2)&&(sensor1>=0.2)) {x=2; digitalWrite(relay1,HIGH);}
else if ((a==3)&&(sensor1>=1.5)) {x=3; digitalWrite(relay1,HIGH);}

if ((a==1)&&(sensor2>=0.4)) {y=1; digitalWrite(relay2,HIGH);}
else if ((a==2)&&(sensor2>=0.2)) {y=2; digitalWrite(relay2,HIGH);}
else if ((a==3)&&(sensor2>=1.5)) {y=3; digitalWrite(relay2,HIGH);}
//////////////////////////Mixing Conditions
if (((x==1)&&(y==1))||((x==2)&&(y==2))||((x==3)&&(y==3))){b=1;}

if (b==1){
digitalWrite (relay3,LOW);
lcd.clear();
lcd.setCursor(2,0);
lcd.print("…Mixing…");
lcd.setCursor(7,1);
lcd.print(":");
if (s<=9){
lcd.setCursor(8,1);
lcd.print(“0”);
lcd.setCursor(9,1);
lcd.print(s);
}
else {lcd.setCursor(8,1);lcd.print(s);}

if (m<=9){
lcd.setCursor(5,1);
lcd.print(“0”);
lcd.setCursor(6,1);
lcd.print(m);
}
else {lcd.setCursor(5,1);lcd.print(m);}

if (s==59){m++;}
else if(s==60){
lcd.setCursor(8,1);
lcd.print(“00”);
s=0;
}

delay(1000);
s++;
}

while(m>=10){
b=0;
digitalWrite (relay3,HIGH);
lcd.clear();
lcd.setCursor(6,0);
lcd.print(“DONE”);
lcd.setCursor(5,1);
lcd.print(“MIXING”);
delay(100);
}

Serial.println (b);
}

Go back and read the "How to use this forum" post, and add code tags to your post.

Where are the other required details?

Don't bother to come back if you can't follow the guidelines.

Wow, those motors must be BIG.
They use a mix of volts.

Update for the project.. that motorized valve are the problem!! we replaced it with solenoid valves.. Thank you

If you'e swapped to solenoid valves, you can reduce your power consumption (in most cases), by using PWM to drive the coils.

analogWrite(solenoidPin, 255); // full power to 'pull' on
delay(50); // 50mS blocking is probably ok here (or convert to millis())
analogWrite(solenoidPin, 50); // reduced drive to 'hold' the solenoid on