# small sine wave with dc bias - translate to logic time signal

I have a time varying pressure sensor output signal from which I would like to obtain the cyclic frequency. The signal originates from a reciprocating gas compressor therefore the voltage signal is a smooth and slightly distorted sine wave, frequency varies slowly from 0-10Hz, but is generally in a steady-state.

The sensor signal is 0-10Vdc, the amplitude is around 0.5V and the dc offset can be anywhere from 0.5 to 9.5v.

I would like to translate the small sine signal into a logic level square wave signal to be received by a microprocessor board (Arduino Uno) for frequency counting.

The approach that I'm thinking of is to shift the ac signal mean to 2.5Vdc, amplify the wave and feed through a Schmitt trigger (I have SN74HC14N)comparator.

I'm sure that this is a very common situation but I haven't found a book chapter to spell it out for the electronics novice.

A simple voltage comparator can do what you need in one step: simulate this circuit – Schematic created using CircuitLab

The LM339 (and comparators like it) has an open-collector output, so it can drive a logic input on your MCU with the assistance of a simple pullup.

On the input side of the comparator, a simple low-pass filter produces the average of the input signal, isolating the DC bias. This is fed to the - input as a reference. Therefore, the output of the comparator switches high and low as the original signal (connected to the + input) swings above and below this average.

Note that the input signal (AC + DC) must at all times be between the supply rails of the comparator, with some margin required at the top end. See the "common-mode input voltage range" specification in the datasheet. Adjust as needed.

If the circuit doesn't work reliably at the lowest frequencies you want to detect, try increasing the time constant of the filter — i.e., larger values for C1 and/or R1.

• Dave, thank you for providing this circuit arrangement and describing the operation so clearly, I will build and experiment. Sep 16, 2016 at 13:33
• @DaveTweed - There is a potential problem here. Tim's interest is in 10 Hz frequency. This comparator will almost certainly add noise to each square wave edge, which will result in a far higher frequency if the RasPi counts edges over a fixed time. Sep 16, 2016 at 13:59