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.
"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).
You also need to know some problems of this solution:
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
C1blocks 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
C1according to the operating frequency of your signal.
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.