Current Transformer Conditioner: Difference between revisions

From lechacal
Jump to navigation Jump to search
 
(44 intermediate revisions by the same user not shown)
Line 2: Line 2:
[[File:IMG_1848_small.png | right | 300px]]
[[File:IMG_1848_small.png | right | 300px]]


The CT Conditioner allows to connect a Current Transformer to an Arduino Analog pin.
The CT Conditioner allows to connect a CT sensor to an Arduino board.


* Supports both '''current''' and '''voltage''' output CT.
* Supports both '''current''' and '''voltage''' output CT.
Line 51: Line 51:
A simple arduino sketch can be used to read the value every seconds. See the example below.
A simple arduino sketch can be used to read the value every seconds. See the example below.


You must download and install the RPICTlib to compile the sketch.


<syntaxhighlight lang="C" line='line'>
http://lechacal.com/RPICT/RPICTlib/RPICTlib_v1.4.1.zip
// CT Conditioner Demo
 
// Version 1.0
<syntaxhighlight lang="c">
// lechacal.com
// CT Conditioner Demo
//
// Version 1.2
// Required Libraries
// lechacal.com
// RPICTlib 1.0.0
//
// http://lechacal.com/RPICT/RPICTlib/RPICTlib_v1.0.0.zip
// Required Libraries
//
// RPICTlib 1.4.1
// http://lechacal.com/RPICT/RPICTlib/RPICTlib_v1.4.1.zip
// Include these 3 lines at the top of the sketch
//
#include "RPICTlib.h"        // Include the library
 
uint8_t ADC_BITS = 10;        // Some mandatory global setup
#include "RPICTlib.h"        // Include the library
uint16_t ADC_COUNTS (1 << ADC_BITS);
 
int sInterval = 250;          // 250usec is 4kHz sampling interval (internal sampling)
int sInterval = 400;          // 400usec is 2.5kHz sampling interval (internal sampling)
 
int NUMBER_OF_SAMPLES = 1000; // We will use 1000 samples to measure the rms signal.
// We use 1000 samples to measure the rms signal.
// Ideal value depends on frequency
CurrentNode ct1;             // Our CT we will compute with
// for example for 50Hz using 10 full cycles
// N = 1000000 * 10 / 50 / 200
void setup()
int NUMBER_OF_SAMPLES = 1000;
{
 
   Serial.begin(38400); // Open the serial port
SignalNode ct1;               // CT computation node definition
 
void setup()
{
   Serial.begin(38400);       // Open the serial port
 
  adc_definition(10, 5000);  // Tell the library we are on 10 bits and 5V voltage reference.
  ct1.begin(A0, 30.00);      // Analog port A0, 30 scaling factor for SCT-013-030
}
 
void loop()
{
  ct1.calcRMS(NUMBER_OF_SAMPLES, sInterval); // Measure and compute Irms
  if (ct1.err) {
    Serial.println("err"); // Error. Current is too high and goes over-limit. (or maybe change sInterval to 400 (unlikely)).
  } else {
    Serial.print(ct1.RMS); // Print the result
    Serial.println(" A"); // Print the unit (Ampere)
  }


  ct1.init(A0, 30.0); // Analog port A0, 30 scaling factor (using a SCT-013-030)
}
void loop()
{
  ct1.calcIrms(NUMBER_OF_SAMPLES, sInterval); // Measure and compute Irms
  Serial.println(ct1.Irms);                  // Print the result
   delay(1000);                                // wait 1 second
   delay(1000);                                // wait 1 second
}
}
 
</syntaxhighlight>
</syntaxhighlight>


=Default Setup=
=Default Setup=


By default the CT conditioner comes with no resistors fitted for both Burden and Gain.
By default the CT conditioner comes without resistors fitted for both Burden and Gain.


This means this is ready for a voltage output CT and the Gain is 1.
This means this is ready for a voltage output CT and the Gain is 1.
Line 99: Line 110:


[[File:IMG_1846_small_01.png | 400px | right]]
[[File:IMG_1846_small_01.png | 400px | right]]
There 2 types of resistor the user can fit on the CT conditioner. These are not mandatory but will help optimising the measurement.
There are 2 types of resistor the user can fit on the CT conditioner. These are not mandatory but will help optimising the measurement.


Both surface mount and though hole resistor are supported. Surface mount resistor case are 0805 size.
Both surface mount and though hole resistor are supported. Surface mount resistor case are 0805 size.
Line 105: Line 116:
==Burden Resistor==
==Burden Resistor==


