Shop OBEX P1 Docs P2 Docs Learn Events
Need source code to create voltmeter using built-in ADC... help please! — Parallax Forums

Need source code to create voltmeter using built-in ADC... help please!

Mach3MaelstromMach3Maelstrom Posts: 7
edited 2009-04-28 10:17 in Propeller 1
Hey all! I'm fairly new with the chip itself and need some quick assistance for a business project that involves reading the voltage drop across a resistor at a given time.

I'm using the C compiler because I know C language MUCH better than Basic. I just want to know how to call upon the VDC to assign the voltage drop value at a given time to a float variable.

Can someone assist me with this? Time is of the essence and while I'm learning fast, it may not be fast enough [noparse]:([/noparse]

Comments

  • RaymanRayman Posts: 14,826
    edited 2009-04-27 10:31
    Sorry, no C code...

    But, I've got some info and Spin code here:

    http://www.rayslogic.com/propeller/Programming/ADC.htm
  • Mach3MaelstromMach3Maelstrom Posts: 7
    edited 2009-04-27 14:56
    Nice. At least that will be simple to construct. But it seems to only display how to graph the function and I can't find where it declares the y-values in the code.

    Also, as newbie as a question this may be, but instead of the Sigma-Delta ADC couldn't I build a full-wave rectifier with a cap to smooth the signal? If not, just let me know. The AC signal is going to be wall current (the project is for a home appliance) and so I'd like to know as soon as you can let me.

    [noparse][[/noparse]EDIT:] Forgot to mention the important fact that I will be testing the voltage coming off of the *common* lead (aka the voltage will be ~0) and NOT the hot lead (aka the voltage being +- 120V). That way you know I'm not killing myself doing this project lol.

    Post Edited (Mach3Maelstrom) : 4/27/2009 3:03:48 PM GMT
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-04-27 15:20
    You're still asking for trouble, if you're connecting directly to the mains. For one thing, "neutral" isn't the same as "ground", since the neutral wire carries current, and the ground wire does not (or isn't supposed to anyway). Plus, if something should happen, and your resistor fails, your Propeller will be seeing the mains' full fury. Moreover, when you connect your PC to this circuit to program it, you risk a serious ground loop, since many PCs connect logic ground to chassis ground.

    It would be much better, if you want to measure current, to use a current transformer or a Hall-effect current sensor. Both provide galvanic isolation between the mains and your sensing circuit.

    -Phil
  • Mike GreenMike Green Posts: 23,101
    edited 2009-04-27 15:25
    How do you know the appliance is wired correctly? How do you know whether the wall outlet is wired correctly? You really have to assume that the ground and hot leads may be reversed because it's so dangerous to get it wrong.

    You will still need some kind of ADC. A full-wave rectifier and filter cap just changes the AC to DC.

    "But it seems to only display how to graph the function and I can't find where it declares the y-values in the code"? Do you mean the Microphone2VGA demo? There the assembly routine does its own graphing.
  • Mach3MaelstromMach3Maelstrom Posts: 7
    edited 2009-04-27 17:56
    Phil and Mike: You guys are absolutely right. If the resistor fails or the house wiring is skewed (which happens more often than I'd like to admit), then my project becomes a hazard.

    I had been warned regarding the latter, so I figured I would utilize a linear optocoupler to fix the voltage differential problem.

    I'm unfamiliar with ADCs and how to use them, I suppose. I was under the impression that the lack of floating variables was the reason I couldn't use the Basic Stamp, but I've been informed that I can make the math all integers as long as I kept proper "bookkeeping" throughout the code. Can someone shed light on that issue?

    And once again, thank you everyone for helping me in this matter! Especially Phil and Mike for convincing me to change the schematic. (P.S. I can just build this circuit in a lab and have no qualms, right? If so, in this system, is Vdd a separate supply or can I get it elsewhere more suitable in appliances?)
  • LeonLeon Posts: 7,620
    edited 2009-04-27 18:06
    It would be a good idea to use an isolation transformer when you are developing your system, and use en "earth-free" area. I'd also ensure that someone else is in the vicinity at all times, in case you electrocute yourself and need resuscitation.

    Leon

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Amateur radio callsign: G1HSM
    Suzuki SV1000S motorcycle
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-04-27 18:40
    Just to be clear, even if the resistor remains intact and the house wiring is correct, a hazard still exists. This is because there will be current from the appliance under test, along with other appliances sharing the neutral line, causing a voltage drop between it and the breaker box. This translates to a voltage differential between neutral and earth ground, which will wreak havoc on anything else connected to the circuit, including your computer and your body.

    -Phil
  • TeslaTesla Posts: 55
    edited 2009-04-28 06:07
    How about a voltage to freq circuit with a opto-isolator? Then just count the freq at the prop. Works in industrial stuff.
  • DanicoDanico Posts: 10
    edited 2009-04-28 10:17
    This is something I have been looking at for a current project - appears to be·accurate and importantly the isolation provides some safety.
    The board layout would need to be·considered to carry the isolation through.

    http://www.allegromicro.com/en/Products/Part_Numbers/0756/

    There are quite a few similar items knocking around as well.

    D
Sign In or Register to comment.