Adjust circuit for analog current sensor

I've been running a current sensor on a proto board for 4 months and it has been running great. I now want to convert it to a pcb, but I am not sure if I am missing key components on the circuit.

I am pretty sure I should have a capacitor on here somewhere.

Here is the datasheet.

I've attached the schematic that I've been using. I remember reading that there should be a current limiting resistor before the analog pin, but I cannot find the source for this now.

Any suggestions or corrections would help. Thanks!

See:
http://openenergymonitor.org/emon/buildingblocks/ct-sensors-interface

@Archibald Thanks! I just found that after posting.

The only problem is they don't give a capacitor size. Do you know what it should be? At the bottom of the page they talk about capacitor size in ohms, which is strange bc that's the only time they talk about the capacitor.

pekasus:
@Archibald Thanks! I just found that after posting.

The only problem is they don't give a capacitor size. Do you know what it should be? At the bottom of the page they talk about capacitor size in ohms, which is strange bc that's the only time they talk about the capacitor.

They mention the 'reactance' of the capacitor. They're talking about capacitive reactance, Xc.
Xc = 1/(2pif*C)

If we assume that "a few hundred ohms" = 300 ohms, and that the current being measured is the mains, it's not hard to transpose the formula to get a rough starting value for the capacitor.

C = 1/(2pifXc) = 1/(2pif300)

In the US the mains frequency is 60Hz:- 1/(2pi60300) = 8.8uF
In Australia, the UK etc, the mains is 50Hz:- 1/(2
pi50300) = 10.6uF

So a 10uF cap should do the trick, I'd imagine, or a 22uF for slightly better filtering at a cost of a little slower response time.

pekasus:
@Archibald Thanks! I just found that after posting.

The only problem is they don't give a capacitor size. Do you know what it should be? At the bottom of the page they talk about capacitor size in ohms, which is strange bc that's the only time they talk about the capacitor.

The purpose of that capacitor is not obvious. The current transformer with its burden resistor is in series with the Arduino's input. I am finding that the input current to a pin configured as an analogue input is less than 0.5nA. That means an insignificant current will be flowing in or out of the centre of the voltage divider (two 10kΩ resistors). So in theory the capacitor is not necessary. However the chances are that the current transformer is on the end of a cable perhaps several metres from the Arduino. You do not want any low frequency or radio frequency voltages picked up by the cable to affect the measurements. The capacitor can provide a fairly low impedance to ground which could significantly reduce any unwanted signal.

Unfortunately the capacitor creates an issue or at least makes an issue worse. The issue is what happens if there is a signal from the current transformer when the Arduino is not powered-up. You could be getting nearly 2.5V or nearly -2.5V applied to the input of the Arduino. Especially with the capacitor in the circuit, the source impedance presented to the Arduino will be low, so current could damage the microcontroller chip. I therefore recommend inserting a resistor in series with the analogue input, close to the Arduino pin, say 22kΩ. This should allow the protection diodes within the microcontroller chip to function without excessive current.

Archibald:
The purpose of that capacitor is not obvious. The current transformer with its burden resistor is in series with the Arduino's input. I am finding that the input current to a pin configured as an analogue input is less than 0.5nA. That means an insignificant current will be flowing in or out of the centre of the voltage divider (two 10kΩ resistors). So in theory the capacitor is not necessary. However the chances are that the current transformer is on the end of a cable perhaps several metres from the Arduino. You do not want any low frequency or radio frequency voltages picked up by the cable to affect the measurements. The capacitor can provide a fairly low impedance to ground which could significantly reduce any unwanted signal.

Unfortunately the capacitor creates an issue or at least makes an issue worse. The issue is what happens if there is a signal from the current transformer when the Arduino is not powered-up. You could be getting nearly 2.5V or nearly -2.5V applied to the input of the Arduino. Especially with the capacitor in the circuit, the source impedance presented to the Arduino will be low, so current could damage the microcontroller chip. I therefore recommend inserting a resistor in series with the analogue input, close to the Arduino pin, say 22kΩ. This should allow the protection diodes within the microcontroller chip to function without excessive current.

The series resistor is always a good idea, in case of mishaps like an accidental Arduino power cut, but we should never connect anything that's powered to an unpowered micro anyway, unless it really can't be avoided.

And we can probably assume that the cap is there for a reason, probably the one you suggest, Archibald. I personally wasn't trying to second-guess anyone, just showing a way to work out what the cap value was likely to be, given the capacitive reactance and frequency.

@oldsteve @archibald thanks for the explanation!

What about the current limiting resistor on the analog pin? The Open Energy Monitor doesn't use one. The one I have on my proto is 100 ohm. Is there any sense to leaving this in?

pekasus:
What about the current limiting resistor on the analog pin? The Open Energy Monitor doesn't use one. The one I have on my proto is 100 ohm. Is there any sense to leaving this in?

