Shop OBEX P1 Docs P2 Docs Learn Events
Reading a cycling voltage, capturing the peak value? — Parallax Forums

Reading a cycling voltage, capturing the peak value?

Turnbull2112Turnbull2112 Posts: 65
edited 2011-09-10 20:02 in BASIC Stamp
I have a voltage I'm reading from a process that cycles from let's say 2 to 4.5 volts every 40 seconds or so. How can I take a "snapshot" of the maximum voltage from the peak of each cycle and average the peaks? Is there any way to take the duration of the peak into account as well? I'm not sure what commands to use here. The voltage I'm reading is going to be scaled into 0-100%. Thanks

Comments

  • ercoerco Posts: 20,256
    edited 2011-09-03 09:25
    You're using an ADC or RCtime to measure the voltage using a Stamp?

    Make a loop that constantly measures the voltage as quickly as possible, updates the stored max value only if the current value higher than the previous stored max value. After the value decreases beyond a reasonable amount, call that a peak value, store in a word-sized accumulator, and update a sample counter. Average value is accumulator/samples.
  • Martin HebelMartin Hebel Posts: 1,239
    edited 2011-09-10 20:02
    There's also a peak-hold circuit using an op-amp that may be of use. It entails an op-amp (LM-358), diode, and cap on the non-inverting input. The capacitor will charge to the maximum value, and the diode will prevent it from discharging. This will lock in the peak for a little while. Without drawing it out, the op-amp is in the voltage follower configuration, with a cap to ground from the non-inverting input, and a diode in series with signal. A better means is to use another op-amp instead of the diode (to prevent the 0.7V drop). This web page has a java applet showing one in action.
    http://www.falstad.com/circuit/e-peak-detect.html

    Note, once charged, the cap must be discharged (reset). A transistor controlled by the controller could be used to "dump" the charge.

    -Martin
Sign In or Register to comment.