Compute analog signals as functions of two othe signals - Page 1
Forum section: electronics / projects

author: Javier
author_rank: Contributor
timestamp: December 08, 2014, 10:05:34 pm
content: Hi everybody,I would like to hear your opinion with respect to the following architecture for a supposedly easy task. I need to “compute” the value of two voltages depending on two signals. Sounds easy, but I can't think of any easy solution.Details:I need to construct a circuit, that computes two voltages (U1, U2) depending on two analogue signals (S1, S2). Since the relationships U1 = f(S1, S2) und U2 = f(S1, S2) are nonlinear, I thought of using an EEPROM. To keep the system as simple and cheap as possible I thought of not using a uC or an FPGA for this task.So I thought about this scheme:http://img5.fotos-hochladen.net/uploads/ansatz9iszena2j5.jpgBut I realized that ADCs, DACs and EEPROMs have mostly a serial interface, and the serial communication would complicate what I though was a simple solution.Does somebody have an idea, how to tackle this problem? I can imagine, that this sort of things are normally done for calibration of sensors but I can't find any good reference.Cheers!Javier

author: BennVenn
author_rank: Regular Contributor
timestamp: December 08, 2014, 10:20:53 pm
content: Hi Javier,ADC's, DAC's and EEPROM are all available in both serial and parallel architecture. Some/most parallel DAC’s will function fine without a clock (from experience), as will EPROMS (never tried alternating address lines without strobing /RW or /CE so not sure with EEPROMS). ADC’s generally require a clock but assuming the PROM and DAC’s don’t then it would simplify the design and a simple oscillator feeding only the ADC will suffice.Considering the cost of ADC’s DAC’s and EEPROM, a MCU would be the far cheaper option as some will have all these peripherals inbuilt.

author: Alex Eisenhut
author_rank: Super Contributor
timestamp: December 08, 2014, 10:31:46 pm
content: How fast? What voltages? Negative? How non linear? Maybe all you need is simple diode-shaping, or a multiplier.

author: dannyf
author_rank: Super Contributor
timestamp: December 08, 2014, 11:18:09 pm
content: -thought of using an EEPROM. To keep the system as simple and cheap as possible I thought of not using a uC or an FPGA for this task.-How did you go from computing in analog to using eeprom, uc or fpga.Maybe you have some interesting definition for analog.

author: ajb
author_rank: Super Contributor
timestamp: December 08, 2014, 11:55:50 pm
content: It's possible to do addition, subtraction, multiplication, division, integration, logarithms, exponentiation, and more all in the analog domain. Perhaps you have some strange arbitrary function that is best handled by a look up table, but otherwise there's a good chance you can keep it all analog. You might find this a good place to start:http://www.ti.com/ww/en/bobpease/assets/AN-31.pdf

