The goal of this post is to improve the DC signal of ECv going into the ADC so that ADC sampling is very close to Vpeak
Thanks to Those That Went Before
My usual THANK YOU to Chris Gammell always applies. As I’ve noted many times before, his Contextual Electronics courses have been a terrific way to jump into building circuits on PCBs. Chris’s mentorship has inspired this post.
And almost as usual given the subject matter is a THANK YOU to Ryan at SparysWidgets. The precision op amp half wave rectifier that is used in this design is from the schematics that Ryan makes available for the minieC.
A thank you to Dave Jones for the great video on precision peak detectors. This video really helped gain a better grasp of what is going on in this part of the circuit.
Converting AC to DC
Converting AC to DC involves two steps:
- rectifying the AC signal so that only positive signals pass through
- figuring out a smoothed peak voltage so that ADC sampling has minimum noise due to AC to DC conversion.
The design in the E.C. circuit is a precision half-wave rectifier.
AWG Into Vin+
Half Wave Rectified
Now that the AC signal has been rectified, on to smoothing
The current design uses a 1µF smoothing capacitor (and a 10K R to reset the charging between sampling):
the ripple given this design for rectification has a Vpp of 184mV. Is 184mV good enough?
What is Good Enough?
Let’s say “good enough” is 10% accuracy. What range for Vpp of the ripple is within 10% accuracy? To figure this out, I’m going to look at possible “ideal” values for the E.C. AC Signal based on the range of values for E.C. that are important for healthy growing of herbs and vegetables.
if Vin has a Vpp of 200mV (discussed in this post) the gain loop that measure the ECv has a known resistor of 1KΩ and the variable resistor is at the higher resistance of 12.5KΩ, Gain = 1 + 1KΩ/Rprobe = 1 + 1000/12500 = 1.08. When the probe’s resistance is measured at 200Ω, the Gain = 1 + 1000/200Ω = 6. Thus the Vpp from the Gain loop ranges from a Vpp of .2V*1.08 = .216V when the conductivity is 0.0008S to a Vpp of .2*6 = 1.2V when the conductivity is 0.005S.
Conductivity meters can measure a wide range of conductivity values. I showed this in a chart in a previous post. For hydroponic growing of vegetables and herbs, the E.C. range that this design must accommodate is E.C. = 0.0008S to 0.005S. Since Ω = 1/S, ReC = 12.5K Ω to 200Ω.
So let’s say in the ideal case, if the E.C. was at the low end at 0.0008S, the Vpp is about 216mV. 10% accuracy then is about 21.6mV. if the E.C. was at the high end at 0.005S, the Vpp is about 1200mV. So 10% is about 120mV. Either way, 186mV is too high.
After looking at a bunch of techniques, I opted for a precision peak detector with smoothing that Dave advises in his video. The circuit is also discussed in the 2nd edition of “The Art of Electronics” section 4.15.
Refer to either or both of the sources noted above the image for detailed explanations of the circuit.
Here is an image of the circuit on a breadboard with the 10µF capacitor. There are three op amps. The IC furthest away is one op amp. It is part of the voltage divider circuit to lift the AC signal above negative voltages. The second IC has two op amps. The first one participates in the half wave rectification. The second – along with the diodes and capacitor – participate in the smoothing of the DC signal.
In this image, I used a 10µF capacitor:
I measured Vrms on the scope because I couldn’t find a way/wasn’t sure how to get the Vpeak. Converting from Vrms to Vpeak, Vpeak = SQRT(2)(Vrms) = 1.414*594mV = 840mV. In the image above of the AWG waveform, the Vpeak was 876mV. Inaccuracies such as the quality of the prototype as well as probe measuring technique/probe quality can be the culprit of the differences.
The Vpp of 60mV is well within the 10% accuracy when the Vpp = 2V.
A .01µF capacitor does not hold enough charge to sustain a smooth peak to peak line given the Input Bias and slew rate of the op amps that I am using in the breadboard setup:
Changes to the Design of AC to DC Conversion
I plan to update the design of the Healthy EC Shield to include the “ultra precision peak detector” discussed above. As noted in both The Art of Electronics and Dave’s video, attention needs to be made to the choice of op amps – in particular their Slew Rate and Input Bias and the Capacitor. The sentence that says it all on this subject in The Art of Electronics: …”the choice of capacitor value is a compromise between low droop and high output slew rate.”
The question then is: If we want 10% accuracy in DC voltage sampled by the ADC, what op amp and capacitor will work as far as “the math” that is at a low price (in quantities of 1)?
Using low price as my first filter, the first thing I do is decide on the dialectic of the capacitor. While both The Art of Electronics and Dave Jones’ video recommend a capacitor with a better dialectic than ceramic, I will continue to use a ceramic capacitor. I do not have a feel if the premium cost is worth it. My breadboard results gave me confidence a ceramic capacitor will not get in the way of the 10% accuracy. Especially when ADC samples are averaged after sampling.
The second thing is pick an Op Amp with a “good enough” Input Bias and Slew Rate.
Up until now, I chose an input bias of 2.5pA or below based on reasoning I provided in an earlier post. This is low enough for the sensors – and should be low enough for the second op amp in this circuit design. The op amp that is currently in the design – the MCP6224 (data sheet) has a typical Input Bias of 1pA. Nice!
The op amp’s slew rate needs to be faster than the maximum follow rate of the op amp’s (Vout to Vin-). The maximum follow rate = maximum output current/C. The maximum output current is noted in the data sheet to be 23mA for a 5.5V rail. If we decide on a 1µF capacitor, the maximum follow rate = 2.3 x 10-2 /1×10-6/106 = .023V/µS.
The slew rate for this op amp is .3V/µS. So the Slew rate of the op amp is much faster than the maximum follow rate. A good thing.
What about the Droop caused by the Input Bias sapping the voltage from the capacitor? Droop = Input Bias/C = 1pA/1µF = 10-12 / 10-6/106 = 10-12V/µS …Not much droop!
So that’s what it will be. The op amp’s slew rate (.3V/µS) and Input Bias (1pA) as well as the 1µF capacitor will work well for this scenario.That’s it for now. Thank you for reading this far. Please find many things to smile about.