Author
Topic: ADC on Raspberry Pi (Read 7420 times)

Sorry for the long post but I'm hoping someone can give me some advice about using an ADC on my RasPi.

I'm building a monitoring server for systems on my boat and looking to monitor the voltage on two battery banks (house and starter), current in/out of the house bank, and current out from three solar panels and a wind generator (using the BB-ACS756 hall effect current sensors from Cytron).

However, monitoring voltages caused me major headaches. I used a voltage divider on the inputs with 10k and 1k resistors giving me a voltage of about 1.2 volts on the differential inputs of the original boards (which should have been good up to something like 20 volts) but that didn't work. I tried putting a capacitor across the inputs thinking it might suppress any spikes but that didn't seem to make much difference. I ended up letting the smoke out of one chip on each board and blowing some individual inputs on the other chips. Expensive mistake!

I think my problem is with spikes on the voltage of the battery banks maybe by loads from pumps etc as they seemed to work for a while then failed badly but I'm not at all sure.

So I'm hoping someone can help me with designing a method of safely measuring voltages between (say) 10 and 16 volts using the new boards. I'm sure I'll need another voltage divider but I'm not sure of the values to use and how can I protect the ADC inputs from unknown spikes or surges?

as battery voltage is very slow to change add a bigger buffer resistance into the adc to bring your time constant something close to 10 seconds, also have a zener or TVS diode to clamp both positive and negative on your input,

you can either up your resistance or your capacitance, the key point is slow down the rate of change and clamp it. when zeners are running dramatically under there wattage they don't fail often. if concerned put 2 in parallel, then your only concern will be if one shorts, but that's going to show up as 0V which should make clear you have a problem, and still protect the input

Keep in mind the input impedance to the ADC effecting your resister divider.mcp3424 has a 2.25/PGA Mohm so worst case is ~280K at a gain of 8 this will mean you will need take this into account at the high impedance you are talking about.with a resister divider a zener will be fine for protection. however a TVS diode has a larger junction area than a zener and therefore can take a large hit.

I read the 2.25/PGA impedance value from the data sheet but wasn't sure what it meant exactly. Would that be 2.25Mohm when the programmable gain is 1 and 0.28Mohm when the gain is set to 8?

Again from the data sheet, the sampling capacitor is 3.2pF so with PGA set to 1, would that mean I can use 10Mohm and 2Mohm in my divider? I think that would give a time constant of around 38 micro seconds or (say) 120 micro seconds to charge to about 90%? I could put another capacitor from the input to ground to slow things down even more I guess.

I think my divider resistors have been orders of magnitude off which might explain why I'm blowing the inputs.

Hi Davo,The reason your inputs have been blowing up are because of transients on the supply rail.This is common on any automotive or marine setup. You will need to protect the input by placing a Zener or TVS across the input as already suggested.

also you will need to be carefully about your ground point and ensure you don't have any ground loops.I assume the ground from your unit goes back directly to the -battery terminal and not linked to a ground on other items?

Any Resister Divider with a few 10s of Kohm should be enough with a zener /TVS to provide protection.as long as the impedance is 1/10 of the impedance of your load you shouldn't really have any loading issues.

I've got the new ADC's (ADC Pi V2.1) today and I'll be installing and testing them over the weekend. This ADC only has single inputs (cannot do differential measurements) and has an on-board voltage divider allowing an input range of + - 5volts.

The house battery bank has a shunt already installed (used by a Xantrex "link 10" battery monitor) and I've been grounding the pi to the load side of that shunt in the same way as all the other loads on the boat. After your comments, I'm having second thoughts especially as I'll need to measure the voltage on the starter battery which shares the same battery ground as the house bank!

Would you suggest I ground the pi on the battery side or the load side of the shunt?

If on the battery side, the Link 10 battery monitor would not see the load that the pi has on the battery bank of course. However, the bank is 420AH so the extra load from the pi would be less than negligible.

If I put it on the load side, would I get a ground loop when I try to measure the starter battery?

And would I be able to measure the size and direction of the current (charge/discharge) through the shunt with the new ADC without a differential input ?

It looks like I'm well out my depth here. Maybe I need to go back to school :-)

Hmmm, I just checked and the shunt is from the house bank negative terminal to an earth bus and the starter battery negative terminal is connected to the earth bus (i.e. on the load side of the shunt).

So I'm sure now that I need to connect the Pi earth to that same bus (i.e. the load side of the shunt).

I'll start with measuring the voltage across the shunt I think as it's highly unlikely to give me problems with spikes as the voltage looks like 1mV per amp of current through the shunt.

Hi Davo,You should be ok if you go on the load side just make sure your sense ground and voltage ground for your supply come from the same point.so you don't get any voltage spikes between your ground of the pi and -ref on your adc.provided you have some reasonable impedance between the voltage points your measuring a zener will clamp it in both positive and negative directions.

With the ground side connected to the pi but the +ve disconnected (via a switch), there is zero resistance from pi ground to the battery ground (actually the load side of the shunt).

But when I switch the power through to the pi, I can measure some voltage (varies a lot but averages around 0.3V) from the pi ground to the battery ground. I don't have a circuit showing the internals of the buck converter but I'm thinking it has a cap or something from it's -ve output to it's -ve input (isolation maybe?).

Anyway, it seems to be screwing up small measurements like the voltage across the shunt. They say nothing in life is easy but a break now and then would be nice :-). I might have to go with a different and probably more inefficient power supply.

I also think I'm going to have to go back to a differential input for the shunt voltage measurement.

I'll give measuring the battery voltage a go tomorrow night when I get back to the boat. I'm hoping that will be nice and stable and with the zeners for protection this time, I might just be able to keep the smoke inside the chips where it belongs!

if I understand what you are saying is that the reference ground is bouncing around.The problem is mostly likely just inductance and resistance between the supply ground (battery) and measuring point (adc) and current is being consumed along the path (pi) which induces a voltage that also shows up at the end. a star earth gets around this issue but can have other issues.is the voltage being induced in the psu or the PI? if its in the psu you may be able to connect both grounds together to ensure a low impedance.

I'll try binding them together tonight with a multimeter to measure the resulting current flow and monitor the buck output voltage at the same time to see if I can successfully bind the input and output earths. I'll put a dummy resistive load on the output first I think rather than risk the pi.

I'm not sure how to tell where the voltage is being induced but I suspect the buck converter output earth is not bound tightly to the input earth . It's earthed back to the battery over a short cable to the load side of the shunt so it's sort of a star topology already.

A instrumentation amp (differential) would be the next option as David_AVD suggests.However you will be outside of the common mode range of the amp so you will most likely need to generate a negative rail.all and all its a pain in the arse to vero board of cludge onto the adc board.Cheers