Path: csiph.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail From: Christopher Howard Newsgroups: sci.electronics.design Subject: Re: cheap analog square function? Date: Mon, 16 Feb 2026 09:36:05 -0900 Organization: A noiseless patient Spider Lines: 36 Message-ID: <87a4x8cz8q.fsf@librehacker.com> References: <877bslbhl7.fsf@librehacker.com> <10mlh77$1q347$1@dont-email.me> <87ms1cd54a.fsf@librehacker.com> <10mnufq$2j3a8$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain Injection-Date: Mon, 16 Feb 2026 18:36:07 +0000 (UTC) Injection-Info: dont-email.me; posting-host="fde006511a491a157278e4a59427dd35"; logging-data="1144371"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/s7M7TK5js/H1ApXxA+hVvrYebj5khpLU=" User-Agent: Gnus/5.13 (Gnus v5.13) Cancel-Lock: sha1:8K/CI4H7rmFP48nakyPixKjS37A= sha1:z31QNdqtUcLow6QBU5jWgNwqlVU= Xref: csiph.com sci.electronics.design:740501 > JL has beaten me to it. In full detail: imagine the sawtooth or > triangle wave swings between 0V and 1V and is nicely linear, i.e. > straight sloped. The comparator in my circuit (A) compares that with > the input voltage to be squared Vx. When Vx is 0 the output is always > low; when Vx is 1V the output is always high; and when Vx is 0.5V the > output is toggling with 50% duty cycle. This pulse width modulation > can then be used to switch the desired output between input Vx and 0V > so when Vx is 0V then output is zero, when Vx is 1V the output is Vx > and when Vx is 0.5V the output is 50% of the time that 0.5V and 50% of > the time zero or in other words an average of 0.25V. The low pass > filter averages the pulsating output to a steady level. > > In circuit (A) the switching isn't done by an explicit analog switch > but by shorting the output to ground - very conveniently done by > choosing a comparator with open-drain output. > > I had multiple square and root channels so it made sense to have one > common triwave generator serve them all. Instead of 1V full scale > unity I scaled to use 5V so ordinary comparators can be used. If you > had no other need for a sawtooth/triwave elsewhere one could build a > self-oscillating PWM generator and use that to drive the chopper. Let > me know if you want that detailed more fully. > Okay, thank you. I think I grasp the core idea now. My THAT comes with a few comparators, but already less than I need for other things, so I don't want to use those. But I've got a lot of 741 op amps to spare. I do have access to a good benchtop signal generator, which I could use for generating the triangle wave. But having a separate triangle wave generator built in to the project also has some appeal. -- Christopher Howard