I have a sinusoidal signal with a frequency of 100 kHz. It's zero centered with a peak-to-peak of around 3V (i.e. from -1.5V to +1.5V). I want to be able to read the peak-to-peak voltage with one of the analog pins on a Teensy 3.2 MCU, but I'm unsure of how to shift this signal to the 0-3.3V range. I'm very much a beginner so I'm still a bit unfamiliar with the terminology. A basic explanation would be really appreciated.

  • 3
    \$\begingroup\$ See the first answer to electronics.stackexchange.com/questions/14404/…, and just use your 3.3V supply where that answer calls out 5V. \$\endgroup\$
    – TimWescott
    Jun 24 '19 at 17:03
  • 1
    \$\begingroup\$ What is the output impedance of your signal source? Provided its low enough a biased HPF is the easiest way to go. \$\endgroup\$
    – sstobbe
    Jun 24 '19 at 17:07

"Shifting" your signal "upward" by adding an "offset" is called biasing. For example, you can add a constant "1.5V" to your signal, your signal would be translated to "0V-3V", which can be then directly fed into your analog pins. The 1.5V here is called a bias voltage.

When precision is not critical (usually not, if it is, you may need an opamp or a instrumentation amplifier), a quick-and-dirty way of adding a bias voltage is simply using a resistor divider. If you wire two identical resistors from +3.3V to ground, you can create a half-voltage of 1.65V at the middle point. You also need a DC-blocking capacitor in series to isolate your signal and the resistor divider, otherwise the 1.65V bias voltage would "flow" to your signal and destroy the operating point.

Here's a simple example. V2 is your power supply, V1 is the signal you want to measure. From this simulation, you can clearly see how a "-1.5V to +1.5V" signal is translated to a "0.15V to 3.15V" signal.

The middle point of the resistor divider can be connected to your analog pin. Make sure your analog pin is set to INPUT on boot, not OUTPUT, otherwise you'll create a short (though the two 10k resistors would limit the current, nothing bad will happen).

Resistor Bias Network

You also need to know some problems of this solution:

  1. The 1.65V middle point is created by halving your 3.3V power supply. If the 3.3V voltage changes, the bias voltage would change. Also, any noise in the 3.3V power supply is going to be superimposed to your biased signal. I believe Teensy 3.2 MCU uses a LDO voltage regulator to generate 3.3V supply, which should be precise enough. But you may still want to add a decoupling capacitor in parallel to R2.

  2. Capacitor C1 blocks DC and isolates the bias network from your signal, but since it's a capacitor anyway, it does not only block DC, but also attenuates other AC frequencies, the side-effect is forming a high-pass filter. You need to adjust the value of C1 according to the operating frequency of your signal.

  3. The example assumes an negligible output impedance of the signal source. If the signal has a significant output impedance (e.g. an analog sensor), you'll see an attenuated voltage, which is not good. If the signal source is fixed and known (e.g. again, an analog sensor), you can measure the output impedance, calculate the input impedance, deduce the voltage drop, and compensate it in software. Otherwise, you may need to buffer it.

  • \$\begingroup\$ This works, but could you please explain how to calculate the capacitor value and the resistor values? \$\endgroup\$
    – rcsmth
    Jun 26 '19 at 23:40
  • \$\begingroup\$ @rcsmth The ratio of R1 & R2 determines the bias voltage at the middle, Vbias = 3.3 V x R2 / (R1 + R2), e.g. if R1 = 20k, R2 = 10k, Vbias = 1.1 V. Their actual values determines the impedance of Vbias (i.e. how much current you can get before Vbias drops unacceptably) and wasted power, since a current always flow across R1 & R2. An ADC input draws almost no current, so you can use large resistors such as 10k-100k. The value of C1 is a bit arbitrary, just make sure Xc is low at your frequency, see electronics.stackexchange.com/questions/308221/… \$\endgroup\$ Jun 27 '19 at 1:45

Not the answer you're looking for? Browse other questions tagged or ask your own question.