When a '''current''' output CT sensor is used a resistor must be soldered to the CT conditioner. It it usually recommended to use a low value resistor. ALso the datasheet of the CT should have some indication on the maximum resistor to use.
When a '''current''' output CT sensor is used a resistor must be soldered to the CT conditioner. It is usually recommended to use a low value resistor. Also the datasheet of the CT should have some indication on the maximum resistor to use.
Burden resistor is also called sampling resistor in some documentations.
Burden resistor is also called sampling resistor in some documentations.


Line 112: Line 123:
==Amplification==
==Amplification==


A second resistor can be fitted on the CT conditioner to adjust the amplification level. Amplification can be required if it is found the levels are too low. For low currents this can increase resolution.
A second resistor can be fitted on the CT conditioner to adjust the amplification level. Amplification can be required if levels are found too low. For low currents this can increase resolution.


From a desired gain the resistor can be calculated as follow
From a desired gain the resistor can be calculated as follow


Rg = 100000/(G -1)
[[File:Rg_Calc_01.png]]


''G'' is the Amplification Gain.<br>
''G'' is the Amplification Gain.<br>
Line 125: Line 136:
  G = Vadc/Vct/2√2
  G = Vadc/Vct/2√2


''Vadc'' if the full scale voltage value of the ADC. Usually 5V or 3.3V.<br>
''Vadc'' is the full scale voltage value of the ADC. Usually 5V or 3.3V.<br>
''Vct'' if the output voltage of the current transformer at maximum desired value (rms).
''Vct'' is the output voltage of the current transformer at maximum desired value (rms).


===Example===
===Example===
Line 134: Line 145:
Let's take the SCT-013-030. This outputs 1V at 30A (both rms and peak). Hence ICAL = 30.<br>
Let's take the SCT-013-030. This outputs 1V at 30A (both rms and peak). Hence ICAL = 30.<br>
Using an Arduino UNO the ADC has 5V reference by default. Hence Vadc = 5.<br>
Using an Arduino UNO the ADC has 5V reference by default. Hence Vadc = 5.<br>
We would like to measure 30A (i.e. 1V) at the maximum scale of the ADC. Hence Vct = 1.
We would like to measure 30A rms (i.e. 1V rms) at the maximum scale of the ADC. Hence Vct = 1.


We can estimate the required gain as follow:  
We can estimate the required gain as follow:  
Line 165: Line 176:
|Voltage
|Voltage
|None
|None
|130 kΩ
|'''130 kΩ'''
|2.83
|2.83
|None*
|None*
Line 173: Line 184:
|Voltage
|Voltage
|None
|None
|130 kΩ
|'''130 kΩ'''
|5.66
|5.66
|None*
|None*
Line 181: Line 192:
|Voltage
|Voltage
|None
|None
|130 kΩ
|'''130 kΩ'''
|8.49
|8.49
|None*
|None*
Line 189: Line 200:
|Voltage
|Voltage
|None
|None
|130 kΩ
|'''130 kΩ'''
|11.31
|11.31
|None*
|None*
Line 197: Line 208:
|Voltage
|Voltage
|None
|None
|130 kΩ
|'''130 kΩ'''
|14.14
|14.14
|None*
|None*
Line 205: Line 216:
|Voltage
|Voltage
|None
|None
|130 kΩ
|'''130 kΩ'''
|16.96
|16.96
|None*
|None*
Line 213: Line 224:
|Voltage
|Voltage
|None
|None
|130 kΩ
|'''130 kΩ'''
|28.28
|28.28
|None*
|None*
Line 220: Line 231:
|SCT-013-060
|SCT-013-060
|Voltage
|Voltage
|None*
|None
|130 kΩ
|'''130 kΩ'''
|33.94
|33.94
|None*
|None*
Line 234: Line 245:
|SCT-006
|SCT-006
|Current
|Current
|10 Ω
|'''10 Ω'''
|17 kΩ
|17 kΩ
|11.62
|11.62
Line 242: Line 253:
|SCT-013-000
|SCT-013-000
|Current
|Current
|10 Ω
|'''10 Ω'''
|40
|'''39 '''
|56.57
|56.12
|75 kΩ
|'''75 kΩ'''
|85.71
|85.71
|-
|-
|SCT-019
|SCT-019
|Current
|Current
|10 Ω
|'''10 Ω'''
|24 kΩ
|24 kΩ
|116.13
|116.13
Line 258: Line 269:
|}
|}