author: T3sl4co1l
author_rank: Super Contributor
timestamp: December 09, 2014, 01:11:16 am
content: The old school... well.. the middle school method might be parallel ADC, EPROM and DAC as mentioned. This might be configured with a 2D array of entries, and the top bits driven by one ADC and the lower bits driven by another. The ADCs have to be clocked (depending on architecture; SAR ADCs have always been quite common, so you'd need a clock divider to strobe the sample event as required; flash ADCs are either asynchronous or single cycle, but uncommon in a large number of bits), but as long as the digital outputs are stable, additional logic isn't necessary (the EPROM and DAC work asynchronously, unless you specifically get a clocked one). Though you could add a latch after the EPROM, delayed by half or one cycle after the ADC conversion, to reduce output glitches.Typical performance might be, 2 x 8 bit ADCs for a 16 bit address = 64kB (512kb) EPROM with 8 bits output (or two strapped in parallel for low and high bits and up to 16 bit DAC).As mentioned, the problem is, back in the day -- this is a very 80s solution, I would guess -- this was the only way to do a truly arbitrary function. EPROMs were slow to write, slow to erase, and not cheap. But that was the only reusable technology, so that's what development used.Since then, we've got Flash memory, which is a snap to reprogram. But we've also got a whole pile of logic available on top of that memory, namely MCUs and FPGAs. These are insanely cheap besides (well, give or take), with the main disadvantage that, software is slow, so you won't get as fast performance. That said, a very average case like an ATmega644 with 64k of Flash (not all of it is available for the table, a teeny bit in the corner is still needed for the program itself!) could run two serial ADCs from the SPI/USART ports, interleaved, pulling in maybe 0.5MSa/s each; the program merges the bits together (say, taking the top 8 bits of each and producing a 16 bit address), reading from program memory and spitting it out a DAC (which would require a 3rd channel to be interleaved, which I don't think exists, so you're kind of stuck on that -- the overall performance might have to be 1/2 to 1/3 depending on how you organize the IO). Program execution should be a minimal cost, running near rated clock speed. (Which is the main difference to the EPROM case -- you can churn data however fast you want, but those ADCs need cycles to convert, and the EPROM is going to take some 200ns or so to decide on what its output is going to be.)Of course, being an analog dweeb, I'd be interested to know what kind of function is being computed here. If it's not too bad, there are ways to solve it. Even if it has to be adjustable.The most familiar function like this that comes to mind, calculating engine timing. Number of bits is not large, so you just put the table in the MCU and be done with it.Tim

author: f5r5e5d
author_rank: Frequent Contributor
timestamp: December 09, 2014, 05:03:06 am
content: what is the max frequency to follow, required sample rate, latency, bit resolution, channels?specs drive everything - at industrial control/motion/audio frequencies single chip uC can do a lot - 1 Ms/s ADC, DAC, 100+ MHz clock, Mb of memory can be had for ~ $10 (Au or US) all functions integrated on chip - only need to add op amps/filters on the analog end

author: Javier
author_rank: Contributor
timestamp: December 09, 2014, 07:09:31 am
content: Hi! thanks a lot for all your answers. It's interesting to see that there is no "standard" obvious way of tackling this problem.Here are some more details:Quote1.- The inputs S_1 and S_2 change at 10 kHz frequency, so the system should give an stable output at that rate2,3.- Voltages are in prnciple 0-5V4.- It´s a second order polynomial in S_1 and S_2:U_1 = a0 + a1 * S_1 + a2 * S_2 + a12 * S_1 * S_2 + a11 * S_1^2 + a22 * S_2^2U_2 = b0 + b1 * S_1 + b2 * S_2 + b12 * S_1 * S_2 + b11 * S_1^2 + b22 * S_2^2In principle the coefficients a_i, b_i depend on temperature, but the dependance is smallQuoteThe signals at the input and at the output must be analog, the computation itself need not be.QuoteIt´s a second order polynomial in S_1 and S_2 for the calibration of a test setup. In principle the coefficients a_i, b_i depend on temperature, but the dependance is small so that I can neglect it in a first attempt.U_1 = a0 + a1 * S_1 + a2 * S_2 + a12 * S_1 * S_2 + a11 * S_1^2 + a22 * S_2^2U_2 = b0 + b1 * S_1 + b2 * S_2 + b12 * S_1 * S_2 + b11 * S_1^2 + b22 * S_2^2I thought about implementation with Opamps, but given the amount of sums and multiplications it seemed to me that I would need too many ICs in my boardQuoteThe input S_1, S_2 change at 10 kHz frequency, 8 bit resolution ideally, but even 4 bit could be acceptable

author: Jeroen3
author_rank: Super Contributor
timestamp: December 09, 2014, 07:15:28 am
content: You either go for a vastly complicated analog computer with tons of opamps.Or you get a mcu, with two adc's, two dacs, and some free time to run your calculation.You'd need a sampling rate of at least 40 KHz, and still be able to run your lookup table or calculation.Is there a limit on the systems delay? (In....Out?)Let an quality audio signal go 48 KHz (or better), find a chip capable of audio processing.Possibly an audio dac/adc.

author: babysitter
author_rank: Frequent Contributor
timestamp: December 09, 2014, 09:03:25 am
content: I once helped a ham with a similar project.He was making a gated power meter for a add-on readout on a RF sweeper, showing the power level in dBm at a marker position.He had a ADC with parallel out and wanted to drive 7seg LEDs - asked me to program a microcontroller for him.After he mentioned the ability to program EPROMs we settled for connecting the ADC to the adress bus and the segments to the data lines.My only task was to convince him that he planned way to much EPROM space and suggest him to put a selector switch on some data lines to switch between dBm, mW, dbµV and mV, and write a little turbo pascal program to calculate the lookup table.So I only had to send a few BIN files by packet radio instead of a snail mail envelope with a µC...

author: tggzzz
author_rank: Super Contributor
timestamp: December 09, 2014, 11:10:48 am
content: Quote from: Javier on December 09, 2014, 07:09:31 amAny purely analogue solution would have to include an analysis defining the sensitivity to non-ideal components, e.g. tempco, offsets.Any partially digital solution would have to include an analysis defining the sensitivity to quantisation (especially 4 bit!) and ADC/DAC non-ideal behaviour.

author: johnwa
author_rank: Frequent Contributor
timestamp: December 09, 2014, 11:32:57 am
content: Quote from: Javier on December 09, 2014, 07:09:31 amThat shouldn't be too hard - you will need three multipliers: One for S_1 * S_2, and a couple for squaring S_1 and S_2. Then, a couple of op-amps configured as inverting summers to calculate U_1 and U_2, and another couple of inverting amps to turn it back up the right way, if you care about that. I assume all the coefficients are positive? Also, you have not mentioned terms in S_1^2 * S_2, S_1 * S_2^2, and S_1 ^ 2 * S_2 ^ 2 - i guess these are not required?Have a look at GK's thread on Rossler chaotic systems if you need some ideas.Having said that, I suspect that a digital solution will be more practical, especially if the coefficients will need frequent adjustment!

author: f5r5e5d
author_rank: Frequent Contributor
timestamp: December 09, 2014, 02:03:53 pm
content: just one of many integrated digital options:http://www.microchip.com/wwwproducts/Devices.aspx?product=dsPIC33FJ64GP802$5 in singles for pdip10/16 bit 4xadc/2xdac, 40 Mips, multiply accumulateis supported by $35 microstick dev boardneed add your own op amp filters, level shifterssome learning curve if you've never programmed

author: T3sl4co1l
author_rank: Super Contributor
timestamp: December 09, 2014, 03:30:06 pm
content: What do you mean by 10kHz rate -- are these sinusoidal repetitive signals, or arbitrary bandwidth up to 10kHz?If they are sinusoidal, you may be able to make use of trigonometric identities to simplify the math, and more crude multiplication functions like a single or double balanced mixer (good linearity, but makes harmonics).For low bandwidth purposes, PWM is often used. Some PFC controller chips do this internally. Others just do the crappy way -- an 8 level multiplying DAC, or really, just a handful of comparators, resistors, and analog switches for more resistors.If accuracy really is so bad that you could use 4 bit converters, you can definitely do it by stacking diodes and adding up the Vf's -- poor man's log converter. It'll have a serious tempco, but hey, maybe that's what you need anyway? Throw some thermistors at it and see what plops out.Tim

author: edavid
author_rank: Super Contributor
timestamp: December 09, 2014, 04:15:38 pm
content: Quote from: Javier on December 09, 2014, 07:09:31 amIf you have 2 8-bit inputs, there's no reason to consider anything other than a lookup table.

author: mikerj
author_rank: Super Contributor
timestamp: December 09, 2014, 05:00:02 pm
content: An ATxmega8E5 has two 12 bit DACs, a whole bunch of 12 bit ADC inputs and plenty of memory for a lookup table for just over 1 USD.

author: Javier
author_rank: Contributor
timestamp: December 10, 2014, 06:43:05 am
content: I meant arbitrary bandwidth up to 10kHz. Do you mean outputting a PWM signal into a capacitor ? Then I don't understand how to get the analog output.Thanks for your interest!Quote from: T3sl4co1l on December 09, 2014, 03:30:06 pm

author: T3sl4co1l
author_rank: Super Contributor
timestamp: December 10, 2014, 09:39:16 am
content: You can make PWM by comparing your 0-5V input signal with a linear ramp (triangle or sawtooth), which produces proportional 0-100% PWM. The PWM is buffered by a one-bit DAC with VREF set by the other input, thereby multiplying the signals. This is finally filtered. Not with just a capacitor, but with a suitable filter (RC, LC or active) to preserve "DC" wave shape while removing the PWM switching. PWM frequency and filter cutoff depend on tolerable output ripple and desired accuracy.Same thing works in steps rather than pulses, if you ADC one signal, and feed the other to a multiplying DAC's VREF. This is practical up to 300kHz or so, where the self-capacitance of the DAC's divider (R chain or R-2R network) impairs bandwidth, and usually in a code-dependent manner. There are also "digital pots", which usually have better bandwidth, at a little expense to linearity (usually the DNL is poorer I think, but not bad enough to be non-monotonic or anything). Which are usually SPI interface, so more handy for MCU control than otherwise.Tim

author: tggzzz
author_rank: Super Contributor
timestamp: December 10, 2014, 10:24:24 am
content: Quote from: edavid on December 09, 2014, 04:15:38 pmProbably. But you'll still have to do a numerical analysis of the accuracy, and you may find that you need a more bits for the internal calculations. See DSP processors and floating point engines for examples.One illustration of the problem is that if you have two numbers, X and Y, each +-1%, then X+Y is also +-1%. But X-Y certainly isn't.Another aspect is that computer arithmetic is neither transitive nor associative, except for subsets of the calculations. See any textbook on numberical analysis, orhttp://people.ds.cam.ac.uk/nmm1/Arithmetic/index.html

author: edavid
author_rank: Super Contributor
timestamp: December 10, 2014, 03:54:58 pm
content: Quote from: tggzzz on December 10, 2014, 10:24:24 amNone of that is an issue. You calculate the lookup table on a real computer and tweak it however you want.

author: tggzzz
author_rank: Super Contributor
timestamp: December 10, 2014, 04:48:09 pm
content: Quote from: edavid on December 10, 2014, 03:54:58 pmFirstly, given the nature of the question asked by the OP, I am unconvinced that the OP has considered it. FSecondly, if you have done that computation and found the answers are correct, then you have already done the numeric analysis.