Multiple ACS712 sensors for 3 phase monitoring

I've managed to find some code to help with getting a True RMS reading from the ACS712 modules using the filters library. While this works fine and all with a single sensor, I'm trying to monitor a 3 phase motor for any variation in the phases. I'm not too hot with modifying the code to accommodate the other two sensors and any kind of addition with extra code using a 5kg hammer just completely stops it from working. So far I've only managed to add code for a Nokia display and I've prototyped a board for another two sensors on the A0 and A1 inputs. Any kind of guiding hand would be nice if possible, please.

#include <Adafruit_GFX.h>
#include <Adafruit_PCD8544.h>
#include <Wire.h>
#include <Filters.h>                      //This library does a massive work check it's .cpp file
//#include <LiquidCrystal.h>

#define ACS_Pin A2   
#define backLight 2
//Sensor data pin on A2 analog input
//const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
//LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

//const int numRows = 2;
//const int numCols = 16;
Adafruit_PCD8544 display = Adafruit_PCD8544(7, 6, 5, 4, 3);
float ACS_Value;                              //Here we keep the raw data valuess
float testFrequency = 50;                    // test signal frequency (Hz)
float windowLength = 40.0/testFrequency;     // how long to average the signal, for statistist

int Page = 1;

float intercept = -0.1; // to be adjusted based on calibration testing
float slope = 0.0647; // to be adjusted based on calibration testing
                      //Please check the ACS712 Tutorial video by SurtrTech to see how to get them because it depends on your sensor, or look below


float Amps_TRMS; // estimated actual current in amps
float amp1Display;
unsigned long printPeriod = 1000; // in milliseconds
// Track time in milliseconds since last reading 
unsigned long previousMillis = 0;

void setup() {
  analogReference(EXTERNAL);
  Serial.begin( 9600 );    // Start the serial port
  pinMode(ACS_Pin,INPUT);  //Define the pin mode
  pinMode(backLight, OUTPUT);
    display.begin();
  display.setContrast(50);
      display.display();
         analogWrite(backLight, 150);

}

void loop() {
  RunningStatistics inputStats;                 // create statistics to look at the raw test signal

  inputStats.setWindowSecs( windowLength );     //Set the window length

  while( true ){
    ACS_Value = analogRead(ACS_Pin);  // read the analog in value:
    inputStats.input(ACS_Value);  // log to Stats function
        
    if((unsigned long)(millis() - previousMillis) >= printPeriod) { //every second we do the calculation
      previousMillis = millis();   // update time
      
      Amps_TRMS = intercept + slope * inputStats.sigma();
      Serial.print( "\t without calc: " ); 
      Serial.print(inputStats.sigma());
      Serial.print( "\t Amps: " ); 
      Serial.print(Amps_TRMS);
            Serial.print( "\t Sigma: " ); 
      Serial.print( inputStats.sigma() * 0.0647 ); //calibrate line
                  Serial.print( "\t Display 1: " ); 
      Serial.println(amp1Display);


    
    if (Amps_TRMS <= 0){
      amp1Display = 0.00;
    }
      else
        amp1Display = Amps_TRMS;
      
    
    screen1();
  }
  }
}
void screen1(){
  display.setTextSize(1);
  display.clearDisplay();
  display.setTextColor(BLACK, WHITE);
  display.setCursor(5, 2);
  display.print("Current Info");
  display.drawFastHLine(0,10,83,BLACK);
  display.drawFastHLine(0,0,83,BLACK);
  display.drawFastHLine(0,47,83,BLACK);
  display.drawFastVLine(0,0,50,BLACK);
  display.drawFastVLine(83,0,50,BLACK);

  display.setCursor(5, 12);
display.print("Phase1:");
  display.setCursor(50, 12);
display.print(amp1Display);
    display.display();
}

I am confused as what you want to do. You mention true RMS, but then go on to discuss phase variations. Why do you think the two are connected? And what standard are you comparing the phase of the current to?

Yeah I should probably fix that part. I'll chalk that up to me just waking up.
The sensor spits out a voltage reading according to the current draw so the true RMS reading in the library gives a more accurate reading even if the if wave form varies slightly. I'm putting a sensor on each phase of a 3 phase motor to meassure the current draw on each phase and if one drops by a certain percentage I want to shut the system down (long story short its a 3 phase water pump on our farm that's a nightmare to pull out of a 60m deep hole when it fries) before it fries.

Since your project has nothing to do with monitoring the phase of the currents, why not change the title of your posting?
Historically, why does the motor fry? Is the motor submersible and is leaking water? Does the water level drop so the motor is no longer water cooled?
The pump on my domestic well is at 420 feet, so I know what is involved when the service people have to pull it!

I suggest that rather than an RMS value, you just average the voltage readings over several seconds while the pump is running and alarm when that value is exceeded.