<small>* For all the None* calculated amplification is 1.17. Being close to 1 we do not consider it is worth installing a resistor.</small>
<small>* For all the None* calculated amplification is 1.17. Being close to 1 we do not consider it is worth installing a resistor.</small><br>
<small></small>
 
ICAL values are theoretical. You might need to adjust them with a calibration if you want to get more accurate values.
 
Resistor values in bold in the above table are provided with the kit. Their colour coding is shown below for reference.
 
{| class="wikitable" 
|+
|-
!Resistor Value
! Colour Code
|-
| 10Ω
| [[File:10ohm.png]]
|-
| 39kΩ
| [[File:39kohm.png]]
|-
| 75kΩ
| [[File:75kohm.png]]
|-
| 130kΩ
| [[File:130kohm.png]]
|-
|}


=Vref=
=Vref=
[[File:IMG_1846_small_02.png | 400px | right]]
[[File:IMG_1846_small_02.png | 400px | right]]
Vref is the center of the waveform and is set on the Amplifier.  
Vref is the center of the waveform and is set by default as half the supply voltage.  


Why? As most ADC scale are set between 0 and 5V (or other positive voltage) is makes it difficult to measure a waveform with a negative part. We will miss the negative part due to the limit at 0. To face this we can offset the signal higher at say 2.5V. Then when negative the waveform will be below 2.5V and above when positive.
Why? As most ADC scale are set between 0 and 5V (or other positive voltage) it is not possible to measure a waveform with a negative part. It would miss the negative part due to the limit at 0. To face this we can offset the signal higher at say 2.5V. Then when negative the waveform will be below 2.5V and above when positive.


