Measuring a 0-1V 5A analog input

13 Jan 2012

I'm looking to measure the power output from a 1600amp CT. according to the spec, the secondary output of the CT, when at full 1600A load, is 5A. Now I can convert that output current to a voltage that the MBED can read through analogin by adding an appropriate burden resistor to the CT output with, say, a 0.5ohm resistor.

My question is, is it safe to connect that input to the MBED's analogin. I'm still learning about this stuff and it sounds to me like 5A would be far too much current!

Thanks....

13 Jan 2012

Yep that should be safe.

The voltage drop across the resistor will be proportional to the current passing through it (V=IR - Ohms law). You will need to make sure that current only passes through the resistor in 1 direction (no AC), and tie the 'ground' leg of the resistor to the GND pin on the mbed.

At 5A the power dissipated by a 0.5 ohm resistor will be (I^2*R) 12.5 Watts - which is quite a bit (it will get hot) and the voltage drop should be (I*R) 2.5 Volts. Basically make sure you use a power resistor not the standard little ones (which are rated at 0.25W) because they will melt!

Martin

13 Jan 2012

So I'm not going to have 5A flowing in to the MBED?

13 Jan 2012

No, the amount of current that flows through a device is dependant on its resistance (impedance). The analogue input on the mbed will have >100 kOhm input impedance so very little current will flow through it. The majority of the current will flow through the resistor.

What you really have here is the resistor and mbed analogue input in parallel.

13 Jan 2012

Ah, that makes sense. Thanks martin!

13 Jan 2012

what on earth are you using >350KW ??

Ceri

13 Jan 2012

a CT is a current transformer: a device to reduce and isolate (!) current for measurement. Normally an analog 5 Amp AC current meter is to be attached.

To measure AC current with a mbed takes more than a simple resistor...

13 Jan 2012

ceri clatworthy wrote:

what on earth are you using >350KW ??

Ceri

A couple of 2.3MVA generators and associated electrical distribution panels.

13 Jan 2012

Gert van der Knokke wrote:

a CT is a current transformer: a device to reduce and isolate (!) current for measurement. Normally an analog 5 Amp AC current meter is to be attached.

To measure AC current with a mbed takes more than a simple resistor...

Actually it can be done with little more than a resistor. I am already using a 100amp CT in exactly this way. The secondary output from my 100amp CT is 0.5amps - in order to measure that with the MBED this must be turned in to a voltage. This is done by placing a burden, or sampling resistor across the secondary. The impedance of the resistor governs the output voltage so in order to keep this in the range of the MBED's analog input we need to ensure that it be no more than 3.3v. I use a 25ohm burden resistor to give me a 1.3v range (it's an AC output so we then use a voltage divider so that the MBED is happy).

13 Jan 2012

Leo - That 25 ohm burden resistor should be 2.5 ohm I suspect (to deliver approx 1.3 volt @ 0.5 amp).

I have also designed a system similar to this. Note that because the signal is AC, the input needs to be biased to half of 3.3 volt, or around 1.65 volt. I used the spare analog out to provide this by writing the value 0.5 to the analog output, this sets it to 1.65 volt. This is a waste of resource if you have a better use for analog out, a pair of equal resistors (1K, 10K, any value in that sort of region, not critical) in series connected between 3.3v and Gnd would also work, the junction being at 1.65v. A capacitor of 1uF, 10uF 100uF or any handy value across the lower resistor helps minimise noise pickup. The two wires from the CT with burden resistor - 1 goes to this 1.65 volt point, the other to an analog input pin to be measured. WARNING - MAKE SURE THE BURDEN RESISTOR CAN NOT EASILY GET DISCONNECTED FROM THE CURRENT TRANSFORMER AS DANGEROUS VOLTAGES CAN RESULT!!.

The task of measuring voltage (current) then needs some thought. Reading one sample will give an instantaneous reading of the sine wave signal at that instant. Not much use. One solution is to take many readings spread over a time of 20 milli secsonds - the period of a 50Hz mains voltage. Writing a short function to find the max and min of these readings should then give a fair estimate of the peak to peak value of voltage measured. Multiplying by a suitable fiddle-factor should then give a reasonably accurate measurement of RMS current.

I performed the measurement another way altogether, using many samples as input to a Fast Fourier Transform, but that's a story for another day.

13 Jan 2012

Jon Freeman wrote:

Leo - That 25 ohm burden resistor should be 2.5 ohm I suspect (to deliver approx 1.3 volt @ 0.5 amp).

Indeed, well spotted Jon. I like your method of using the analog out at 0.5, neat way to voltage divide but as you say, not ideal if you need all your pins!

At the moment I am doing the RMS calc by grabbing 3000 samples from the analog - how do you spread them over 20 milliseconds though?

Would love to hear your FFT method though!

14 Jan 2012
14 Jan 2012

Leo My scheme for spreading samples evenly through time is to setup a 'Ticker'. This is used to generate interrupts to take readings at a known rate, and keeps this sampling task out of the way of whatever other processing you are doing. For my purposes I chose to take 32 samples per 20ms cycle indicating a period between interrupts of 625 micro seconds. Ticker setup thus:-

