Arduino Ultrasonic Anemometer Part 3: Analog Circuit

Today I’ll go through the details of the analog cirquit. Click here for an overview over this series of posts on the anemometer project: https://soldernerd.com/arduino-ultrasonic-anemometer/

_MG_1026
The analog board ready to be connected

This is what I would consider the heart of this wind meter. This is where the received signal is amplified and processed so the overall accuracy and reliability of the entire project really depends on it. The functionality of this board can be summarized as follows:

  1. Amplify the received signal
  2. Generate a digital signal when the amplitude exceeds a given threshold (envelope detector)
  3. Generate a digital signal every time the received signal crosses zero (zero crossing detector)
  4. Measure the temperature
20140930_223527
The finished analog circuit on the test bench

This circuit runs on the +5V rail generated on the digital board. There’s no need for a negative voltage here, the +5V is all we need. The input to the amplifier (i.e. the received signal) also comes straight from the digital circuit. The 3 outputs temperature (analog), zero-crossing detector (digital) and envelope detector (digital) are all connected to the Arduino Uno. I’ll go through each of the four parts now.

_MG_1025
Analog board with the Arduino on the left and the digital circuit below.

Amplifier:

Just as Carl, I have used two tuned amplifier stages. Each stage uses a NPN darlington pair built from two discrete transistors. The parallel LC tank at the collector determines the resonant frequency of 40kHz as well as the bandwidth. Check out this wiki page http://en.wikipedia.org/wiki/Common_emitter or google for ‘degenerated common emitter amplifier’ if you’re not familiar with this topology.

_MG_1027
Close-up of the amplifier

 

The main difference to Carl’s design is that it’s running from 5 volts instead of 8 which eliminates the need for an extra rail.

I’ve added a 10k resistor from the emitter of the first transistor to the emitter of the second. This is often done to to enable Q1 to turn of Q2 faster. It’s probably not necessary at our low frequency but leaving it away later is much easier than adding it.

I’ve also added an extra resistor to the emitter degeneration. There is a bypassed resistor as with Carl’s design but I’ve added another resistor in series that can be used to reduce the gain. I’ll use a zero-ohm resistor at the beginning and replace that with whatever is needed to get just the right amount of gain. Thinking of it, it would have been smarter to put the gain setting resistor in series with the bypass capacitor only. That way I could adjust the gain without affecting the biasing. But that’s something for the next version.

For simplicity, I’ve biased the input of both stages to half the supply rail or 2.5 volts. The emitter will be two diode drops lower at around 1.2 volts. That should be sufficient to get a stable quiescent current over a reasonably wide temperature range. Speaking of quiescent current: The 330 ohms emitter resistor will yield a quiescent current of around 3.5mA.

I’ve made a rookie error on the LC tank. Carl had used a 470uH coil with a 33nF capacitor which gives just the right resonant frequency. He reports the DC resistance of his coil to be around 10 ohms which gives a Q-factor of around 10 – not great but sufficient. I didn’t have a 470uH inductor around but there were a few 47uH ones from a previous project. They had a DC resistance of slightly below 1 ohm so the Q-factor would also be just above 10. So I decided to use them, together with a 330nF cap to get the right frequency. Onetenth of the inductance, one tenth of the resistance, ten times the capacity. Same frequency, same Q, just perfect I thought. And yes, the resistance across the LC tank does have the same shape. But it only has one tenth of the value. So I got very little gain out of the amplifier when I first turned it on and had to correct this later. Lesson learned.

Envelope detector

I’ve changed little for the envelope detector. It still uses a two-pole active low-pass filter. The values have changed somewhat but the time constants and cuttoff frequencies remain similar.

_MG_1028
Close-up of the envelope detector

I’ve used a 1M plus 47k resistor at the input before the diode. At a 5V supply this yields a voltage of about 0.2 volts which just about compensates for the voltage drop over the schottky diode.

I’ve added a 10k pot to adjust the gain of the active filter. So there are two parameters you can adjust without grabbing your soldering iron: filter gain and threshold voltage.

