Why does it take 250uS to charge this cap? - Page 1
Forum section: electronics / projects

author: robzy
author_rank: Regular Contributor
timestamp: November 06, 2022, 11:54:34 pm
content: I am playing with an inverter-ish oscillating circuit. See schematic. There is a NOT gate connecting the IN and OUT lines to create the oscillations.I was expecting a ~20kHz even square wave (25uS low, 25uS high). But I'm actually getting a ~3.5kHz uneven square wave (25uS low, 250uS high).I don't understand why one half of the waveform is taking 250uS. Or, in other words, why its taking 250uS for C3 to charge from 1.1V to 2.2V.The Rf1/R2/R3 resistors are creating some hysteresis that should cause C3 to charge/discharge between 1.1V and 2.2V, and I've usedthis calculatorto confirm it should take around 25-35uS for both sides of the cycle.Any ideas of what I might be missing?

author: Benta
author_rank: Super Contributor
timestamp: November 07, 2022, 12:17:11 am
content: The values of R1 and C3 are in outer space.Try with 50k and 1nF and see what happens.There are easier ways to make a 20 kHz oscillator.

author: Andy Watson
author_rank: Super Contributor
timestamp: November 07, 2022, 12:30:24 am
content: QuoteThis ^^^The differential input capacitance of the MCP6562 is quoted as 4pF - that's going to have almost as much effect as your 5pF, C3. And much more effect considering that it is "connected" to the much lower impedance feedback path that israpidlytransitioning between the switching thresholds.

author: robzy
author_rank: Regular Contributor
timestamp: November 07, 2022, 12:40:27 am
content: Re application - this is just one component of a small capacitive rotation sensor that I'm trying to design, so the absolute values that I'm getting from it don't really matter.Its not intended to be an oscillator, but of course it can be analysed as if it were one.Maybe I should've phrased the question from more of an engineering/investigative perspective: What non-idealism would cause the cap to take 250uS to charge but only 30uS to discharge?

author: macboy
author_rank: Super Contributor
timestamp: November 07, 2022, 01:14:05 am
content: Quote from: robzy on November 07, 2022, 12:40:27 amInput offset current (leakage current) of U1 should be looked into. With such high R and small C, many other things can affect it, even leakage currents on the PCB.

author: robzy
author_rank: Regular Contributor
timestamp: November 07, 2022, 01:58:09 am
content: Quote from: macboy on November 07, 2022, 01:14:05 amGood question, and I did put some thought into the choice of comparator (MCP6562 datasheet).The offset (and bias) currents are in the single-digit pA range. These are around 10,000x smaller than the >110nA actual currents in the 10M/5pF network.And, sure, leakage currents are a thing, but I'm not seeing anyway that they could cause a 3.5kHz 85% duty cycle. PCB attached. I think the PCB is reasonable-ish. But am I missing something?

author: Benta
author_rank: Super Contributor
timestamp: November 07, 2022, 12:42:47 pm
content: Quote from: robzy on November 07, 2022, 01:58:09 amA greasy fingerprint somewhere is enough.

author: robzy
author_rank: Regular Contributor
timestamp: November 08, 2022, 12:04:13 am
content: So I've been playing around with a simulation (screenshot attached) and it looks like you're right - PCB parasitic resistance might be the cause.The differential input capacitance doesn't cause uneven PWM cycles, but a few megaohms of resistance to ground does.I guess my options now are:1) Add mechanical guards against leakage currents (e.g. slots)2) Add electrical guards against leakage currents (e.g. guard trace rings driven by an amplifier)3) Lower the impedence of the node (e.g. 1Mohm, but this will cause it to charge much quicker)4) Try a totally different topology (e.g.3 terminal guarded measurement)

