Measure high DC current with an Arduino and the LEM HO 120-P Transducer

What techniques are available to measure high current with an Arduino microcontroller?

There are several different ways to measure current using a microcontroller such as the Arduino Nano Every. These methods generally fall into two categories:

  • shared ground connection: With these methods the microcontroller must be at the same ground potential as the system being measured. The classic example is to pass the current through a low resistance shunt resistor. With the microcontroller’s ground anchored to the ground return of the shunt resistor, an Analog to Digital Converter (ADC) pin may be used to measure the voltage drop across the resistor. There is always a compromise with this method to keep shunt resistor energy loss low, yet the microcontroller demands a high voltage drop. A compromise is to add an op amp to boost the voltage.

  • galvanically isolated: With this method the Arduino is free to use a different ground from the system under test. In some respects, this is similar to optical isolation as the microcontroller is no longer directly part of the measured circuit. Galvanic isolation allows the grounds to be separated by a large difference such that thousand-volt transients generally cause no harm. The resulting circuit is simple and easy to design. It does not suffer the problems of the shunt resistor.

This engineering brief is focused on Life Energy Motion (LEM) manufactured galvanically isolated current transducers. The LEM HO 120-P device as pictured in Figure 1 features Hall effect sensing element with differential outputs.

On a related note, please review this article that describes how to configure the Arduino to use an internal voltage reference. This technique used to improve the Arduino’s ADC is assumed for this article. Also, please review this article concerning the measurement of small currents by passing multiple turns through the aperture of a current sensor. We will use this technique to bench test the LEM transducer simulation a 60 A current by passing a 3 A current through a wire that physically passes through the transducer’s aperture 20 times. This simulated current is easier to manage on a benchtop that the full current and requisite busbar that normal passes through the LEM transducer.

Tech Tip: The LEM and related sensors offer advanced capabilities that extent beyond this introductory article. In addition to DC application, the LEM transducers are responsive AC device with a bandwidth that extends on the 100 kHz range. Consequently, they may be used to measure the current of high frequency and high-power devices such as motor drives or alternative energy applications. Perhaps in a future article we can explore how to use the sensor to measure RMS current.

Figure 1: The Arduino Nano Every is coupled to the LEM USA HO 120-P open loop current sensor. The sensor is wrapped with 20 turns of wire to simulate a 60A current while using a benchtop DC power supply.

How is the current sensor connected to the Arduino?

The physical connections for the LEM sensor are very simple and readily seen in Image 1. For this minimal setup, four wires are used. This includes power and ground as well as the transducer’s voltage reference output and output signal where the output voltage is proportional to current. These are sent to Arduino analog A7 and A6.

What is the relationship between the sensor output and the voltage reference?

As seen in Figure 1, the Arduino’s ADC reads the transducer’s output signal and the voltage reference. For this LEM sensor, the actual current is encoded as the difference between the two voltages – the current is the delta (V_{out} – V_{ref}). For the HO 120-P sensor, a delta of 2 VDC equates to 300 A while a delta of -2 VDC equates to -300 A.

How is the transducer output converted into a human readable current?

A simple Arduino program to measure and display the current is shown below. There are a few things to note about this program:

  • An internal 4.3 VDC reference is used to improve the performance of the Arduino ADC. Please see the previously mentioned article as well as Arduino’s analogReference( ) function. Note that 4.3 is the highest internal voltage reference for the Arduino Nano Every. A low microcontroller voltage reference would have required the use of voltage divider resistors to accommodate the LEM transducer’s full scale voltage output.

  • A floating point mapping operation converts the two sensor input into human readable voltages. This is advantageous from a troubleshooting perspective.

  • The delta voltage is also calculated in human readable form. This calculated value may be compared to a physical voltmeter reading the voltage difference between the signal and the reference pin.

  • The multiplication by 7.5 accounts for the full scale 300 A reading as well as the fact that the bench test includes 20 wraps of wire.

#define SIGNAL_PIN A7
#define REF_PIN A6

float fmap(float x, float in_min, float in_max, float out_min, float out_max) {
    return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}

void setup() {
    pinMode(SIGNAL_PIN, INPUT);
    pinMode(REF_PIN, INPUT);
    analogReference(INTERNAL4V3);
    Serial.begin(9600);
}

