July 2016, Author: Adrian Colomitchi
First thing, where's the capacitive probe in this schematics? The only one that fits the bill seems to be `C_5` - a plausible value and connected as the capacitor of a NE555 astable circuit.
So far, so good... astable, using a LMC555 (a CMOS equiv of NE555, able to go to 2MHz), will form a train of pulses... yes, OK... they say their sensor will output an analog value - which, of course, will need calibration, here's an example of values one may encounter.
So they'll need to convert the frequency to voltage somehow... umm-hmm... hang on, I'll let aside that `C_3` (the one that's supposed to provide the output signal as voltage) is 'naked' if connected to anything but a huge impedance, but what's the group I circled in red supposed to do?
It's not a low-pass filter (the `D_1` diode would stop the discharge of the `C_3` by the 555), it's not a peak-detector (what would `R_1` do in a peak detector?).
Looks like an integrative circuit with losses - the astable's pulses would be integrated by the `C_3` through `R_2`, while `C_3` will slowly discharge all the time through `R_1`. Perhaps this is meant to smooth/average the output voltage?
But that's not all... the plot thickens... the astable will be pumping pulses like crazy - with the values on the schema, the pulse period will be `ln(2) * (R_3+2*R_4) * C_5 = 1.15μs`. That's close to 900kHz guys.
Meanwhile, the `R_2` and `R_1` have quite disproportionate values, so `C_3` will charge quickly through `R_2` and diiissschaaaarge sloooowlyyy through `R_1` (`D_1` blocks the discharge by the 555 through `R_2`).
It's likely that `C_3` will be close to the max value unless the astable's duty cycle would drop low enough to allow a significant discharge. But... but... the astable's duty cycle is already fixed by the `R_3` and `R_4`, so what gives?
And this is the WTH topic to be examined here
The stage is set, let me try to derive the output voltage as a function of the probe capacitance, maybe my intuition is wrong and the maths will provide the correction.
Start your Maxima and describe the equations of the circuit for the "up" part of the cycle:
e1: i(t)=i1(t)+i2(t); e2: Vs=R2*i(t)+Vx(t); e3: Vx(t)=R1*i1(t); e4: 'diff(Vx(t),t)=i2(t)/C3;then solve the system:
After a bit of massaging, the solution for the output voltage becomes:
`V_x(t) = R_1/(R_1+R_2) * V_s*(1-e^(-((R_1+R_2)*t)/(R_1*R_2*C_3))) + V_x(0)*e^(-((R_1+R_2)*t)/(R_1*R_2*C_3))`
With the self-explanatory notation of: `R_1∥R_2 = (R_1*R_2)/(R_1+R_2)`, the expression becomes:
(before you jump on my throat telling "that's no way `C_3` can use `R2` to discharge because `D_1`, so something must be wrong": no, it's nothing wrong, that's the mathematical expression as a superposition of two terms of the DE - that's "differential equations". In reality, the already existing charge/voltage on `C_3` will cause a slower current caused by the `V_s`, which is equivalent with a "charge" current as if `C_3` would be empty minus a "discharge" current as if `V_s` would be 0)
`V_x(t_1+t_2)=V_x(t_1)*e^(- t_2/(R_1*C_3))=(V_s* R_1/(R_1+R_2) * (1-e^(-t_1/(R_1∥R_2*C_3))) + V_x(0)*e^(-t_1/(R_1∥R_2*C_3)))*e^(-t_2/(R_1*C_3))`
Let massage it a bit to put into evidence the contribution of the initial voltage separately from the contribution of the charge injected during the "up" stage of the astable.
With the note that both of them are subunitary (be my guest, check), the output voltage after a full cycle becomes:
Right! So, what after 2 such cycles? Well simple:
`V_x(2*(t_1+t_2)) = \mathbf(A) * V_s + mathbf(B) * V_x(t_1+t_2)`; or
`V_x(2*(t_1+t_2))=\mathbf(A) * V_s +mathbf(B) * (\mathbf(A) * V_s + mathbf(B) * V_x(0))`
`V_x(2*(t_1+t_2))=\mathbf(A) * V_s ( 1 + mathbf(B))+ mathbf(B)^2 * V_x(0)`
After 3 complete cycles? Well, of course
After n complete cycles? Elementary, my dear, high school stuff:
So, after n cycles, the output voltage becomes:
After a sufficient number of cycles (big n), because `mathbf(B)` is subunitary, the output voltage becomes:
Good, so the steady output voltage of the circuit (after enough "up/down" cycles) is:
Before replacing the `\mathbf(A)` and `\mathbf(B)` constants, let's try to substitute the `t_1` (duration of the "up" stage of the astable) and `t_2` (duration of the "up" stage).
The astable is a 555 classic so, using the component references of the original schematic, one gets
... finally, the glorious formula for the output voltage of the "mistery circuit" as a function of the probe capacitance (`C_5`):
As it stands though, with the values specified by the schematics ( `C_5 = 470`pF, `C_3 = 10`μF, `R_4=1.6`K, `R_1=1`M), the `e^(- ln(2) * C_5/C_3*R_4/R_1)` is so close to `1` somebody would need an electron microscope to discerne between them (the value is `0.999999479`).
Which confirms my intuition: due to the `D_1` diode, the `C_3` capacitor can only discharge through `R_1`, which is so humongous that one would never see anything but saturation, no matter how the capacitance of the soil moisture probe would vary.
Actually, the capacitance of the soil moisture probe would need to be in the order of `R_1/R_4 * C_3` for the circuit as presented by the schematic to 'feel' something. Let me translate this: the moisture probe capacitance would need to be somewhere in the region of 10 to 100μF for the circuit to feel something different than saturation
Finally, to prove this, fire up Maxima and let's examine `vout = V_(output)/V_s` as a function of `x = C_5/C_3` with the values specified by the schematics:
par(r1,r2):=r1*r2/(r1+r2); y(r1,r2,r3,r4,x):=exp(-log(2)*x*((r3+r4)/par(r1,r2)+r4/r1)); vout(r1,r2,r3,r4,x):=r1/(r1+r2)*(exp(-log(2)*x*r4/r1)-y(r1,r2,r2,r4,x))/(1-y(r1,r2,r2,r4,x)); plot2d(vout(1e6,1e4,330,1600,x), [x,1e-5,1200], [label, ["C5/C3", 800, 0.1], ["Vout/Vs", 100, 0.9]]);
And there you have it: until the `x = C_5/C_3` doesn't step into the 10-100 range, the `V_(output)/V_s` will stick pretty close to `1`. Actually one will need...(let me see)
find_root(vout(1e6,1e4,330,1600,x)=0.5,x,1e-5, 1200);... yeap, `x = C_5/C_3 = 616.0279` to have `V_(output)/V_s = 0.5`. That means a capacitance of the moisture probe to a value of 616μF. If somebody actually manages to do this with a coplanar capacitor etched from a 25 x 100mm (or 1" x 4") get that person a Nobel award: the energy storage solution of the future is here and cheap
Important - don't try to DIY the circuit with the values presented in the schematic: it will not work. In spite of their pretention of "open source hardware", the DFRobot guys seems to be sloppy (and I'm considering "honest mistake" circumstances here) and put up a wrong schematics.
Yes, of course, there is the possiblibity that I made a mistake in the computations above - I don't think so but, if you find an error, please drop me an email on acolomitchigmail.com, thanks
Also important (for me at least): yes, that part may work as a poor's man "frequency to voltage converter", but not with the values as presented by the schematic.
Use the (8) formula group to get the output voltage as a function of frequency and duty cycle.