Ticker samp_int_gen;  // Ticker named 'samp_int_gen' declared

Then somewhere near the top of code in main()

    samp_int_gen.attach_us(&samp_int_handler, 625);// Setup interrupts
                      //  to occur every 625 micro second, rate 1600Hz

And to service the timer interrupts, an example interrupt handler function might look something like:-

void samp_int_handler ()  {   // services Ticker 'samp_int_gen' interrupts
                    // Read analogue input here
    float I = Current.read();
    if  (I_neg_pk > I)    // I_neg_pk and I_pos_pk are global floats
        I_neg_pk = I;     // declared above somewhere
    if  (I_pos_pk < I)
        I_pos_pk = I;
    global_tickcnt++;       // Keep interrupt handlers SHORT AND QUICK !!
}

My code is a little more complex involving reading samples into circular buffers, however this shows one simple method. Integer global_tickcnt may be useful to your code to, e.g. know how many samples have been read since ...

Some consideration of sampling rate might be worthwhile. My chosen rate was influenced by consideration of the implementation of the fft. It could be that my sampling rate misses the peaks on every sample if it happens to take readings equally spaced either side of the peak - no problem for fft, but not good for accurate peak reading!

I was using the fft as I was interested to measure the magnitude and phase of the 50Hz fundamental and the first few harmonics. I may well publish my code here some time soon, it needs a bit of a tidy first though!!

14 Jan 2012

At these kind of powers you also need to keep an eye on transients too. 5 Amp could be the max. your transformer can deliver constantly but the transient currents (and thus the voltage across the load resistor) can be much much higher and easily destroy the input of the mbed.

14 Jan 2012

A good point Gert, the inputs are easily damaged.

The current transformer I use also delivers up to 5 Amps, this is the input interface circuit I ended up with. My choice of burden resistor is 0.45 Ohm ( 4 times 1.8 ohm parallel) to reduce power dissipation. The amplifier stage has some gain to compensate, and the amplifier is not capable of outputting harmful voltages. R2 is sufficient to prevent damage to the amplifier during overload conditions.

/media/uploads/JonFreeman/current_transformer_mbed_interface.png

15 Jan 2012

Leo,

I am not certain if you and Jon are using the '5 Amp' rating in the same way. Usually it is an RMS rating, with the corresponding Peak-to-Peak value being 2.8x larger. So, I would expect you to need a load resister of 0.2 Ohms. That could be 5 resistors in parallel, each of 1 Ohm value with a dissipation rating in the range of 2 to 5 Watts (per resistor). That, in turn, would produce 1.0 volts RMS, or 2.8 volts P-P. If a single load resistor failed in the 'open' condition, it would create 3.5 volts P-P (which would saturate the mbed ADC pin, but not over-load it). If you need to measure larger (transient) currents (from start-up loads, lightning strikes, etc.) the load resistor must be correspondingly smaller. It is also true that you should plan on 'snubbing' out-of-range transient signals at the ADC input with a buffer circuit (such as Jon's) or with a limiting resistor and catch diodes. Such snubbing was also discussed earlier in a thread on using a mbed in an automotive application.

Jon's circuit has a 0.45 Ohm load resistor a 10x gain, so the current levels he can accurately measure might be just a fraction of the 5 Amp (RMS?) rating.

If you measure over a 100 mS interval the RMS calculation will avoid 'partial cycle' effects from both 50 Hz and 60 Hz sources. That advantage fades as the line frequency strays further from either nominal. Measuring at a 1280 sample-per-second rate gives 128 samples each 100 mS, which will allow the RMS calculation to accurately incorporate (out to at least) the 9th harmonic of either 50 Hz or 60 Hz.

The easy and straight-forward way to calculate RMS is to first calculate the average of all the samples in an interval. Next, sum the squares of the differences between each sample and that average. Finally, divide that sum by the number of samples in the interval and take the square-root of the quotient.

The effort to get RMS via a FFT is probably only needed when you also want include or reject certain harmonics from the resulting RMS value. For 'true' RMS the straight-forward method includes all harmonics (which is what is needed).

Note that it is possible to re-arrange the straight-forward calculation so that most of the work can be spread over all the samples, instead of all-at-once at the end of the interval but before the next sample.

24 Jan 2012

Jon,

Thanks for the tips so far (I sent you a PM too).

I now have a working prototype with two CT's attached. I'm pretty happy with the calibration and the sensitivity, I'm reading to within a tenth of an amp at 40amps when compared to an expensive calibrated Fluke meter.

One thing I did learn, as obvious as it may now seem, is that each CT needs it's own voltage divider circuit otherwise you get the reading from one CT affecting another. That's ok but a bit annoying when you want 6 CT's on one MBED and have to make 6 VD circuits. Is there an alternative?

The other issue I have yet to resolve is that I periodically see a spike in the readings. I'm reading each sensor taking 3000 samples and using an RMS calculation. I do the calculation once every 10 seconds. This is fine most of the time but even when there is no load on the CT I'll occasionally see a spike in one of the readings. For example it will read 0 for a few minutes and then will read 0.5amps for one reading and then settle back to 0. It does this on seemingly random intervals and never exceeds 0.8amps in magnitude. I can probably live with this as the CT's I am currently testing with are 40amp and during normal duty would be reading loads of between 20 and 30 amps all the time. When looking at a graph of hourly averages those odd few spikes are of no real consequence but it would be good avoid them.

Any thoughts or suggestions much appreciated!

24 Jan 2012

The best way to get rid of random glitches is to use a MEDIAN filter, Where you take 3 or 5 samples, in a row, sort them and take the middle value, Although this does require 3 or 5 times tour sample rate.

It is the best filter I have come across.

If you do have an oscilloscope, then have you looked as the waveform ?

If that is noise, then you should think about a low pass, or even a band pass filter.

The low pass can be made from a single resistor, and a single capacitor.

Although a 'T' configuration is better, possibly with a buffer amp. After it. , Additionaly a good spattering of de-coupling Capacitors close to sensitive parts will have a big effect.

Note: 1,10,100 nano together will be better than a single capacitor !

Hope this helps

Ceri

24 Jan 2012

Ceri,

Thanks for that, I'll have a look at a MEDIAN cut. I do have a few capacitors there but I'll also try a mixture of values! :)