void loop() {
    int rawSignal = analogRead(SIGNAL_PIN);
    int rawRef = analogRead(REF_PIN);
    float scaledSignal = fmap(rawSignal, 0.0, 1023.0, 0.0, 4.3);
    float scaledRef = fmap(rawRef, 0.0, 1023.0, 0.0, 4.3);
    float delta = scaledSignal - scaledRef;
    float current = delta * 7.5;   // Where the maximum current of 300 A yields a delta of 2V.
                                   // This also accounts for 20 turns of wire on the current sensor
                                   // delta * (1/20) * (300 / 2) = delta * 7.5

    Serial.println(current);
    delay(1000);
}

Results of the bench test

The results of the bench test are shown in Figure 2. The results show the transducer’s response as the BK Precision 1550 power supply (not shown) ramps from 0 to 3A. Observations:

  • There is some measurement noise. For this DC application, it may be desirable to add a small amount of digital filtering.

  • The graph shows a small remanence or magnetic offset. In relative terms this is a fraction of the full current rating for the device. This remanence is most apparent at the beginning of the chart. Here we can see that the displayed current is not zero even though the power supply is turned off. Please see the tech tip for more information about the inherent remanence associated with an open loop Hall sensor such as the HO 120-P. The amount of offset depends on the previous magnetization of the code. Note that an impulse of current in the opposite direction reduces the offset.

  • Although not shown, the sensor and associated program will also measure current flowing in the opposite direction. This would make the sensor a good candidate for a battery charge circuit allowing both charge and discharge current to be measured.

  • As always, the performance could be improved with more attention to the ADC. This includes an external voltage reference as well as a 12 or 14-bit ADC. A calibration against a known standard would also be welcome.

Figure 2: Results of the Arduino current measurement responding to a ramp from 0 to 3 A. With 20 wraps through the transducer aperture, this simulates a 60 A current. The small remanence is visible in the first 15 samples where zero current is displayed as a slight positive offset.

Why does my Hall sensor transducer display an offset when the current is zero?

Sensors such as the LEM are designed to measure both DC and AC signals. This can cause some confusion when interpreting the datasheet specification. The challenge is to differentiate between the AC and DC (max) specification. For example, the HO 120-P is designed to measure an AC current with an RMS current of 120 A. From basic electronics we know that a 120 A RMS signal has a peak value of 170 A. Allowing for a generous safety margin, the transducer is rated for +/- 300 A.

Note that we generally want to avoid current extremes due to remanence (magnetic offset). This is an undesirable property of physics. At high currents magnetic hysteresis is a problem as the core approaches saturation and tends to remember the past magnetic field. This manifests itself as a semi-permanent offset in the reading. Reversing the current tends to eliminate the offset or will add an offset with the opposite polarity. For sensitive applications it may be desirable to use an advanced closed loop sensor. Either way, it is desirable to limit the current. Note that a short circuit with resulting high transient current may require a manual or automated procedure to reduce the remanence by removing the residual magnet flux. In extreme situation, it may be useful to wind a degaussing coil into the aperture of the transducer. A dampened sinusoid would remove the magnetic hysteresis.

For more information, please consider this LEM white paper.

Conclusion

Isolated transducers such as the HO 120-P featured in this article are very simple to integrate into your microcontroller projects. With this class of sensor, we can easily measure currents up to several hundred Amperes. As demonstrated in this article we must take some precautions with the sensor to avoid saturation especially for DC circuits as there is no self-resetting of the remanence (magnetic hysteresis resulting in a measurement offset) such as when the sensor is used for AC.

Please leave your comments and suggestions below. Descriptions and pictures of your success stories are especially welcomed.

Best Wishes,

APDahlen

About the Author

Aaron Dahlen, LCDR USCG (Ret.), serves as an application engineer at DigiKey. He has a unique electronics and automation foundation built over a 27-year military career as a technician and engineer which was further enhanced by 12 years of teaching (interwoven). With an MSEE degree from Minnesota State University, Mankato, Dahlen has taught in an ABET accredited EE program, served as the program coordinator for an EET program, and taught component-level repair to military electronics technicians. Dahlen has returned to his Northern Minnesota home and thoroughly enjoys researching and writing articles such as this. LinkedIn | Aaron Dahlen - Application Engineer - DigiKey