Shop OBEX P1 Docs P2 Docs Learn Events
BS2SX to measure current unique problem almost solved please help. — Parallax Forums

BS2SX to measure current unique problem almost solved please help.

steve213steve213 Posts: 9
edited 2008-01-08 21:17 in BASIC Stamp
hello everyone,

here is my problem. I am trying to use the following product and interface it to the basic stamp BS2-SX

http://www.allegromicro.com/en/Products/Part_Numbers/0713/index.asp

so far I have been able to hook up a computer through the ACS713 and measure the current with a multi meter and it compares to my clamp on ampmeter at about .7 amps which is great. my problem is i want to output the AC voltage from the ACS713 (in millivolts) to the BS2SX somehow so that the stamp can understand what is going on.

I tried the ADC0831 and hooked it up it works but only measures DC volts, my problem is how do i get all of this to work with AC?

The ACS713 measures the current of whatever is hooked up to it and has output voltage on a VOUT pin at 185mv/amp. for example i was measuring how much current a desktop computer was drawing and the ACS713 had about 120mv on its VOUT pin - so 120/185 = about .7 amp load the computer was drawing.

in this example i want to feed that 120mv AC voltage to the ADC0831 (or something similar) to have the stamp be able to read the voltage.

thanks a lot
steve

Comments

  • stamptrolstamptrol Posts: 1,731
    edited 2008-01-02 19:21
    steve,

    Google "precision rectifier". You'll be looking for a design with an op-amp which will compensate for the normal voltage drop across diodes.

    In your case, a half-wave version will be fine as your loading into the ADC will be very light, requiring only a small amount of filtering. You can also go one step further and add a stage of amplification so the output will be 0 - 5 VDC, which the ADC will really like.

    Cheers,

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tom Sisk

    http://www.siskconsult.com
    ·
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2008-01-02 19:23
    The Hall-effect device you cite is for measuring DC current. Reading the datasheet, it's apparent that you will not get a negative voltage output from this device when the current is running in reverse. If you look at the voltage output on a scope, you will likely see separated, positive-going, sinewave "bumps". If you could sample these bumps often enough, you could compute your average or RMS current from that. But to make life easier, a peak detector would be a better option. This is an op-amp circuit whose output corresponds to the highest input voltage it sees (with a slow decay). You can then feed this relatively constant output to your ADC to get readings at a more leisurely pace. Assuming that the original current waveform is symmetrical and sinusoidal, you can then compute the RMS current from the peak voltage that you read.

    Peak detector circuits are available in abundance on the internet. Google op-amp peak-detector. National Semiconductor's op-amp datasheets are another good source for inspiration.

    -Phil
  • steve213steve213 Posts: 9
    edited 2008-01-07 22:49
    hello,

    i tried this and i'm getting the same result. am i doing something wrong? the debug screen is showing the voltage and its bounding all over the place.

    http://www.discovercircuits.com/DJ-Circuits/peakdet1.htm

    here is the code:

    '{$STAMP BS2SX}

    ADdata CON 2
    ADclock CON 1
    ADcs CON 0

    result VAR Byte
    mvolts VAR Word

    Initialize:
    HIGH ADcs

    Main:
    GOSUB Read0831
    mvolts = result */ $139C
    DEBUG HOME
    DEBUG "adc... ", DEC result," ", CR
    DEBUG "volts... ",DEC mvolts DIG 3, ".", DEC3 mvolts
    PAUSE 100
    GOTO Main
    END

    Read0831:
    LOW ADcs
    SHIFTIN ADdata,ADclock, MSBPOST, [noparse][[/noparse]result\9]
    HIGH ADcs
    RETURN
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2008-01-08 05:10
    steve -

    If you really are reading 9 bits of data, you probably want "result" to be defined as a WORD, and not a BYTE. A BYTE can only contain 8 bits of data.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2008-01-08 19:01
    Steve,

    What does your voltmeter measure at the output of your peak detector? This will help to isolate the problem as to whether it's hardware or software. If you get a steady voltage reading, then it may be your code. If not, it's more likely to be the peak detector circuit. If you have an oscilloscope, use it instead of the voltmeter, since some voltmeters have rather long sample times and may not reflect any jitteriness in the signal.

    -Phil
  • steve213steve213 Posts: 9
    edited 2008-01-08 20:15
    phil,

    i am getting the same results with my multimeter with and without the peak detector. the Vout with NO LOAD is 0v AC and about .5vDC which is expected, the data sheet says you will see .5vDC on the output pin with no load. i add a load and i switch the multi meter to AC and i start to see exactly what i'm supposed to which is about .130vAC and the DC goes to about .540 but that means nothing to me.

    i'm using this peak detector http://www.discovercircuits.com/DJ-Circuits/peakdet1.htm

    and this IC from allegro micro http://www.allegromicro.com/en/Products/Part_Numbers/0713/index.asp

    basically i want the stamp to see the .130vAC just like the meter tells me in AC mode. does the .540 vDC help me at all?


    when hooked up to the stamp with the peak detector and the ADC (using my code above) i see about .510 vDC (which is right) but as soon as i put a load on it the numbers start bouncing all over the place. im hoping for the numbers to change to about .130.

    thanks
    steve
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2008-01-08 20:56
    I'm afraid we may be at a disadvantage here without a scope. What we really need to know is what the signals at the sensor and peak detector outputs look like when there's a load. The results you're reading with the Stamp may or may not be indicative. Another possible issue is whether your load is creating high-current spikes shorter than the 60Hz period. If that's the case, peak readings will be misleading, and it won't be possible to compute an average or RMS current from them. Here, again, a scope is essential.

    In the case of short spikes, or even out-of-phase voltage and current, and if what you're really interested in is power consumption — not just current draw — a DC current sensor will be inadequate. If that's the case, I may be at a loss to help, since my experience with power factor considerations is nil.

    -Phil
  • steve213steve213 Posts: 9
    edited 2008-01-08 21:17
    ill try and get a scope i guess...


    thanks again.
    steve
Sign In or Register to comment.