Why did you put 100Ω there? Can you not find a higher value resistor, say anything between 22kΩ and 10MΩ?

I don't think anyone knows what current the protection diodes within the microcontroller chip will tolerate (with chip not powered). So my 22kΩ suggestion is a guess. Without the capacitor, the two 10kΩ resistors effectively provide 5kΩ resistance in series with the analogue input. That alone may well give sufficient protection but who knows? It's possible that the "few hundred ohms" reactance of the capacitor in series with the burden resistor will give sufficient protection, but who knows?

One thing you could try while no current is being sensed is to see whether the capacitor makes any difference to your digital readings. Hopefully your readings will show no AC signal with or without the capacitor. If so, leave the capacitor out so you gain the protection of the 5kΩ resistance.

We may be worrying unnecessarily about this issue but it may save you buying a new Arduino!

@Archibald, I agree regarding a series protection resistor.

One in the order of 10K to 22K would be fine, but higher wouldn't hurt. I tried searching for maximum current ratings for the input protection diodes, but they don't appear to be published anywhere. Still, to be useful, logic tells me that they must be able to handle at least 1mA continuous, possibly up to as high as 10mA, otherwise there'd be no point in them being there in the first place. Allowing for 1mA maximum, and 2.5V across the cap, anything from 2K7 upwards should protect the input from the voltage on the cap when power is removed from the chip.

Capacitors are used regularly on PWM outputs for filtering, often with series resistances of 10K, sometimes less, without any damage to the chip when the power is removed. (The pin will not still be an output for long after the power is removed.)

I don't think that the addition of the capacitor is much of a problem at all, and definitely not a problem with a 10K to 22K series input resistor. (100 ohms is a bit low.) I was taught to always use a 22K series resistor with all off-board inputs.

As to whether the cap is even necessary, that's what the proto board circuit is for. @pekasus, as suggested by Archibald, do some testing with and without the cap, in the typical environment/setup you will finally use it in. As mentioned, the lead length is a consideration.
Since you've been running it for 4 months without a cap and with no problems, it might well be true that you don't need one at all, but it probably was included in the circuit you showed for a good reason.

OldSteve:
Still, to be useful, logic tells me that they must be able to handle at least 1mA continuous, possibly up to as high as 10mA, otherwise there'd be no point in them being there in the first place.

Looking at the microcontroller chip package of my Arduino Micro, just 7mm square, logic tells me that these 40 or more protection diodes must be very small to allow space for the lead frame, processor, memory and other interface circuitry. The circuit diagram of the protection diodes shown in the data sheet is only an "equivalent schematic", not necessarily the actual circuit of what is on the silicon. We are not certain the diodes still function fully when the chip is not powered up. However I find it remarkable that such a tiny chip is capable of driving relatively high output currents so I'm probably being far too over-cautious. Nevertheless, a resistor is much cheaper than a replacement Arduino!

Archibald:
Looking at the microcontroller chip package of my Arduino Micro, just 7mm square, logic tells me that these 40 or more protection diodes must be very small to allow space for the lead frame, processor, memory and other interface circuitry. The circuit diagram of the protection diodes shown in the data sheet is only an "equivalent schematic", not necessarily the actual circuit of what is on the silicon. We are not certain the diodes still function fully when the chip is not powered up. However I find it remarkable that such a tiny chip is capable of driving relatively high output currents so I'm probably being far too over-cautious. Nevertheless, a resistor is much cheaper than a replacement Arduino!

I agree regarding the resistor, as I said in my last post. I don't connect anything to my inputs without a 10K to 22K series resistor, either with my Arduino or with PIC chips. Besides things like the filter cap, a decent-value resistor provides good protection from ESD as well. Better to be safe than sorry, and as you say, resistors are cheap.

The diodes will be very small, (that's why I said they may only be able to safely handle 1mA), but you'd find that they are still normal silicon diodes, and would remain diodes even when the chip loses power. Otherwise, as mentioned, the filtering capacitor on a PWM output, or filter capacitors on inputs as we're discussing, would regularly do damage when power to the chip is cut and we'd (most likely) hear about it here on the forums.

And the actual silicon area on even a 1N4148 is extremely small, too, but they handle up to 200mA without problems. They're mainly glass. The diodes in a microcontroller chip are big enough to 'protect' the chip. After all, that's why they're there. And they have the whole chip body to dissipate any heat that may be generated, especially with a series resistor correctly placed.

These little chips are very robust, and seem to withstand all sorts of torture without damage. I'm sure you've read what some people do to them. (Poor chips) :slight_smile:

Edit: I'm really surprised that there are no specs in the datasheets relating to the protection diodes. And PIC datasheets are also lacking in this regard. At the very least, they could provide a recommendation for a minimum safe series resistance.