Leo

25 Jan 2012

It might be useful to have a current sense chip doing also isolation, like the ACS712. It converts the current into a directly usable voltage, and isolates the mbed nicely from the circuit you want to measure. That way, the chance for frying the mbed is way lower then when you connect it directly.

25 Jan 2012

Hendrik Lipka wrote:

It might be useful to have a current sense chip doing also isolation, like the ACS712. It converts the current into a directly usable voltage, and isolates the mbed nicely from the circuit you want to measure. That way, the chance for frying the mbed is way lower then when you connect it directly.

The trouble with the ACS700 series is that they are invasive. This introduces several issues, firstly that the power has to be interrupted in order to connect the chip. Also if the chip fails they go open circuit and you've lost your power. They get VERY hot when close to half load and finally they dont go to the 400 and 1600amp at 11kV ranges that I personally will end up with.

CT's are easier and generally safer to work with, they are non-invasive and therefore isolated from load. The only headache I have is in respect of the noise they pick up!

25 Jan 2012

Leo Dee wrote:

The trouble with the ACS700 series is that they are invasive. This introduces several issues, firstly that the power has to be interrupted in order to connect the chip.

But we were talking about adding a sense resistor in the first place, didn't we? So I was just proposing replacing this resistor with an ACS, not measuring 1600A with it...

26 Jan 2012

Martin Smith wrote:

The analogue input on the mbed will have >100 kOhm input impedance

@Martin Where do you have this information from?

26 Jan 2012

Rene Greiner wrote:

@Martin Where do you have this information from?

Good question. I was sure that I had read it on the forum but I can't find where. So I had a look at the datasheet here and figure 27 would suggest that it is actually more like 5k but varies with temperature.

Much lower that I though - sorry guys

30 Jan 2012

Leo,

Sorry for delayed response - have seen your email and will respond...

You should not need to provide multiple voltage dividers, what you need is one voltage reference with a low impedance. You could use an op-amp in a circuit similar to the above - omit L1, R1 and R2, then R3 could be as shown or indeed any value down to 0 ohms. This leaves one voltage divider with the op-amp providing a unity gain buffer with negligible output impedance, although may be good to insert a maybe 100 ohm resistor between op-amp output and each of your input circuits to discourage instability due to any excessive capacitance.

I do not see spikes on the inputs, not unexpected spikes anyway, but then I'm using the Fast Fourier Transform as a very effective filter. I have no reason to doubt the readings taken by the inbuilt mbed A-D. It could be that your input circuit is picking up extraneous noise, an oscilloscope would help here. Could also be the spikes you see are real, perhaps a fridge or other reactive load switching on and off.

I will release my FFT code after tidying up.

Jon

10 Feb 2012

Probably way late in the game for this, but have you considered using a hall effect currrent sensor for this?

10 Feb 2012

Dan Weatherill wrote:

Probably way late in the game for this, but have you considered using a hall effect currrent sensor for this?

I have and generally Hall Effect sensors are good for fairly low current applications but as soon as you get in to the 10's of amps range then heat starts to become a real issue. Also the invasive nature of hall sensors means that they intorduce a point of failure.

Depends on the application.

10 Feb 2012

i found 1530851 in Farnell +/-400A

10 Feb 2012

ceri clatworthy wrote:

i found 1530851 in Farnell +/-400A

Cool. A non-invasive Hall-effect.

10 Apr 2012

Hi everybody I have to create a circuit capable of measuring 0-5 ampereA AC currents and convert these to a (RMS?) linear 0-3.3V DC voltage with a mbed..I don't how to make the link between the mbed and the circuit. I will be very happy to get some answers thank to you.