2

I need help with wiring this current sensor so that I can read the output voltage as an analogue input. - http://www.tamuracorp.com/clientuploads/pdfs/engineeringdocs/L03SXXXD15.pdf

This is how I have it wired right now - 1 - +15v 2 - 15v ground 3 - output to arduino 4 - arduino ground

This seemed simple but reviewing the wiring diagram again I have a hunch that this is not at all how I should be wiring this up.

Thanks

2
  • Are you planning to measure AC current?
    – Nick Gammon
    Commented Aug 28, 2015 at 21:09
  • Have you looked at the "Electrical connection diagram" in the datasheet?
    – Majenko
    Commented Aug 28, 2015 at 21:12

2 Answers 2

2

To read the sensor properly you have to convert the output signal into something the Arduino can work with.

At full current the output will swing between +4V and -4V, and over-current will cause that to be nearer +6V to -6V. The frequency of that swing will be the frequency of the input voltage - so typically 50 or 60Hz.

The Arduino can only read between 0V and 5V, so you will need to convert the provided voltage to fit.

You need to first reduce the voltage by about a half, so it fits into +/- 2V, and then you need to add a 2.5V offset voltage to it so that it swings between 0.5V and 4.5V.

Once you have done that you then need to sample the incoming signal fast enough that you can get the peak values, from which you can then calculate the incoming current.

Often for this kind of thing you would use a simple voltage divider with an offset voltage applied to it, but the output impedance of the sensor (set by RL) is 10KΩ which is around the upper limit for the input impedance of the Arduino's input. A voltage divider that wouldn't adversely affect the output accuracy would be using resistors in the order of 1MΩ, which would be way too high for the ADC on the Arduino to be able to sample accurately.

So you need to buffer the signal with a high impedance buffer. That can be achieved most simply with an inverting op-amp circuit with a gain of 0.5. You want a rail-to-rail op-amp which is capable of running from a single supply voltage.

enter image description here

In this circuit the output current is converted into a voltage by the 10KΩ resistor RL. It is then AC coupled to the rest of the circuit through C1 which has to be high enough in value as to not reject the frequency you are working with (it acts like a high-pass filter). R1 and R2 set the gain of 50/100, or 1/2, so the voltage is halved. R3 and R4 form a voltage divider to provide a VCC/2 offset voltage into the non-inverting input of the op-amp. This is known as the virtual ground voltage and is the voltage the output of the op-amp will swing around.

The result is the input voltage inverted, halved and off-set by 2.5V, which can be read directly by the Arduino's ADC.

Note the magic word inverted there, though. The values you read will be upside down. Anything read above 512 from the ADC will equate to a negative voltage. Anything read below 512 will be a positive voltage. So it is necessary to first "invert" the reading, which can simply be done by subtracting it from 1023.

Then it's just a matter of sampling often enough and recording the peak (and negative peak) values over a short period. The faster you can sample the better your results will be.

From those peak values you can then do all sorts of calculations and things. You can use them "as is" to directly give you the "peak-to-peak" current, or calculate the RMS voltage to then give you the RMS current.

3
  • Why are you AC coupling?
    – Nick Gammon
    Commented Aug 29, 2015 at 2:40
  • I withdraw the question. I made up your circuit, and without the AC coupling it didn't work properly (it was biased too high and the positive output was clipped). I like your solution, Majenko, it gives a nice clean output signal without needing diodes.
    – Nick Gammon
    Commented Aug 29, 2015 at 6:29
  • 1
    You need the capacitor for the AC coupling to separate out the two ground levels - the 0V for the sensor and the 2.5V offset for the op-amp. As you saw, if you don't have it the inverting input is pulled too low by the sensor's ground point and the output has to raise itself much higher to try and compensate (the output, through the feedback, tries to keep the inverting input at the same level as the non-inverting input), which results in the output being offset and clipped.
    – Majenko
    Commented Aug 29, 2015 at 9:34
2

Looking at the datasheet the output is +/- 4 volts, so this is not suitable to connect directly to the Arduino, because the input pin will not tolerate -4 V.

I am no Hall Effect sensor expert, but a quick search on Google showed another potential problem: If you are planning to measure AC current, and you try to sample the output on the Arduino, the reading will average out to zero (half of the time positive, half of the time negative).

What may help - and this is a bit of a guess - is to put a diode in series with the sensor output, oriented so that you only get the positive pulses. That is, the anode connected to the Hall Effect sensor, and the cathode (with the black line) on the Arduino side.

Then you probably want to smooth the voltage so you can read the average voltage with the ADC converter, rather than what it is at a particular millisecond. A low-pass filter will take an average, which you can then read with analogRead.

Something like this:

Hall effect sensor wiring


I made up that circuit driven by a signal generator (8 V peak to peak, i.e. +/- 4 V) and found a 400 mV drop over the diode using a 1N4148 normal diode, and a 160 mV drop using a BAT85 Schottky diode.

With a 3 V peak-to-peak signal the voltage drop with the Schottky diode reduced to 120 mV, so it wasn't totally linear.


As Majenko pointed out, there is a voltage drop over the diode. You can make a Precision Rectifier out of an op-amp and a few other parts, like this:

Precision Rectifier

This avoids the problem of the voltage drop (put this in place of the diode in the earlier circuit).

If the signal is AC then the smoothing circuit I described above will only give you an average voltage, not a peak one. You may want to sample rapidly in order to find the peak values.

2
  • 1
    Don't forget you would have to compensate for the diode voltage drop.
    – Majenko
    Commented Aug 28, 2015 at 22:14
  • Good point. You could get a diode with a smallish voltage drop, like a Schottky.
    – Nick Gammon
    Commented Aug 28, 2015 at 22:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.