I'm looking for reasonably priced and reasonably easy to implement ways to measure voltages with a computer. To be more specific:-
The computer will either be the existing eeePc running Ubuntu (but no GUI) or a raspberry pi.
I need to monitor at least four and preferably eight or so voltages, some of these are 12 volts (i.e. lead acid batteries) and others are current transducers giving an output around 2.5 volts with a +-0.5 volts swing.
I don't need *incredible* accuracy but something around 2% or better is necessary for it to be useful in monitoring battery charge state.
I want it to be cheap!
Sample rate can be slow, once an hour would be fine.
I have a 1-wire interface implemented which currently measures temperatures but I can't find any quick/easy way to add voltage measurement to 1-wire. It can be done but gets 'messy' and 1-wire seems to be a disappearing technology.
I've looked for volts->USB interfaces but can't find much, if someone knows of anything I'd be pleased to hear about it.
Any ideas for cheap hardware to do this (I am happy to solder things etc.) would be very welcome.
If you want quick and dirty just use something like the ADS7830, it runs on i2c so if you want minimal soldering just run it direct from a i2c bridge or even a bus pirate and have the monitoring app as a daemon on the pc. 8bit so 0.05v step resolution if you were wanting to monitor 0-12v.
You'll need to set up some lot tolerance potential dividers to cope with the 12v and you may run into problems with shared grounds depending on what you are monitoring. I *think* the 7830 has an isolated analogue signal ground so you may just end up needing a couple of them running on different ground planes but you'll need to check that on the datasheets. Otherwise it probably supports 4 channels of differential measurement so you could do the ground isolation that way.
Alternatively pick any microcontroller platform and build a standalone monitor that buffers and spits out the data via serial or whatever. Doesn't matter what really, could be PIC, AVR, or even just an Arduino shield, the right Arduino shield/AVR has 8 ADC inputs on chip but then you have more work to do on ground isolation probably.
Either way a fairly trivial amount of code and a tiny bit of hardware would see you though. Would take a bit more effort to get it spot on and stable and again depending on what you are monitoring you may want some electrical isolation between your PC and whatever is being monitored.
On Fri, Oct 26, 2012 at 11:10:14PM +0100, Wayne Stallwood wrote:
If you want quick and dirty just use something like the ADS7830, it runs on i2c so if you want minimal soldering just run it direct from a i2c bridge or even a bus pirate and have the monitoring app as a daemon on the pc. 8bit so 0.05v step resolution if you were wanting to monitor 0-12v.
You'll need to set up some lot tolerance potential dividers to cope with the 12v and you may run into problems with shared grounds depending on what you are monitoring. I *think* the 7830 has an isolated analogue signal ground so you may just end up needing a couple of them running on different ground planes but you'll need to check that on the datasheets. Otherwise it probably supports 4 channels of differential measurement so you could do the ground isolation that way.
Yes, I'm conscious of the grounding problem. While the boat wiring (the batteries are on a boat) is quite well behaved in having a single earth point to the hull etc. the length of the wires to the voltages being measured are such that there may be problems.
Alternatively pick any microcontroller platform and build a standalone monitor that buffers and spits out the data via serial or whatever. Doesn't matter what really, could be PIC, AVR, or even just an Arduino shield, the right Arduino shield/AVR has 8 ADC inputs on chip but then you have more work to do on ground isolation probably.
I was thinking about Arduino (I already have one) but it gets a bit 'messy' to have something like:-
Desktop PC (where Arduino code would be written/built) | V eeePc (or Raspberry PI) on the boat | V Arduino
If I can instead have some hardware read/written by a Python script (or something similar) that can be done 'locally' on the boat eeePc then life would be simpler.
On 28/10/12 10:58, Chris Green wrote:
Yes, I'm conscious of the grounding problem. While the boat wiring (the batteries are on a boat) is quite well behaved in having a single earth point to the hull etc. the length of the wires to the voltages being measured are such that there may be problems.
Well the serial communications can go through a significant length of cable, hell i2c to the adc chip can be a significant length if you clock it down enough. So why not put the adc's near the batteries you are monitoring ?
I was thinking about Arduino (I already have one) but it gets a bit 'messy' to have something like:-
Desktop PC (where Arduino code would be written/built) | V eeePc (or Raspberry PI) on the boat | V Arduino
If I can instead have some hardware read/written by a Python script (or something similar) that can be done 'locally' on the boat eeePc then life would be simpler.
Sorry I'm confused here, what does building the arduino code on your desktop have to do with anything ? It's not in the chain as part of the live system.
Really you could be using the arduino as a smart bridge between Serial and i2c, If you put that in the way then it could spit out raw or even converted values and your python just needs to log or do whatever you want with them. It could even log and buffer data when the PC isn't available to collect it (which may make sense if that would be the only reason for the PC remaining powered up, even a RPi is a bit power heavy and self defeating to be used as a battery charge monitor)
If you use a dumb i2c bridge then you'll actually need to form and interpret the i2c packets at the PC end, you could do that in python as the bridge just presents a serial interface.
For me I'd do it all in the microcontroller because the parts cost will be the same as getting a dumb i2c bridge but there will be less work to do at the PC end...but that's just me :)
On Sun, 28 Oct 2012, Chris Green wrote:
Yes, I'm conscious of the grounding problem. While the boat wiring (the batteries are on a boat) is quite well behaved in having a single earth point to the hull etc. the length of the wires to the voltages being measured are such that there may be problems.
If the "grounding problem" you're worried about is magnetic pickup, then one traditional solution is:
- start with a wire twice as long as you need - bend it round a fixed support at its half-way point - sticky-tape both ends of the wire to the chuck of a power drill - turn the power drill on for a few seconds - cut the wire at the bend.
Hey presto, you've got signal and ground wires in a twisted pair.
On 28-Oct-2012 15:46:09 Dan wrote:
On Sun, 28 Oct 2012, Chris Green wrote:
Yes, I'm conscious of the grounding problem. While the boat wiring (the batteries are on a boat) is quite well behaved in having a single earth point to the hull etc. the length of the wires to the voltages being measured are such that there may be problems.
If the "grounding problem" you're worried about is magnetic pickup, then one traditional solution is:
- start with a wire twice as long as you need
- bend it round a fixed support at its half-way point
- sticky-tape both ends of the wire to the chuck of a power drill
- turn the power drill on for a few seconds
- cut the wire at the bend.
Hey presto, you've got signal and ground wires in a twisted pair.
HTH, Dan
Hmmm, I doubt that will work! The reason being that, with the ends taped to the chuck, it would not be possible for "counter-twist" to build up along each arm of the wire. So, when the doubled/twisted wire is released from its constraints, it would: a) Tend to wrap round itself; b) When this wrapping is undine (essential for extended use), the twist which had been imparted by the power drill would undo itself.
To test this theoretical doubt, I have just taken a 3m length of USB cable, doubled it, hooked the halfway point over a door-handle, then, holding the free ends firmly together (to emulate being taped to the power drill) I rotated the free end pair until there was plenty of apparent twist along the doubled cable.
I then unhooked the doubled end. Result: exactly as predicted above!
Has anyone successfully used Dan's method in practice?
The real way to impart a true twist would be to double the wire round the fixed support and then, starting at the support and working outwards away from the support, twist the wire, allowing the counter-twist to build up (with the free ends twisting correspondingly). Industrial twisting/spinning (e,g, in rope making) would have the strands being fed in from separate bobbins, which would counter-rotate.
(Now that I check at: http://en.wikipedia.org/wiki/Rope-making#Styles_of_rope_construction it would seem to conform the above).
Best wishes to all, Ted.
Best wishes to all, Ted.
------------------------------------------------- E-Mail: (Ted Harding) Ted.Harding@wlandres.net Date: 28-Oct-2012 Time: 17:46:58 This message was sent by XFMail -------------------------------------------------
On Sun, 28 Oct 2012, Ted.Harding@wlandres.net wrote:
Has anyone successfully used Dan's method in practice?
Yes - I have, although I didn't invent it. It was the standard method in the Quantum Matter Group at Cambridge University Department of Physics, when I was a masters student there.
It was a long time ago, but from memory, the wires I used were about 1mm diameter including insulation, and the repeat distance of the twist was about 6mm. This was tight enough to deform the wire plastically, avoiding the "elastic untwist" problem you encountered.
On 28/10/12 15:46, Dan wrote:
If the "grounding problem" you're worried about is magnetic pickup, then one traditional solution is:
- start with a wire twice as long as you need
- bend it round a fixed support at its half-way point
- sticky-tape both ends of the wire to the chuck of a power drill
- turn the power drill on for a few seconds
- cut the wire at the bend.
Hey presto, you've got signal and ground wires in a twisted pair.
That only really helps for balanced line or differential signalling and tbh electrical noise on a battery voltage you are monitoring isn't going to make much of a difference anyway.
It's a common misconception but twisting pairs doesn't magically reduce interference. What it does when you have differential signalling is ensure that both sides of the pair are subjected to the same electromagnetic interference at the same amplitude. Thus making it easy for a comparator to subtract the noise out.
The grounding problem Chris may have is twofold.
If the things he is monitoring don't share a common ground then he doesn't have a common point to tie the analogue ground of the A/D converter.
If he measures upstream from the batteries on their feed wires then his local ground will have a DC offset to the battery negative post, particularly under load. The reason is that the voltage drop in the battery cabling affects both sides of the circuit. So it would be fairly easy to create an unintentional ground loop.
Chris now tells us that the batteries are grounded to the hull things have become a bit simpler (as long as his ground straps are all good).
On Sun, 28 Oct 2012, Wayne Stallwood wrote:
What it does when you have differential signalling is ensure that both sides of the pair are subjected to the same electromagnetic interference at the same amplitude. Thus making it easy for a comparator to subtract the noise out.
That's the situation I meant by "magnetic pickup". Yes, the other noise sources you identify are probably bigger in Chris' application.
On Sun, Oct 28, 2012 at 06:18:51PM +0000, Wayne Stallwood wrote:
If he measures upstream from the batteries on their feed wires then his local ground will have a DC offset to the battery negative post, particularly under load. The reason is that the voltage drop in the battery cabling affects both sides of the circuit. So it would be fairly easy to create an unintentional ground loop.
Chris now tells us that the batteries are grounded to the hull things have become a bit simpler (as long as his ground straps are all good).
As in nearly all well engineered electrical systems like this (i.e. like our boat) it has as far as it's possible to ensure a single ground point.
I.e. there is only one electrical connection to the hull of the boat and that is close to the batteries and has a short and very fat cable from the battery negatives to the ground point. All connections throughout the boat comprise two wires whose negative wire (eventually) gets back to the single ground point.
The 'grounding' problem (if there is one) arises from the distance between the computer/electronics measuring the voltage and the voltage to be measured (which is essentially that across the battery terminals in the nether regions of the boat).
If the voltage measuring device has a floating/balanced/differential input there is not so much of a problem, a pair of wires to the battery terminals (or as close as necessary/needed) should work OK and if it's a twisted pair most electrical interference will be fairly well rejected.
However if the input is 'unbalanced', i.e. the A2D input on the Arduino or whatever has one side at ground potential (as seen by the Arduino) then one has to make very sure that ground potential is *actually* at the same potential as the battery -ve terminal. If there is significant current being drawn by other devices fed by the same piece of wire then this may well not be true.
On 29/10/12 09:45, Chris Green wrote:
If the voltage measuring device has a floating/balanced/differential input there is not so much of a problem, a pair of wires to the battery terminals (or as close as necessary/needed) should work OK and if it's a twisted pair most electrical interference will be fairly well rejected.
Aye that would work, The AVR chip used in the arduino doesn't AFAIK have a dedicated differential mode on it's A2D though so some fiddling would be required.
Either that or you are only a handful of op-amps away from having nice stable differential inputs with ground isolation by default :)
Personally I would still go with just putting the A2D or micro-controller down near the things you are monitoring and then you only have to deal with a single low speed data connection up to the bridge or wherever your PC lives. If you are really bothered you could always stick RS-422 level shifters at each end rather than using RS232 and run it over twisted pair...a bit of cat-5 would do.