Interfacing Arduino with Current Transformer – AC Current Measurement

Hi there,

I am trying to implement a CT with help of Arduino IDE and proteus, take a look the original work here, https://simple-circuit.com/interfacing-arduino-with-current-transformer-ac-current-sensor-rms/

I have translated this circuit to proteus.

CT name (as noted): ZDCT004GL
Primary rated current: 20 A
Secondary rated current: 10 mA
Turns ratio: 20/0.01 = 2000
Max burden resistance (sampling resistance): 100 Ohm

The secondary of the current transformer is connected to resistor with resistance of 20 Ohm (R1), other resistance values may be used (up to 100 Ohm).
With R1 = 20 Ohm and at rated primary current of 20A, the voltage drop across R1 is:
V = 20 x 10mA = 200mV AC.

Number of problem arises here,

  1. Adding a load heater always give 44 A RMS current.
  2. Difficult to configure a current transformer.
  3. Inverting switching regulator MCP150130ESN output gives wrong voltage reading.


#include <LiquidCrystal.h>   // include Arduino LCD library

// LCD module connections (RS, E, D4, D5, D6, D7)
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);

// define analog channel input
#define INPUT_CHANNEL  A0
// other definitions
#define CT_RATIO     2000    // current transformer ratio 2000/1 = 2000
#define SHUNT_RES    20      // shunt resistor connected to CT secondary = 20 Ohm
#define REF_VOLTAGE  1024    // reference voltage for ADC, in millivolts

// variables
const uint16_t n = 256;   // total number of samples (readings) - without oversampling
uint16_t r_array[n];      // readings array

void setup(void) {
  
  Serial.begin(9600);

  lcd.begin(16, 2);     // set up the LCD's number of columns and rows
  lcd.setCursor(0, 0);  // move cursor to column 0, row 0 [position (0, 0)]
  lcd.print("RMS Current =");

  analogReference(EXTERNAL);    // set positive reference voltage to external

}

void loop() {

  float dc_offset = 0;
  float rms_voltage = 0;

  for (uint16_t i = 0; i < n; i++)
    r_array[i] = 0;

  // read voltage at INPUT_CHANNEL 'n' times and save data to 'r_array'
  for (uint16_t i = 0; i < n; i++) {
    // adding another 2 bits using oversampling technique
    for (uint16_t j = 0; j < 16; j++) {
      r_array[i] += analogRead(INPUT_CHANNEL);
    }
    r_array[i] /= 4;
  }

  // calculate signal average value (DC offset)
  for (uint16_t i = 0; i < n; i++)
    dc_offset += r_array[i];
  dc_offset = dc_offset / n;

  // calculate AC signal RMS value
  for (uint16_t i = 0; i < n; i++) {
    if( abs(r_array[i] - dc_offset) > 3)
      rms_voltage += sq( r_array[i] - dc_offset );
  }
  rms_voltage = rms_voltage / n;

  // calculate Arduino analog channel input RMS voltage in millivolts
  rms_voltage = sqrt(rms_voltage) * REF_VOLTAGE / 4096;  // 4096 is max digital value for 12-bit number (oversampled ADC)

  // calculate current passing through the shunt resistor by applying Ohm's Law (in milli Amps)
  float rms_current = rms_voltage / SHUNT_RES ;
  // now we can get current passing through the CT in milli Amps
  rms_current = rms_current * CT_RATIO;
  // convert milli Amps to Amps
  rms_current /= 1000;

  char _buffer[9];
  if(rms_current < 10.0)        // if current < 10 Amps
    sprintf( _buffer, " %1u.%03u A", (uint8_t)rms_current, (uint16_t)(rms_current * 1000) % 1000 );
  else
    sprintf( _buffer, "%2u.%03u A", (uint8_t)rms_current, (uint16_t)(rms_current * 100) % 100 );

  // print data on the LCD
  lcd.setCursor(0, 1);
  lcd.print(_buffer);

  // send data to Arduino serial monitor
  Serial.print( "RMS Current = " );
  Serial.println( _buffer );
  Serial.println();

}

// end of code.

Try the Open Energy Monitor approach. There is no need for the op amp, and it adds additional complications.

Few people will look elsewhere for the supporting details, so for help with your problem, please post a close up, focused pic of the actual setup, a pic of hand drawn wiring diagram of your circuit, with all parts and connections clearly labeled, and the code in line, using code tags.

Posting instructions can be found in the "How to get the best out of this forum" post, linked at the head of every forum category.

Not to dissuade the whole CT (Current Transformer) approach but rather than a CT you may want to place dome thought into the use of a Current Transducer. I have no clue as to your full intended application but you may want to consider something like this. The merit being you get a Vout proportional to the AC Current. Transducers like this come in a variety of ranges and outputs. Just something to consider.

Ron

@anon94801460 I understand.

What's the purpose of this current measurement?

Generally, current transformer is used to transmit current image information signal to a measuring instrument, protective device or similar apparatus.

@anon94801460 open Energy monitoring is another application. I have edited my post here to make it understandable.

Yes, do you have any idea

Generally, your circuit is way too complicated to be protective device.

You don't want to amplify the current signal to sense in a suitable level?

Try using the following device (ACS712 Current Sensor):

Data Sheet:
ACS712_AllegroMicroSystems.pdf (934.8 KB)

Nope, my input current level is 10mA, take a look what your suggestion says,

You have primary rated current: 20 A

So, the ACS712 will provide you: 20 x 100 = 2000 mV = 2 V DC.

You may collect one/two ACS712 and test it physically.

You could look into the MAX471 sensor, I have used it to sense 10mA before
MAX471 Sensor

How much max AC current you can feed through VIN-GND terminals? What is the transfer function of the sensor on VOUT-GND terminals?

Wrote a library with examples so a quick test can be done quite fast.

According to - https://electronoobs.com/eng_arduino_tut81.php

The MAX471 is a solid alternative to an ACS712 for measuring DC Current. Its a high side device that is powered by a load source that can range anywhere from 3 to 36 VDC.

You might need to check datasheet if it does AC too.

I just saw this is for AC current measurement. The MAX471 might not be great for that unless there’s an external circuit that can convert the DC sending current to AC.

Or it might actually be able to sense AC directly, this is the data sheet. Still try it out poster.

@Hasaniirc

ACS712-master.zip (43.1 KB) (RobTillaart)
ACS712-0.3.10 (1).zip (41.9 KB) (Arduino)

Does it fits with this project ? Discuss with the wiring.