A problem regarding connecting the grounds within two seperate circuits
One means of solving the problem is to replace OA3 with a precision full-wave rectifier.



Figure 1. For negative inputs, the first section operates as a closed-loop inverter (A=-1) and the second stage is simply a buffer for the positive output. When the input signal is positive, the first opamp output remains saturated near ground and the diode becomes high-impedance, allowing the signal to pass directly to the buffer stage non inverted. The composite effect is a full-wave rectified waveform at the output of the buffer. Source: Linear.

Another would be to add a second LM339 comparitor. The outputs can be paralleled as they are open-collector type (as far as I remember).







simulate this circuit &ndash; Schematic created using CircuitLab

Figure 2. Dual comparitor option. The two pots could be replaced by a resistor chain.