Author Topic: Any way to change a linear DC voltage to a x^2 response?  (Read 1861 times)

0 Members and 1 Guest are viewing this topic.

Offline K3mHtHTopic starter

  • Regular Contributor
  • *
  • Posts: 98
  • Country: ca
Any way to change a linear DC voltage to a x^2 response?
« on: November 14, 2019, 02:50:49 am »
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.
 

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21611
  • Country: us
Re: Any way to change a linear DC voltage to a x^2 response?
« Reply #1 on: November 14, 2019, 03:06:16 am »
What you need is an op-amp, that's exactly what they were developed to do, perform mathematical operations.
 

Offline edavid

  • Super Contributor
  • ***
  • Posts: 3464
  • Country: us
Re: Any way to change a linear DC voltage to a x^2 response?
« Reply #2 on: November 14, 2019, 03:36:52 am »
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.

« Last Edit: November 14, 2019, 03:40:13 am by edavid »
 
The following users thanked this post: wraper

Offline JustMeHere

  • Frequent Contributor
  • **
  • Posts: 827
  • Country: us
Re: Any way to change a linear DC voltage to a x^2 response?
« Reply #3 on: November 14, 2019, 03:55:37 am »
Probably not exactly what you want, but it is a good watch:

EEVblog #469 - Cockcroft-Walton Multiplier - YouTube   

 

Offline K3mHtHTopic starter

  • Regular Contributor
  • *
  • Posts: 98
  • Country: ca
Re: Any way to change a linear DC voltage to a x^2 response?
« Reply #4 on: November 14, 2019, 04:06:13 am »
Thanks james,
do you have any example circuits showing an opamp squaring or multiplying?
 

Offline wraper

  • Supporter
  • ****
  • Posts: 17952
  • Country: lv
Re: Any way to change a linear DC voltage to a x^2 response?
« Reply #5 on: November 14, 2019, 04:15:22 am »
Probably not exactly what you want, but it is a good watch:
Completely unrelated thing.
 
The following users thanked this post: tooki

Online mariush

  • Super Contributor
  • ***
  • Posts: 5171
  • Country: ro
  • .
Re: Any way to change a linear DC voltage to a x^2 response?
« Reply #6 on: November 14, 2019, 04:26:03 am »
Probably a microcontroller with ADC and DAC built in, followed by an opamp to do 5x on your 0..5v that the DAC outputs.
 

Offline K3mHtHTopic starter

  • Regular Contributor
  • *
  • Posts: 98
  • Country: ca
Re: Any way to change a linear DC voltage to a x^2 response?
« Reply #7 on: November 14, 2019, 06:45:30 am »
Probably a microcontroller with ADC and DAC built in, followed by an opamp to do 5x on your 0..5v that the DAC outputs.

Thanks, but I should have specified that I"d like to keep the design analog.
 

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21611
  • Country: us
Re: Any way to change a linear DC voltage to a x^2 response?
« Reply #8 on: November 14, 2019, 07:02:01 am »
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
 

Offline not1xor1

  • Frequent Contributor
  • **
  • Posts: 716
  • Country: it
Re: Any way to change a linear DC voltage to a x^2 response?
« Reply #9 on: November 14, 2019, 07:42:20 am »
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

most analog multiplier/divider ICs have a typical squarer schematic diagram in their datasheets
AD633 is cheaper than AD534 and AD534 is not recommended for new projects so I guess is going out of production

the 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
 

Offline T3sl4co1l

  • Super Contributor
  • ***
  • Posts: 22436
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: Any way to change a linear DC voltage to a x^2 response?
« Reply #10 on: November 14, 2019, 12:39:34 pm »
1. Slide rule

Take 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. Multiplier

2a. 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. Samplers

Start 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 analog

Any 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. Digital

Arguably, 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 DACs are 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? :P

Tim
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 

Offline Ground_Loop

  • Frequent Contributor
  • **
  • Posts: 674
  • Country: us
Re: Any way to change a linear DC voltage to a x^2 response?
« Reply #11 on: November 14, 2019, 12:49:18 pm »
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.
« Last Edit: November 14, 2019, 12:52:15 pm by Ground_Loop »
There's no point getting old if you don't have stories.
 

Offline atmfjstc

  • Regular Contributor
  • *
  • Posts: 121
  • Country: ro
Re: Any way to change a linear DC voltage to a x^2 response?
« Reply #12 on: November 14, 2019, 04:14:36 pm »
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.
 

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21611
  • Country: us
Re: Any way to change a linear DC voltage to a x^2 response?
« Reply #13 on: November 14, 2019, 04:48:21 pm »
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.
 

Offline atmfjstc

  • Regular Contributor
  • *
  • Posts: 121
  • Country: ro
Re: Any way to change a linear DC voltage to a x^2 response?
« Reply #14 on: November 14, 2019, 05:42:19 pm »
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.
 

Online David Hess

  • Super Contributor
  • ***
  • Posts: 17428
  • Country: us
  • DavidH
Re: Any way to change a linear DC voltage to a x^2 response?
« Reply #15 on: November 15, 2019, 03:29:47 pm »
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).

The 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.
 
The following users thanked this post: T3sl4co1l

Offline edavid

  • Super Contributor
  • ***
  • Posts: 3464
  • Country: us
Re: Any way to change a linear DC voltage to a x^2 response?
« Reply #16 on: November 15, 2019, 07:08:36 pm »
Thanks, but I should have specified that I"d like to keep the design analog.

Why?
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf