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,
- Adding a load heater always give 44 A RMS current.
- Difficult to configure a current transformer.
- 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.




