TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Circuit Design and Applied Optimization (Part 1)

95 点作者 stefanpie超过 3 年前

7 条评论

docfort超过 3 年前
I believe this is supposed to be the first in a series on moving from continuous to discrete optimization, but the EE in me can’t help but point out what I would do in this scenario. It also connects with other interesting aspects of physics.<p>Looking at the governing equations, you can clearly see that if R1 &lt;&lt; R2, then the duty cycle is close to 50%.<p>With that done, I also would have fixed the cap to something that is available. Ignoring R1 for the moment (because I just need to ensure R2 is bigger), I solve for R2 in the frequency equation. It is approximately 72 kOhms.<p>I notice that a nonzero value of R1 is really there to tune the frequency. As long as R1 is much smaller than R2, then the frequency equation is more sensitive to changes in R1 than the duty cycle equation. So I can play with different small values of R1 to tune my frequency to get closer.<p>Finally, since I know that I’m likely using imprecise resistor tolerances, I know that I can pass if I just get close, so I might not need to be picky about R1.<p>In my opinion, this chain of reasoning (effective modeling, function sensitivity wrt parameters, tolerance specs) is what the lab experiment is actually about. Developing circuits that are tolerant to parameter variation is the key to real hardware products. That gives you so much flexibility in price and manufacturer and requires the designer to keep this kind of reasoning frontmost.
评论 #29754609 未加载
评论 #29752921 未加载
评论 #29752811 未加载
评论 #29755270 未加载
neltnerb超过 3 年前
This reminds me of an undergraduate course on diffusion (atomic scale movement of atoms in a solid).<p>There are known formal differential equations that let you solve for the exact diffusion profile given geometry, composition, diffusion rate constants, and temperature (basically). So on the homework they asked us to tell them how long it took for the concentration of the dopant to reach 10% at a 10 micron depth.<p>So of course we all reached for this new math we had learned.<p>We all got it wrong with the professor commenting that &quot;you should have just used the approximate formula [which was trivial algebra], we only know the diffusion rate to an order of magnitude anyway&quot;. This was far more useful as feedback than the 0.2% of our grades we missed credit for.<p>So I look at this essay and am a bit amused at minimizing calculation error to such an extent in a mathematical model when your resistors have a 5% tolerance and your capacitor is probably at 20% tolerance if you happened to have it in a university EE lab. But I do appreciate the fun of doing it this way too if you&#x27;re not in a hurry =)<p>It is crucial for any systems designer to realize that no matter how well you do your math and theory you have to also understand the sensitivity to variability so that you know what math is worth doing and what components we have no choice but to control the tolerances on better.<p>You can find some fancy software for generating filter networks (similar in concept to this except with more discrete math because component values are discrete...) and ask it to show you sensitivity and you can see exactly how much you&#x27;ll screw up your perfectly designed 10th order Chebyshev filter if that last resistor is off by 1%...
评论 #29751510 未加载
评论 #29751222 未加载
hyperman1超过 3 年前
The formula for the duty cycle makes no sense. My rusty brain thinks it should be D=(R1+R2)&#x2F;(R1+2R2), but it&#x27;s multiple decades ago I used it so I might be wrong
评论 #29750985 未加载
xondono超过 3 年前
You might want to look into whatever you are using to render LaTeX, because it doesn’t work on iOS.<p>I’ve had zero problems with Mathjax so far.
评论 #29751546 未加载
评论 #29756865 未加载
hyperman1超过 3 年前
In feynman&#x27;s &#x27;Surely you&#x27;re joking&#x27; there&#x27;s a chapter where he designs some machinery for the army. He gets as guidance to use cogs from the middle of the list of available options, as the smallest or largest parts have all kinds of downsides.<p>This idea works well in all kinds of situations where you have to select parts. I assume it might do well here, too.
评论 #29752183 未加载
mayapugai超过 3 年前
I&#x27;m just here to say this article was such a pleasure to read. I&#x27;ve always relied on intuition to pick good-enough values based on experience. So this rigorous analytical approach to viewing the objective space and picking a reasonable value is refreshing. It&#x27;s ironic and rightfully hilarious that you still had to take a gander and pick a &quot;close-enough&quot; value.<p>I look forward to part 2 where you incorporate the resistor choices that you had. Perhaps also include the statistics of the tolerance into the mix to find the optimal values that we should all be picking for our future 555 timer hijinks.<p>Your academic research work is also very interesting. Suffice to say I&#x27;ll be following you on GitHub :)<p>Cheers and happy (almost) new year!
kragen超过 3 年前
Brute-force search, as kurthr suggested doing, takes under 250ms to find a solution that&#x27;s better on both axes by an order of magnitude, without Scipy, though it still took me 15 minutes to set it up.<p>With R1 = 100Ω, R2 = 330kΩ, C = 2200pF, the frequency error is 7 Hz rather than 39 Hz (0.7% instead of 4%) and the duty-cycle error is 0.008% instead of 0.03%. Probably your capacitor is not going to be stable to 0.7% or precise to 1%, but you can certainly do better than 4%. (Use an NP0&#x2F;C0G capacitor, not an X7R or something. In larger capacitance values you&#x27;d use a film cap instead, but 2200pF is fine for NP0&#x2F;C0G.)<p>You probably ought to measure some capacitors before running the optimization if you&#x27;re only building one circuit, and if you&#x27;re really interested in precision you might put a couple of trimpots across the resistors and adjust it while watching the scope (modern digital scopes can continuously display the frequency and duty cycle, so this is quick). But that will only help if most of the resistance and capacitance comes from components that won&#x27;t drift over time or vary too much with temperature.<p>Multiplying the loss values instead of adding them avoids having to choose weights for them. If you were going to use Newton&#x27;s method or gradient descent, you might want to square them instead of taking the absolute value in order to get faster convergence, but of course that takes you back to solving a continuous relaxation of the discrete component selection problem you actually have. For branch-and-bound search a continuous relaxation can still be a useful thing to do, though.<p><pre><code> &gt;&gt;&gt; R1 = R2 = 1000 &gt;&gt;&gt; import math &gt;&gt;&gt; u, n, p = 1e-6, 1e-9, 1e-12 &gt;&gt;&gt; caps = [a * b * c for a in [1.0, 2.2, 4.7] for b in [1, 10, 100] for c in [u, n, p]] &gt;&gt;&gt; e24 = [1.0, 1.1, 1.2, 1.3, 1.5, 1.6, 1.8, 2.0, 2.2, 2.4, 2.7, 3.0, 3.3, 3.6, 3.9, 4.3, 4.7, 5.1, 5.6, 6.2, 6.8, 7.5, 8.2, 9.1] &gt;&gt;&gt; C = 47 * u &gt;&gt;&gt; 1&#x2F;(math.log(2) * (R1 + 2*R2) * C) # f 10.231879722616762 &gt;&gt;&gt; (R1 + R2) &#x2F; (R1 + 2*R2) # duty cycle 0.6666666666666666 &gt;&gt;&gt; rs = [a * 10**b for a in e24 for b in range(2, 6)] &gt;&gt;&gt; import time &gt;&gt;&gt; s = time.time(); soln = min(((abs(1000 - f)&#x2F;f) * (abs(0.5 - D)&#x2F;D), R1, R2, C, f, D) for R1, R2, C, f, D in ((R1, R2, C, 1&#x2F;(math.log(2) * (R1 + 2*R2) * C), (R1 + R2) &#x2F; (R1 + 2*R2)) for R1 in rs for R2 in rs for C in caps)); time.time() - s 0.2474360466003418 &gt;&gt;&gt; soln (1.0000300746386372e-06, 100.0, 330000.0, 2.2000000000000003e-09, 993.4411045771049, 0.5000757460990759) </code></pre> It would be fair to argue that the nested generator expression there is pretty hard to read, but it didn&#x27;t really take that long to type, the Python REPL is pretty shitty at editing multiline functions, and I didn&#x27;t feel like firing up Jupyter. But this way of writing it is definitely less unreadable and works just as well:<p><pre><code> &gt;&gt;&gt; def search(rs1, rs2, cs): ... for R1 in rs1: ... for R2 in rs2: ... for C in cs: ... f = 1&#x2F;(math.log(2) * (R1 + 2*R2) * C) ... D = (R1 + R2) &#x2F; (R1 + 2*R2) ... yield (abs(1000 - f)&#x2F;f) * (abs(0.5 - D)&#x2F;D), R1, R2, C, f, D</code></pre>