By default Vref is connected to Vcc/2 (2.5V or 1.65V). This is done with the solder blob shown on this picture. The Vcc/2 is achieved using a voltage divider with 2x 10k resistors on the board.
By default Vref is connected to Vcc/2 (2.5V or 1.65V). This is done with the solder blob shown on this picture. The Vcc/2 is achieved using a voltage divider with 2x 10k resistors on the board.
Line 274: Line 310:
[[File:IMG_1846_small.png | 300px]]
[[File:IMG_1846_small.png | 300px]]
[[File:IMG_1849_small.png | 300px]]
[[File:IMG_1849_small.png | 300px]]
=Playground: View the waveform=
Using a simple sketch one can view the waveform easily using an application called [https://bitbucket.org/hyOzd/serialplot/src/default/ SerialPlot].
==SerialPlot==
Download SerialPlot from [https://github.com/hyOzd/serialplot here].
[[File:Serial_plot_001.png | 600px]]
Make sure ASCII is selected in the Data Format tab.
[[File:Serial_plot_002.png]]
==Sketch==
Upload the sketch below to the arduino.
<syntaxhighlight lang="c">
// CT CONDITIONER WAVEFORM DEMO
// VERSION 1.0
// LeChacal.com
//
// Description
// Read waveform from pin A0. Then send data over serial to be read by Serialplot application.
//
//
const int N = 512;  // Length of storage buffer
uint16_t BUFFER[N]; // Storage buffer - Array to store analog data
const int INTERVAL = 285; // Sampling interval approx 3.5kHz
const float ICAL = 30; // Using SCT-013-030 CT here
const float VCC = 5.0; // Vcc is 5V
const float VREF = 2.5; // Using the Vcc/2 reference here as setup by default on the conditioner.
void setup() {
 
  Serial.begin(9600); // Setup the serial port
  pinMode(A0, INPUT); // Setup pin A0 as input
}
void loop() {
  fill_buffer(A0);
  print_buffer();
}
// Function to read analog data and store into array BUFFER.
void fill_buffer( byte _PIN)
{
  unsigned long timer1 = 0;
  unsigned int i = 0;
  while (i < N) {
    if ((micros() - timer1) > INTERVAL) {
      timer1 = micros();
      BUFFER[i] = analogRead(_PIN);
      i++;
    }
  }
}
// Function to print the buffer
void print_buffer()
{
  unsigned int i;
  for (i = 0; i < N; i++) {
    //Serial.println(BUFFER[i]);
    Serial.println(((float)BUFFER[i]*VCC/1024-VREF)*ICAL);
  }
}
</syntaxhighlight>

Latest revision as of 12:44, 18 March 2023

The CT Conditioner allows to connect a CT sensor to an Arduino board.

  • Supports both current and voltage output CT.
  • 3.5mm Jack connector CT port.
  • Amplification easily setup by mean of a resistor.
  • Zero offset can be set to Vcc/2 onboard. Or use an external reference.
  • Uses instrument amplifier AD623 for accurate result.
  • Provision of a burden resistor mounting for current output CTs.
  • Minimum setup uses 3 wires. +5V Gnd and analog out.
  • Dimensions: 24x24mm

Link to the shop

Usage

Connect the CT sensor to the jack connector. Then connect 3 wires to the Arduino. The 3 wires to connect are

CT conditioner -> Arduino
  Vcc         -> 5V
  Gnd         -> Gnd
  Out         -> A0

Note Vcc can also be connected to 3.3V.

Compatible CT

Any CT with a 3.5mm jack connector will be supported.

Voltage CT
No burden resistor should be fitted using a Voltage CT. These are commonly
SCT-013-005
SCT-013-010
SCT-013-015
SCT-013-020
SCT-013-025
SCT-013-030
SCT-013-050
SCT-013-060

Current CT
A burden resistor must be used when using current output CT. These are commonly
SCT-013-000
SCT-006
SCT-019

Sketch Example

A simple arduino sketch can be used to read the value every seconds. See the example below.

You must download and install the RPICTlib to compile the sketch.

http://lechacal.com/RPICT/RPICTlib/RPICTlib_v1.4.1.zip

// CT Conditioner Demo
// Version 1.2
// lechacal.com
//
// Required Libraries
// RPICTlib 1.4.1
// http://lechacal.com/RPICT/RPICTlib/RPICTlib_v1.4.1.zip
//

#include "RPICTlib.h"         // Include the library

int sInterval = 250;          // 250usec is 4kHz sampling interval (internal sampling)

// We use 1000 samples to measure the rms signal.
// Ideal value depends on frequency
// for example for 50Hz using 10 full cycles
// N = 1000000 * 10 / 50 / 200
int NUMBER_OF_SAMPLES = 1000;

SignalNode ct1;               // CT computation node definition

void setup()
{
  Serial.begin(38400);       // Open the serial port

  adc_definition(10, 5000);  // Tell the library we are on 10 bits and 5V voltage reference.
  ct1.begin(A0, 30.00);      // Analog port A0, 30 scaling factor for SCT-013-030
}

void loop()
{
  ct1.calcRMS(NUMBER_OF_SAMPLES, sInterval); // Measure and compute Irms
  if (ct1.err) {
    Serial.println("err"); // Error. Current is too high and goes over-limit. (or maybe change sInterval to 400 (unlikely)).
  } else {
    Serial.print(ct1.RMS); // Print the result
    Serial.println(" A"); // Print the unit (Ampere)
  }

  delay(1000);                                // wait 1 second
}

Default Setup

By default the CT conditioner comes without resistors fitted for both Burden and Gain.

This means this is ready for a voltage output CT and the Gain is 1.

Resistor

Fitting

There are 2 types of resistor the user can fit on the CT conditioner. These are not mandatory but will help optimising the measurement.

Both surface mount and though hole resistor are supported. Surface mount resistor case are 0805 size.

Burden Resistor

When a current output CT sensor is used a resistor must be soldered to the CT conditioner. It is usually recommended to use a low value resistor. Also the datasheet of the CT should have some indication on the maximum resistor to use. Burden resistor is also called sampling resistor in some documentations.

Note that you do not need a burden resistor if the CT is voltage output.

Amplification

A second resistor can be fitted on the CT conditioner to adjust the amplification level. Amplification can be required if levels are found too low. For low currents this can increase resolution.

From a desired gain the resistor can be calculated as follow

G is the Amplification Gain.
Rg is the resistor value in ohm.

The formulae below should be used to estimate the Gain.

G = Vadc/Vct/2√2

Vadc is the full scale voltage value of the ADC. Usually 5V or 3.3V.
Vct is the output voltage of the current transformer at maximum desired value (rms).

Example

Here is an example of Gain calculation.

Let's take the SCT-013-030. This outputs 1V at 30A (both rms and peak). Hence ICAL = 30.
Using an Arduino UNO the ADC has 5V reference by default. Hence Vadc = 5.
We would like to measure 30A rms (i.e. 1V rms) at the maximum scale of the ADC. Hence Vct = 1.

We can estimate the required gain as follow:

G = 5/1/2√2 = 1.77.

Then the required resistor for this Gain is:

Rg = 100000/(1.77-1) = 130Kohm.

We can now calculate the theoretical scaling coefficient to enter in the sketch:

newICAL = ICAL/G = 30/1.77 = 16.95

We will then fit a 130kOhm resistor and enter in the sketch

ct1.init(A0, 16.95);

Recommended Values

CT Output Type Rburden Rgain (for 5V) ICAL (for 5V) Rgain (for 3.3V) ICAL (for 3.3V)
SCT-013-005 Voltage None 130 kΩ 2.83 None* 5.0
SCT-013-010 Voltage None 130 kΩ 5.66 None* 10.0
SCT-013-015 Voltage None 130 kΩ 8.49 None* 15.0
SCT-013-020 Voltage None 130 kΩ 11.31 None* 20.0
SCT-013-025 Voltage None 130 kΩ 14.14 None* 25.0
SCT-013-030 Voltage None 130 kΩ 16.96 None* 30.0
SCT-013-050 Voltage None 130 kΩ 28.28 None* 50.0
SCT-013-060 Voltage None 130 kΩ 33.94 None* 60.0
SCT-006 Current 10 Ω 17 kΩ 11.62 28 kΩ 17.5
SCT-013-000 Current 10 Ω 39 kΩ 56.12 75 kΩ 85.71
SCT-019 Current 10 Ω 24 kΩ 116.13 40 kΩ 171.43

* For all the None* calculated amplification is 1.17. Being close to 1 we do not consider it is worth installing a resistor.

ICAL values are theoretical. You might need to adjust them with a calibration if you want to get more accurate values.

Resistor values in bold in the above table are provided with the kit. Their colour coding is shown below for reference.

Resistor Value Colour Code
10Ω
39kΩ
75kΩ
130kΩ

Vref

Vref is the center of the waveform and is set by default as half the supply voltage.

Why? As most ADC scale are set between 0 and 5V (or other positive voltage) it is not possible to measure a waveform with a negative part. It would miss the negative part due to the limit at 0. To face this we can offset the signal higher at say 2.5V. Then when negative the waveform will be below 2.5V and above when positive.

By default Vref is connected to Vcc/2 (2.5V or 1.65V). This is done with the solder blob shown on this picture. The Vcc/2 is achieved using a voltage divider with 2x 10k resistors on the board.

If you prefer using an external Vref then disconnect Vref from Vcc/2 by removing the blob with a soldering iron. Then Vref can be set from an external source on one of the pin of the CT conditioner.


Playground: View the waveform

Using a simple sketch one can view the waveform easily using an application called SerialPlot.


SerialPlot

Download SerialPlot from here.

Make sure ASCII is selected in the Data Format tab.

Sketch

Upload the sketch below to the arduino.

 // CT CONDITIONER WAVEFORM DEMO
 // VERSION 1.0
 // LeChacal.com
 //
 // Description
 // Read waveform from pin A0. Then send data over serial to be read by Serialplot application.
 //
 //
 
 const int N = 512;  // Length of storage buffer
 uint16_t BUFFER[N]; // Storage buffer - Array to store analog data
 
 const int INTERVAL = 285; // Sampling interval approx 3.5kHz
 
 const float ICAL = 30; // Using SCT-013-030 CT here
 const float VCC = 5.0; // Vcc is 5V
 const float VREF = 2.5; // Using the Vcc/2 reference here as setup by default on the conditioner.
 
 void setup() {
  
  Serial.begin(9600); // Setup the serial port
  pinMode(A0, INPUT); // Setup pin A0 as input
 }
 
 void loop() {
 
  fill_buffer(A0);
  print_buffer();
 
 }
 
 // Function to read analog data and store into array BUFFER.
 void fill_buffer( byte _PIN)
 {
  unsigned long timer1 = 0;
  unsigned int i = 0;
 
  while (i < N) {
 
    if ((micros() - timer1) > INTERVAL) {
      timer1 = micros();
      BUFFER[i] = analogRead(_PIN);
      i++;
    }
  }
 }
 
 // Function to print the buffer
 void print_buffer()
 {
  unsigned int i;
 
  for (i = 0; i < N; i++) {
    //Serial.println(BUFFER[i]);
    Serial.println(((float)BUFFER[i]*VCC/1024-VREF)*ICAL);
 
  }
 }