Reading a cycling voltage, capturing the peak value?
Turnbull2112
Posts: 65
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
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.
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