Shop OBEX P1 Docs P2 Docs Learn Events
BASIC Stamp Voltmeter — Parallax Forums

BASIC Stamp Voltmeter

Jason OJason O Posts: 16
edited 2007-11-11 05:25 in BASIC Stamp
Hello All,
·
I'm working on a project that *should* be relatively simple, but the answer is alluding me grossly! I have a BASIC Stamp 2 and I want to use it to detect voltages from -5 to +5 volts but I'm not sure how best to go about it. I realize that I will need to use some sort of ADC chip to convert the analog signal and clock it into the Stamp, but I'm having a lot of trouble figuring out how to set it up to measure both positive and negative voltage values. Most of the circuits I've seen online use ADCs that will accept an input from the circuit ground potential up to some value X. In my case, I really just want to measure the voltage across a resistor (which could be positive or negative depending on the direction of the current flow through it. To complicate things further, I'm trying to find a way to do this without connecting either side of my measurement resistor directly to the circuit ground (paranoia about spikes and noise·frying my chips). I've heard of differential input ADCs but I'm having a lot of trouble finding one that doesn't need one of the inputs to be·grounded.
·
Has anyone worked on something like this before? The idea seems so basic but I can't seem to find any good information on it.
·
God Bless,
Jason O

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2007-11-08 23:51
    You can transform a -5V to +5V range to 0-5V at the ADC pin quite easily, using biasing resistors. At the ADC input, run a 10K pullup resistor to 5V. Then apply your analog voltage to the same pin through another 10K resistor.

    Your readings will be as follows:

    ····-5V : 0V
    ·····0V : 2.5V
    ·····5V : 5V

    For this to work with any accuracy, the output impedance of your analog source will have to be considerably less than 10K. If that can't be achieved, you will have to buffer the analog source with an op-amp.

    -Phil
  • Mike GreenMike Green Posts: 23,101
    edited 2007-11-08 23:59
    One trick is to use a differential input op amp as input to a standard ADC. Any dual supply op amp (+5/-5) can be used this way and, if you use a dual unit, you can use one to measure the differential voltage across the resistor and transform it into a -2.5 to +2.5V range instead of -5 to +5V range (by picking the feedback resistors to give a gain of 1/2), then use a 2nd stage with the negative terminal tied to -2.5V to transform this into a 0-5V range which you can feed to a standard 0-5V ADC like the ADC0831. I'm sure there's a little simpler way, but this would work.
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2007-11-09 04:12
    The MAX1270 analog to digital converter sold by Parallax for the Stamp PLC has an input range of +/- 5 volts (among other possible ranges). It uses a single power supply and a scheme of resistors at the input similar to the one Phil described. The input resistance is thus quite low, on the order of 15 or 20 kohms. But it is not differential--It is single ended with all voltages measured with respect to analog ground.

    On rereading what you are asking, it sounds like you do need a differential input. I am left with some questions. Could you describe in a little more detail where this resistor stands in relation to the circuit? For example, it might be a resistor in series with a battery that will be either charging or discharging. If that is the case, there are some dedicated current monitoring integrated circuits that could help out. Details please!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • Jason OJason O Posts: 16
    edited 2007-11-09 20:11
    Hey Guys,

    Thank you for all the great suggestions!

    @Tracy,

    I attached a basic diagram of what I am attempting to do. In the most basic sense, I want to make a voltmeter that has the capability to measure a voltage range of· 0 to 1000V with roughtly 1V resolution (quite coarse but sufficient for my application). I am using a voltage divider circuit to reduce the 0 to 1000V input down to a 0 to 5V input.

    The thing is that the input could be positive or negative depending on which way the probes are connected to whatever is being measured. Also, the input is expected to be mostly DC but could also have AC voltage spikes and RF hash mixed in. So I really don't want to connect any part of the resistor divider circuit directly to the circuit ground (to keep the noise off the board). So I'm hoping I can use something that allows the input voltage to basically float with respect to the circuit. So if I can just mrasure the voltage drop across the resistor in the divider, that would be the best thing.

    I attached a circuit schematic of my idea (as it stands now).

    God Bless,
    Jason O

    Post Edited (Jason O) : 11/9/2007 8:16:06 PM GMT
    547 x 163 - 2K
  • LilDiLilDi Posts: 229
    edited 2007-11-09 22:49
    I don't get it!!!
    For $25 or $30 you can buy a DVM from Radio Shack that meets your requirements in a handy pocket sized meter.
  • Jason OJason O Posts: 16
    edited 2007-11-09 22:52
    LilDi said...
    I don't get it!!!
    For $25 or $30 you can buy a DVM from Radio Shack that meets your requirements in a handy pocket sized meter.

    It needs to be able to interface to my microcontroller as part of a control loop.
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2007-11-10 05:42
    Jason,

    The circuit as you have drawn it requires some kind of common connection between the circuits, but what you are after is high voltage isolation.

    One way to achieve lots of isolation is to use a voltage to frequency converter powered by the high voltage itself, and flash a light at a rate proportional to the voltage. An isolated photoreceiver attached to a BASIC Stamp is the other half of the magic, with no direct connection, just the light. Your resistor divider circuit draws about 100 microamps from the 1000 volt supply, so that could alternatively go into powering the VFC. To illustrate, the simplest circuit of this type consists of an NE-2 neon bulb in parallel with a 0.01uF capactor, and that combination then in series with the 10meg resistor. At 1000 volts input, the light would flash at a rate of about 10 per second, and slower rate at lower voltages. But it would not work at all below ~90 volts, and would not be as stable as you require. But it is bipolar. An improvement could be made by using a Diac (bilateral trigger diode, e.g. Teccor HT32) such as is found in AC lamp dimmers. Or at a lower voltage, the circuit could use a unijunction transistor or a timer IC with LED. IF the IC itself will only operate on one polarity, then the circuit could be wrapped in a full diode bridge.

    It is also possible to derive an isolated supply from the low voltage system. There are little power modules that cost around 10 bucks that can provide about 1 watt of power with >2000 volts of isolation. There are also isolation amplifiers and other tools in the exotic bag of tricks.



    Jason O said...
    Hey Guys,


    Thank you for all the great suggestions!



    @Tracy,



    I attached a basic diagram of what I am attempting to do. In the most basic sense, I want to make a voltmeter that has the capability to measure a voltage range of 0 to 1000V with roughtly 1V resolution (quite coarse but sufficient for my application). I am using a voltage divider circuit to reduce the 0 to 1000V input down to a 0 to 5V input.



    The thing is that the input could be positive or negative depending on which way the probes are connected to whatever is being measured. Also, the input is expected to be mostly DC but could also have AC voltage spikes and RF hash mixed in. So I really don't want to connect any part of the resistor divider circuit directly to the circuit ground (to keep the noise off the board). So I'm hoping I can use something that allows the input voltage to basically float with respect to the circuit. So if I can just mrasure the voltage drop across the resistor in the divider, that would be the best thing.



    I attached a circuit schematic of my idea (as it stands now).



    God Bless,

    Jason O
    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • jsmasterkingjsmasterking Posts: 35
    edited 2007-11-10 22:33
    Phil Pilgrim (PhiPi) said...
    You can transform a -5V to +5V range to 0-5V at the ADC pin quite easily, using biasing resistors. At the ADC input, run a 10K pullup resistor to 5V. Then apply your analog voltage to the same pin through another 10K resistor.

    Which input are you referring to Vin(+) or Vin(-)?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·on····· plane··········································, when catching ducks

    "In this house, we obey the laws of thermodynamics!"
    ··············································································^
    http://profiles.yahoo.com/jsmasterking
  • Jason OJason O Posts: 16
    edited 2007-11-11 05:25
    Hi Everyone,

    Tracy, your idea to use the opto-couplers is a good one, but the problem is that I'm not expecting that the input will go up to 1000V, I'm actually anticipating voltages in the range of 50-300V, but I want the circuit to be able to take voltages that could get that high. I don't want to have to necessarily power anything from the voltage divider, just measure the potential voltage across the 5V side of it. I want the input voltage to be high impedance so that I won't affect the circuit that I am measuring very much. Plus, I'm planning on sampling the voltage at something like 100 samples per second, so whatever I use should have a reasonable response time.

    At this point, I've been looking into using Op-amps to isolate the input and convert it to a single-ended input like what Mike was saying. If I can just isolate the inputs using the Op-Amps, then I won't have to worry about having an isolated supply on my board, and using opto couplers to clock the data across the isolation zone to my Stamp. But I'm not completely sure how to setup the op-amps to convert from the differential input to a biased, single-ended, input that I can read with my ADC.

    Rather that dealing with +- voltage supples, If I could just have the input waveform ride on top of a 2.5V bias, then I can simply use the range of the ADC and subtract the positive offset voltage inside my Stamp to get the negative voltage values. To fully isolate the inputs, I was thinking about using sort of an instrumentation amplifier setup since it *appears* that the voltage divider doesn't have to be directly referenced to the circuit ground. Here's a link to the circuit I'm thinking about:

    03046.png

    But this circuit by itself won't make the offset output wave that I want. What do you think about using the two op-amps at the beginning to isolate the input signal? would that work without having the ground reference connected th the input resistor divider?

    God Bless,
    Jason O

    Post Edited (Jason O) : 11/11/2007 5:41:26 AM GMT
Sign In or Register to comment.