Why using a bipolar transistor instead of a MOSFET to discharge this cap ? - Page 1
Forum section: electronics / beginners

author: JL34
author_rank: Contributor
timestamp: May 07, 2022, 12:10:40 pm
content: Hello,This is a simple moisture sensor device :Entire device operation description is here :https://wemakethings.net/2012/09/26/capacitance_measurement/I try to understand why in this schematic bipolar transistor Q2 and Q3 are used to discharge C1, instead of a mosfet.A simple P-mosfet, placed after R1 and ground, should act like a closed switch when the square wave is in Low state, forcing C1 to completely discharge.Please, can anyone explain this to me?Thanks

author: Zero999
author_rank: Super Contributor
timestamp: May 07, 2022, 12:35:40 pm
content: Most MOSFETs are designed for switching power and will be physically larger, thus have a much higher capacitance, compared to a BJT.

author: vk6zgo
author_rank: Super Contributor
timestamp: May 07, 2022, 02:04:18 pm
content: Quote from: Zero999 on May 07, 2022, 12:35:40 pmThere are plenty of small signal RF MOSFETS around, though they are optimised for linear use rather than switching.

author: CaptDon
author_rank: Super Contributor
timestamp: May 07, 2022, 02:22:46 pm
content: Umm, since R3 goes to ground and not supply it isn't a pull up for the base so I don't see how Q2 would ever turn on? Either the circuit is fubar or that transistor isn't there to discharge the cap?

author: magic
author_rank: Super Contributor
timestamp: May 07, 2022, 02:28:16 pm
content: That's a mistake, R3 should definitely go to 5V or similar.A P-MOSFET source follower wouldn't work for the same reason that PNP doesn't work: the gate needs to be a few volts lower than the source for it to conduct current from source to drain (equivalently, the source needs to be a few volts higher than the gate), so the capacitor wouldn't discharge all the way down to zero when the gate is at zero.The circuit could be much simplified:either connect R1 to a supply rail and drive Q2 (NPN or N-MOSFET) straight from the PWM pin,or make the PWM pin alternate between drive low and weak pullup high or high impedance (and external pullup then).

author: MasterT
author_rank: Frequent Contributor
timestamp: May 07, 2022, 02:29:27 pm
content: There is a diode in series, so it's not necessary to discharge C to zero, and BJT likely to be less costly.

author: DavidAlfa
author_rank: Super Contributor
timestamp: May 07, 2022, 04:04:37 pm
content: Switching a MOSFET at 8MHz isn't easy, as you basically have a RC circuit (mosfet gate is a capacitor) slowing down the switching time, also a 2.5V turn-on threshold below which the mosfet does nothing.A small signal bjt turns from 0.7V, has much lower capacitance, so more adequate here.

author: MathWizard
author_rank: Super Contributor
timestamp: May 08, 2022, 09:03:08 am
content: So what is the point of charging, and even more rapidly discharging this cap anyways, and then just taking averages from a much much longer time constant valued RC on the output ?Why does this sensor use a 8MHz sqr wave ??

author: ledtester
author_rank: Super Contributor
timestamp: May 08, 2022, 12:40:56 pm
content: A look at the latest schematic:https://github.com/Miceuz/PlantWateringAlarm/blob/master/schematics.pngshows that the transistors have been eliminated.Also, I'm sure an 8 MHz square is being used simply because it is easy to generate. Looking at the Makefile:https://github.com/Miceuz/PlantWateringAlarm/blob/master/src/Makefilereveals that the low fuse byte has the CKOUT bit programmed. This sends the system clock out through the CKOUT pin and you don't have to write any code to do that. Pin availability also might have something to do with it since the design is trying to use an attiny24/44/84.You could manually toggle the PB2 pin and a lower frequency would work. The code would be a little trickier to write as you would need to perform an ADC reading while toggling the pin.

author: ledtester
author_rank: Super Contributor
timestamp: May 08, 2022, 06:12:35 pm
content: Some more specifics about the test frequency used...The circuit measures the amount of ripple that passes through the RC filter when a certain square wave is applied to it. The ripple only depends on the ratio of 1/f to R*C (note both are a measure of time). So, if you used a 1 MHz square wave you could achieve the same ratio by increasing R by a factor of 8.

author: JL34
author_rank: Contributor
timestamp: May 10, 2022, 09:24:09 pm
content: Thanks for those replies. I understand better.So I think the main reason to use a BJT instead of a MOSFET is the bigger capacitance on MOSFET gate, that prevent that part of the circuit from working at high frequency.Maybe there is some small signals MOSFET that could work in this case, but compatible BJTs seems to be easier to source.For those asking why working at Mhz frequencies, take a look atthis article. Electric fields dissipate too fast in soils materials to be measured under Mhz frequencies.Quote from: ledtester on May 08, 2022, 12:40:56 pmAnd finally, this explain why choosing 8Mhz in Mhz range. Easiest frequency to have in Mhz, at the beginning of Mhz but far from problematic frequencies to use (hundreds Mhz).