Published: 2011-06-06 | Category: [»] Electronics.
Last Modified: 2014-07-22

When playing with [»] flow sensors last year I have shown that the flow rate is proportional to the pressure drop of a small orifice raised to some power. At that time, I was more focusing on having an output voltage related to the flow rate but not the flow rate itself because the relation between the pressure drop and flow speed was kind of complicated to build out of electronic chips.

I have then spent a few days working on this lately and I will show you some of my results here. The overall idea is to transform an electrical potential V1 into a second electric potential V2 that is a power-of-n function of the former: V2=αV1β where α and β are real, non-negative, numbers. For practical concerns, I will focus on β not too small and not too large.

The (almost) first reaction was to think of a digital solution to the problem: read some voltage, apply a formula or use a translation table (this last solution is fairly general!) and use a digital-to-analog converter to output the resulting potential. This may work in some case, is reliable and reproducible but has two major issues: the limited bandwidth (max 10 kHz with most microcontrollers) and the limited resolution of numeric systems.

So I continued digging into old dusty books to look for answers and I found two Applications Notes about log function using op-amps: the AN30 and AN311. I have added two links at the end of the post so you can enjoy reading them too.

You may wonder what does a log function has to do with our problem? Well actually... everything!

Multiplication, divisions and power-of-n functions can all be broken down to additions, subtraction and scaling when using log and antilog functions. For instance, the product C of two numbers A and B can be written as:

In the case of power function, all we have to do is to compute the logarithm of our voltage, to scale it by β and to compute the antilog of it. The concept is given on Figure 1.

Figure 1

To test the solution I have assembled a derivation of the circuit of AN30 using TL084 op-amps which have small dc offsets and very low leakage current. I was not able to get LM394 matched transistors as suggested by the AN30 paper so I ordered a few samples of MAT12 super-matched transistors from Analog Devices (the retail price of these transistors is prohibitive but they were kind enough to send a couple of them for free). Unfortunately, I could not get the circuit working with these MAT12 transistors so I had to turn back to unmatched BC547 transistors, presumed to belong to the same production batch. This is a clearly inferior solution that has consequences I will describe later but I didn't have much choice.

The circuit schematic is given on Figure 2 and have 0.02<β<2 and 0.11<α<2.57. I have used a [∞] MC1702 sample from Microchip to create the reference voltage within 0.4%.

Figure 2

To test the circuit, I have used a ramp generator and stored both the input and output voltages. From these, I have then compared the actual output with the predicted output of a power function. The result is given on Figure 3.

Figure 3

There is an extremely good match between the actual and predicted outputs with an r2 above 0.999. There is only a slight deviation at the ramp voltages, probably due to saturation effects with either the DAC or ADC circuits.

Finally, the stability of the output for a constant input was tested. The results are given on Figure 4.

Figure 4

The stability is of about 1% even over extended periods of time but, during the test I opened a window to have an air flow in the lab because of the summer heat. This had a strong influence on the stability of the signal which dropped periodically. This is the consequence of using transistors in separate cases.

All the working principle of our log amplifier is based on Eber-Molls law which is temperature dependent. When the transistors are at the same temperature, the effects cancel out but when we are using transistors in separate cases this is no longer true, especially when there is a stream of air around the circuit. This is the exact reason why we should use transistors integrated in the same case such as the LM394 or the MAT12.

Anyway, the circuit works fine and we may use it with satisfaction as long as we have some means to ensure that there are no temperature gradients over the transistors. Maybe a closed box with a fan would do the trick? If, on the other hand, you manage to get the MAT12 implementation working, send me an e-mail!

Resources

The two Application Notes:

[∞] Download the AN30 PDF

[∞] Download the AN311 PDF

[⇈] Top of Page

You may also like:

[»] A Trick to Double ADC Resolution

[»] Thorlabs LD1255R Laser Driver Review

[»] Split Power Supply with the TC962

[»] Flow-rate Controlled Peristaltic Pump

[»] DIY Flow Sensors