How can I filter a DC offset of a pulse train with an RC circuit? The signal is a pulse jumping between 3.07V and 3.53V. But I need a pulse which is jumping between 0V to 0.5V. How can I filter that 3V DC offset?
The simple and obvious answer that meets your specs is:
This thresholds the input around the midpoint of what you say the high and low levels are. In practise a little hysteresis is probably wise:
This will create about a 50 mV hystersis band. For example, when the input goes high so that the output goes high, the input has to go 50 mV lower before the output will go low. The hystesis band will be a little assymetric due to your threshold of 3.3 V not being in the middle of the output. This can be compensated for several ways, including adjusting the reference voltage fed into the negative input. Let me know if you want to get into those details.
Use an op-amp to create a mixer circuit and subtract the 3.07 volts from the signal: -
V1 can be your input and apply -3.07 volts DC to V2. If you want to restore the polarity of your signal (because Vout = -(V1+V2)) use an op-amp inverter afterwards.
If the dc offset is slightly moving with respect to the signal then something like a data-slicer would work: -
This uses a comparator and one input has the signal plus offset and the other input has the much-slowed-down version of the raw input. This slowed-down version will contain hardly any signal but just the average level of the signal. providing the mark-space ratio doesn't get excessive i.e. greater than 95% or less than 5% then it will produce a logic-level version of the desired digital signal. This can be returned to the 46mVp-p level should that be desired by using a resistor attenuator.
Should the undesired DC offset be wobbling quite a bit then you can use peak detectors on the upper and lower bounds of the composite signal to set upper and lower thresholds for two comparators and get even better performance - the two comparators can set and reset a flip-flop to restore the original signal.
Alternatively, you can use a high pass filter to largely differentiate the composite signal leaving no dc offset and spikes. The spikes will rise positive for edge transitions that were positive and there will be negative spikes for negative edge transitions of the composite signal. Then use a comparator with hysterisis to convert this back to a logic-level signal.
If red signal is fed to a comparator with some hysterisis it will toggle the comparator each time a pulse/spike rises above the comparator threshold thus resoring the sq wave. Ignore the scales on the picture above - they are not important but the concept is.