Well, it is a 3-phase pump so I thought it was appropriate. Yeah considering the mains supply is 50Hz stable I probably shouldn't bother with needless complications. I thought it was cool? lol

I have no idea why the motor fried last time. It didn't even last a year whereas it usually stays good for about 5 or 6 years. The warranty office just sent back a picture of fried windings and said something was wrong with the supply. I found this rather odd considering there is a phase protection unit mounted. Granted this monitors that there isn't an anomaly in the supply voltage, before the contactor for the pump, but doesn't actually monitor the current or voltage to the pump (it's just wired parallel to the supply and cuts off power to the contactor's coil if it isn't right).
I did notice however when I put the new pump down, we had a 4 core armour cable going to the pump with the red, yellow, blue and black cable. Been a 3 phase I wired up the coloured ones and snipped the black off at both ends. while making sure the pump ran the right direction my hand grazed over a bit of bare copper from the black cable and I got that tingle of "not quite powered" buzz. considering this cable was cut off at both ends I can only assume there is a piece of cable under the ground that might have gotten hot and fuzed with the black cable slightly. Not enough to trip the system but still enough to cause one of the winding to work more than needed. Long story short again I want to put this in to stop something like that in future.

Do you understand the difference between a "Y" type 3-phase connection and a "delta" type three-phase connection? Which do you have and does the pump motor match?

There should be no variation phase to phase of the currents , unless a phase has become open circuit .
Your pump motor should have the appropriate sized fuses and thermal over load trips to prevent it failing .

50Hz usually means a 220-240volt mains.
I hope you do know that the ACS712 is not safe for 230volt AC,
and the boards from China they come on make things worse.
It would be wise to change to current transformers, and keep the ACS boards for low-voltage projects.
Leo..

Repeating myself here … there won’t be any phase to phase variation unless there is a winding failure ( which will stop the motor ) so you project won’t tell you anything .
Correctly sized motor with proper overload protection is the answer

Yes I do. I'm assuming the pump is in delta but I can't open to check because the whole unit is sealed because its, well submersible. The wiring for it is just to go into a pump starter unit. The one with the big red and green buttons =P

Ah yes, this is getting closer to topic. In most cases they do run alright and yes, it does have a 5amp overload on the contactor which yes does work correctly. my whole project is to stop one phase from drawing less current or more current than the other two by a few percent. If it falls under the amount of the overload it won't do anything, but if a winding draws say 10% more or less than the others there is a long term effect on the pump an overload wont figure out. This is my project =D
On a side note you do buy these things but they cost a stupidly large sum.

I've used them before and granted they do look a little.....uh sub-optimal. I was thinking about replacing them with these (HKD AC/DC CURRENT SENSOR MOD 50A - Communica [Part No: HKD AC/DC CURRENT SENSOR MOD 50A]) which could work pretty well. and yes, it is 220 volt. To make matters worse since I'm going for three phase that boots it up to around 380/400 so yeah. probably not the best thing to use. Thanks for the imput.

For mains voltage I prefer non-invasive (clip-on) current sensors over hall-type sensors.
Leo..

1 Like

How come? Mainly from a safety perspective? I've seen them and thought about it but they tend to be more expensive and seem a little cumbersome.

What do you think is safer.
A circuit board with cut and bare soldered connections and bare pads,
or a plastic box clipped over an existing uncut insulated wire.
Leo..

I was asking what was your perspective on preference lol. I wasn't saying they weren't safer.
My only problem is I'm using the power from the ac to power the whole system. Eventually it'll be contained in its own unit with no bare copper exposed but for a test they would be better. Not so much for a permanent system. Not in my case as least.

Under what circumstance can this possibly happen ? The only way this can happen is if there is a power supply imbalance , which can be readily spotted by measuring the phase voltages ( no need to measure current ) . A power supply imbalance could cause damage , but your phrase “draws more “ suggests the problem is with a motor fault .
Then again harmonics on the power supply could also cause issues …..

To measure voltage I would use small lightly loaded transformer, on each phase, to get a safer voltage . Will need calibrating , but the safe way . Or buy voltage transducers.
Might be worth looking at what single phase loads also have , the supply capacity etc to identify any unbalance source .

A temperature sensor on the motor may do the job too

You could always just buy one … probably cheaper and more suitable

Example

Well, a temp sensor at the motor would just be, uh, problematic. I mean it is a 75mm wide motor down a 150mm diameter hole that is submerged in about 40m of water. So assuming the cooling sleeve is doing its job I don't think that would be an issue. Also from the supply board where the switch and overload is to where the actual pump hole is situated is about 100m. I can't put any kind of monitoring at the pump itself.
I appreciate all the input and ideas but I notice this is all wildly out of the scope of the original question. In the meantime I have made some headway with the programming of the Arduino to get more or less what I wanted.

Trying to be helpful mate - measure the supply voltage , easy ! Google phase balance

Notice how the scope of your question has expanded !