author: robzy
author_rank: Regular Contributor
timestamp: November 16, 2022, 09:16:51 am
content: Wait a second - I don't think its leakage currents! What else could it be??I replaced the 10M resistor with a 1M resistor. This means that the impact of the leakage current on the duty cycle should be an order of magnitude lower - but it isn't. The duty cycle has remained essentially exactly the same.I've just remembered that due to chippageddon the comparator chip is actually a TLV9032DR (datasheet) and not the MCP6562 (datasheet), but they are both high performance push-pull comparators.Any ideas why the duty cycle is so far out of whack?

author: Andy Watson
author_rank: Super Contributor
timestamp: November 16, 2022, 11:24:53 am
content: How are you measuring the output? Would you be able to capture high-frequency oscillations at the trip points. The datasheet has a few paragraphs about stability problems - perhaps this is an issue with this particular chip?"Not gate" ? Any more details?Are the labels on the timing diagram refering to the not gate? The input appears to transition shortly before the output.

author: robzy
author_rank: Regular Contributor
timestamp: November 16, 2022, 12:37:54 pm
content: Quote from: Andy Watson on November 16, 2022, 11:24:53 amI have a logic analyser connected to the OUT label in the schematic (i.e. the output of U1A). Another logic analyser probe is connected to the IN label of the schematic (i.e. the input of U1B). The logic analyser shouldn't impact the reading - but maybe I'm missing something?Which paragraph has issues about stability problems? I Ctrl-F'd but couldn't find them. I would've expected that the hysterises would avoid that.Unfortunately I don't have an oscilliscope that I can use for analogue readings of the IN and OUT.Quote from: Andy Watson on November 16, 2022, 11:24:53 amWe can assume that the OUT signal is fed into the input of a 393 NOT gate. And the output from the 393 NOT gate is fed straight back into the IN signal. Expected results: The circuit will oscillate at a 50% duty cycle.In reality its not a 393, but a Raspbery Pi Pico emulating that behaviour. You can see it lag a bit with the 1M resistor (compared to the 10M resistor), but that doesn't explain the uneven duty cycle.I've attached a modified schematic that might make it clearer.

author: robzy
author_rank: Regular Contributor
timestamp: November 16, 2022, 01:16:44 pm
content: HOLY MOLY!I think I just found the problem. There's a mistake with my PCB.When I open up my PCB design in KiCAD I see an important track and via. But I can't see it on the PCB. And I can't see it in the JLCPCB preview.When in doubt I assume that I've screwed up - and I think that's what I've done here! Somehow.R3 and R5 aren't connected to ground. They're floating.Discovered when I was multimetering over the power reservoir capacitor. There was essentially no voltage over it. Because it wasn't connected to ground either.Thank you everyone for your help. Turns out it was a major PEBCAK. Sorry that I didn't figure that out myself. Lesson learned.

author: Andy Watson
author_rank: Super Contributor
timestamp: November 16, 2022, 01:22:33 pm
content: Quote from: robzy on November 16, 2022, 12:37:54 pmJust seen your last post, which explains things. It would have been much easier to find that fault with an oscilloscope.QuoteSection 8.3 and a little bit of 9.1 looks reevant too. And mostly section 7.4.6

author: robzy
author_rank: Regular Contributor
timestamp: November 17, 2022, 03:43:46 am
content: Quote from: Andy Watson on November 16, 2022, 01:22:33 pmIt would have, but its funny, its also that type of thinking that prevented me from solving it earlierA multimeter was enough for me to see that something was going awry here.Quote from: Andy Watson on November 16, 2022, 01:22:33 pmAh gotcha. I am familiar with those section, and couldn't relate it to the duty-cycle issues I was seeing.I was seeing ringing on the OUTPUT line, but that's because I knew I was being bad, and that a resistor on that line would likely clear it up.

author: RoGeorge
author_rank: Super Contributor
timestamp: November 17, 2022, 03:54:58 am
content: - Capital letterSdenotes Siemenshttps://en.wikipedia.org/wiki/Siemens_(unit).- Small lettersis for seconds.

author: robzy
author_rank: Regular Contributor
timestamp: November 18, 2022, 04:36:03 am
content: Good pickup, thanks for the correction.