Any way to change a linear DC voltage to a x^2 response? - Page 1
Forum section: electronics / beginners

author: K3mHtH
author_rank: Regular Contributor
timestamp: November 14, 2019, 02:50:49 am
content: So there's a bunch of ways I can ask this question, but I hope the title makes the most sense. I have a voltage that goes from 0-5V with a linear response and I want it to still go from 0-5V but have a x^2 response.I've found a few circuits that can convert to an exponential response, but that is 2^x correct? That's very drastic and I'm just looking for something to do x^2 - or basically, to multiply the voltage by itself (and obviously pad the output so it doesn't go to +25V). I couldn't even find any circuits that do voltage multiplication... so maybe I'm searching for the wrong terms.

author: james_s
author_rank: Super Contributor
timestamp: November 14, 2019, 03:06:16 am
content: What you need is an op-amp, that's exactly what they were developed to do, perform mathematical operations.

author: edavid
author_rank: Super Contributor
timestamp: November 14, 2019, 03:36:52 am
content: The correct search terms are "squaring circuit" or "analog multiplier".A popular IC you could use is the AD633.However, it's usually best to do it digitally - a microcontroller with ADC and DAC built in will do the job better than any analog circuit.

author: JustMeHere
author_rank: Frequent Contributor
timestamp: November 14, 2019, 03:55:37 am
content: Probably not exactly what you want, but it is a good watch:EEVblog #469 - Cockcroft-Walton Multiplier - YouTube

author: K3mHtH
author_rank: Regular Contributor
timestamp: November 14, 2019, 04:06:13 am
content: Thanks james,do you have any example circuits showing an opamp squaring or multiplying?

author: wraper
author_rank: Unknown
timestamp: November 14, 2019, 04:15:22 am
content: Quote from: JustMeHere on November 14, 2019, 03:55:37 amCompletely unrelated thing.

author: mariush
author_rank: Super Contributor
timestamp: November 14, 2019, 04:26:03 am
content: Probably a microcontroller with ADC and DAC built in, followed by an opamp to do 5x on your 0..5v that the DAC outputs.

author: K3mHtH
author_rank: Regular Contributor
timestamp: November 14, 2019, 06:45:30 am
content: Quote from: mariush on November 14, 2019, 04:26:03 amThanks, but I should have specified that I"d like to keep the design analog.

author: james_s
author_rank: Super Contributor
timestamp: November 14, 2019, 07:02:01 am
content: The datasheet for the AD534 shows you how to configure it as a squarer. It's an old and ridiculously expensive part but should get you pointed in the right direction. Search for analog multiplier circuits and analog squarer and you might find something pretty much ready to go.http://www.analog.com/media/en/technical-documentation/data-sheets/AD534.pdf

author: not1xor1
author_rank: Frequent Contributor
timestamp: November 14, 2019, 07:42:20 am
content: Quote from: james_s on November 14, 2019, 07:02:01 ammost analog multiplier/divider ICs have a typical squarer schematic diagram in their datasheetsAD633 is cheaper than AD534 and AD534 is not recommended for new projects so I guess is going out of productionthe original poster did not specify the required features (i.e. linearity, temperature stability, BW, etc.)if a coarse linearity would be enough he could use cheap discrete components, i.e. those circuit diagrams published during the 70s or use a PWM circuit with a low pass filter

author: T3sl4co1l
author_rank: Super Contributor
timestamp: November 14, 2019, 12:39:34 pm
content: 1. Slide ruleTake the exponent. Apply gain of 2. Take the logarithm.Downsides: requires thermally and electrically matched diodes/transistors to achieve few-% accuracy.Very popular for a time (60s-70s). All the analog methods were popular around then, really.2. Multiplier2a. Multiplier IC. The aforementioned AD633 and a few relatives. Some mixers and OTAs. The ready-made kind are pretty accurate, somewhat noisy, and these days, very special purpose ($$).2b. Guts of a multiplier. Gilbert cell, OTA or other mixer structure. These start with the exp or tanh function of a transistor or diff pair, so you only get the leading (product or square) terms for small signals. The input can be pre-distorted with diodes and stuff (that's how the multipliers do it), extending the range (basically, noise floor) for a given amount of distortion.2c. Weird multipliers. Tektronix patented these, back in the day -- if you take a bunch of diff pairs (each having a tanh function) and wire their inputs in series (I think?) and their outputs in the correct pattern, you can synthesize the general Taylor series of many functions, including other exp-family functions like trig (sin/cos)! The number of stages functions much like the order of the approximation, so you might consider a couple stages for about one hump of sine, or half a dozen stages for a couple cycles, etc.Of course, you can use 1-cos(x) as x^2 over a limited range.2d. PWM multiplier. Create a linear PWM generator (can use a 555 with current sources to make linear ramps, then a comparator to slice the triangle wave into PWM), and drive an analog switch between 0V and VREF. VREF is the same input signal setting PWM. Filter the result. Voila: you've got VREF*VREF. This is a 1- or 2-quadrant multiplier depending on what kind of analog switch you've used, or if you cancel out offsets or not. Downsides: not terrific accuracy (dominated by messy switching edges), slow (bandwidth and delay limited by PWM frequency and output ripple).3. SamplersStart with a periodic function that resembles x^2, and convert the input signal into a time delay synchronized to that function. Sample the function, and optionally filter the output to smooth out the sampling steps.x^2 is not a periodic function, so this obviously only works over some range. You might start with a low-distortion sine wave, and sample part of the peak, in the same way as 2c. uses 1-cos(x) ~= x^2 over a local range.Or we could integrate the input value, making a ramp waveform with variable rate. If we sample that ramp at a proportional time delay, then reset the integrator and repeat, we get \$ \int_0^x x dt = x^2\$.4. Anything else analogAny physical phenomenon that has an even-order nonlinear term (and probably some other well-behaved properties) can be used in ways like the above. Cancel out other terms until the desired term remains. Constant and linear terms can be calibrated out easily (as long as they don't vary with other parameters like temperature or supply voltage). Higher order terms can be canceled in certain ways (e.g. put together two or three multiplier cores with different signs of operands), or simply reduced by keeping the argument small, at the expense of noise floor (since noise is constant but your signal might be 10mV versus 100mV).5. DigitalArguably, this is part of #3 because of sampling, but it's also nonlinear in so many extreme ways (i.e., the implementation of a full digital function plus converters) that it would be kind of silly to model it that way. But yeah, ADC-multiplier-DAC, simple as that!Obvious limitations: number of bits, sample rate. Note that, when you multiply two numbers together, you expect about twice as many digits out. If you sample the two inputs at 12 bits, you ideally need a 24-bit output! This could get pretty extreme -- and not something you're likely to achieve from an analog solution where the noise has constant and proportional terms ruining your ENOB -- but 24-bit DACsare absolutely reasonable. Needless to say, this method offers accuracy far beyond anything an analog solution can offer, and this (and cost) is why analog solutions disappeared in the 70s-80s.Methods?An MCU or FPGA to run the ADCs and DAC, obviously enough. May suffer from inconsistent timings, because of instructions and interrupts and stuff (well, the MCU more so than the FPGA). Depending on how it's written, of course. Use whatever type of hardware you like, that meets the ENOB and sample rate required.On a lower level, a bit-serial ADC and DAC would actually be very easy. You can half-clock the ADCs (so you're producing two half-bits every cycle), multiply them together plus carry (very simple logic, can solve with a couple of gates), then clock the full product bits into the DAC.Excccccccccept... you'll never get LSBs first out of a serial ADC, that would be crazy. You'd have to stack the bits in a shift register, then shift them out in reverse, into the multiplier. And then whatever order the DAC is, which I'd have to look up if they're usually MSB first or last.So you'd actually incur the multiplier logic, a few shift registers, and a state machine to control everything, which is kind of sucky.Or if you get a parallel-out ADC, you can use a selector/mux instead of shift register, which is probably the better way to go. These are a bit antiquated, honestly, though I think they're still in production.So yeah, a couple of lines of Arduino is looking pretty good, eh?Tim

author: Ground_Loop
author_rank: Frequent Contributor
timestamp: November 14, 2019, 12:49:18 pm
content: How about something like this, an overall unity gain Voltage Controlled Amplifier (VCA). Of course you'll need to play with the resistor values to get correct scaling and such. Tie both inputs together to get a squared function.

author: atmfjstc
author_rank: Regular Contributor
timestamp: November 14, 2019, 04:14:36 pm
content: What are you trying to do, specifically? It sounds like you might be trying to normalize/undistort the output of a sensor. In that case, are you sure that squaring it is the ideal transformation? In my experience I have to play with various functions before I get what I need, and often end up with gentler exponents like 1.2, 1.3 etc instead of 2.If you find an exponent different from 2 serves you better, you'll probably need a different op-amp setup (or better yet, just do it digitally). One way to do it would be to take the logarithm of the signal, then amplify this by a tunable "constant", then exponentiating it again. e^(a * ln(x)) = e^(ln(x^a)) = x^a.

author: james_s
author_rank: Super Contributor
timestamp: November 14, 2019, 04:48:21 pm
content: This is actually an interesting topic, at first glance I thought "oh that's easy" then thinking about it further I realized it's not so straightforward. I do like this old analog stuff, I mean they figured out ways to compute all sorts of complex math with analog systems back in the day.

author: atmfjstc
author_rank: Regular Contributor
timestamp: November 14, 2019, 05:42:19 pm
content: Now that I think about it, I remember that FETs have a quadratic dependency of I_D vs V_GS when in saturation. So maybe you could add the threshold voltage to the input voltage, feed it to the gate, and get a quadratic current dependency at the output which you can then trivially turn into a voltage.

author: David Hess
author_rank: Super Contributor
timestamp: November 15, 2019, 03:29:47 pm
content: Quote from: T3sl4co1l on November 14, 2019, 12:39:34 pmThe LTC1043 datasheet shows a charge balancing variation of that idea using two operational amplifiers and an LTC1043 dual switched capacitor building block. One input controls the frequency via a charge balancing voltage-to-frequency converter and the other input controls the amount of charge transferred to the output per cycle. Bandwidth is low but accuracy is excellent and no special provisions or parts for temperature compensation are required.

author: edavid
author_rank: Super Contributor
timestamp: November 15, 2019, 07:08:36 pm
content: Quote from: K3mHtH on November 14, 2019, 06:45:30 amWhy?