I have included a (positive) feedback resistor across the comparator just in case I need some extra hysteris but don’t plan to use one unless tests show it’s really needed. I found that most of the time the comparator itself has enough hysteris of its own. But that remains to be seen, there is space on the board in case we need it.

About the components: The op-amp is a Microchip MCP6061, a precision op-amp. We don’t need this here but I happened to have some of them from a previous project. The comparator is a Microchip MCP6541. A bit slow (up to 8us of propagation delay) but as with the op-amp I already had some at hand.

Zero-crossing detector

I’ve simplified the zero-crossing detector somewhat. I want it to trigger every time the received signal crosses zero. When the signal is small it will most likely trigger on random noise but I’m not worried about that. I’m planning to average a number (say, 16) zero-crossings for each measurement. Exactly half of them shall be positive-to-negative and negative-to-positive. This will help to cancel some of the errors I hope. My plan is to set up my interrupts on the Arduino to trigger on the envelope detector first. Only after that I will enable the zero-crossing interrupts. Once I have captured all of my 16 (or whatever the number happens to be) zero-crossings, I’ll disable both time of interrupts until the next measurement. So this zero-crossing detector may random-trigger as much as it likes during all other times.

_MG_1029
Close-up of the zero-crossing detector

So I bias the signal at half the supply rail at 2.5 volts. The threshold is at 2.5 volts as well so I can even use the same resistive voltage divider.

As with the other comparator, I’ve included a feedback resistor across it but don’t plan to actually use it.

Temperature measurement

At the heart of the temperature measurement is a LM35 temperature sensor. It outputs a voltage of 10mV per degree centigrade. So there’s no way you can measure any temperatur below zero. That’s of course a problem depending on where you live but I see this version as a prototype and for testing it will do just fine.

_MG_1030
Close-up of the temperature measurement

There is also an op-amp that lets you scale up the rather small voltage of the LM35 to the 0…5V measurement range of the Arduino ADCs.

Here are the links to the board layout and the schematic as PDFs. As I’ve mentioned before I’m happy to share the Eagle files if anyone’s interested but at the moment I can’t upload them here. Seems you have to go premium to upload zip files and the like.

analog_RevA_Board

analog_RevA_Schematic

Next time I’ll talk about my first tests with the hardware described so far. Click here: https://soldernerd.com/2014/11/16/arduino-ultrasonic-anemometer-part-4-testing-the-analog-board/

7 thoughts on “Arduino Ultrasonic Anemometer Part 3: Analog Circuit”

  1. TheLM35 does work fine below zero centigrade, but you need a negative voltage to use it. See the datasheet.

  2. What’s up every one, here every one is sharing these kinds of know-how, so it’s nice
    to read this webpage, and I used to pay a quick visit this website daily.

  3. Hello, I am Xiao.
    The whole structure you have made is remarkable.
    I’m really interested in it!
    If possible, may I receive the Eagle and other reference files from you?
    Really thanks a lot!

  4. Hi,

    I have an issue about envelope and ZCD circuits. My envelope triggers after hit treshold, but the time when it triggers swings about +-2-3 us. Due to that I cannot accurately detect ZCD, because sometimes it detect rising edge correctly and sometimes after half wave. This makes my measurement wrong and the time of flight difference increases about 25us. How could I solve this problem? Measuring and averaging 8 falling and rising edges could help this?

    1. My another question: I could see that when I receive on south transducer my signal shape is a bit longer and higher amplitude if compared to received signal at east. Is it normal or it is problem with switching circuit? Maybe this is caused duo to Multiplexer resistance? I am currently using 4053. It has COM and pair of NO and NC. NO used for East, NC for West. The difference of received signal shape causes difference for envelope triggering point.

  5. hello lukas,
    you have done great work and it is helping a lot in my project….thanks a lot for this information and sharing all the files.
    as i am doing this project, but i m getting noise with received signal….so the noise is also amplifying in both stages…and hence at the ZCD i m getting distorted output…please help me with this…how to reduce noise in first stage or second stage..your answer will be very helpful in my project….thank you in advance.

Leave a Reply to Lukas Fässler Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.