# Level shifting op amp?

Hello guys,

I have a sine signal of vp-p 10V, I supplied this signal to op amp as comparator, which succesffuly converted into square signal. Now, I want to shift this signal so that it can compatabile with arduino due.

Do you think I can use the, single op amp 741 to do both comparator and level shifiting or do I need an extra op amp.

Below is my circuit I have used.

Use a comparator with an open collector output with a pull up resistor connected to the Due 3.3V. It will match the Due much better. If you have to use the 741 (which dates back to the 1970's), you could use it to drive a transistor to do the same job.

Are you sure you don't want some hysteresis in the circuit? Noise in the input can create multiple transitions at the threshold voltage if you don't have it.

Do you have a one in mind? I am not sure which one to go for.

And, we can't achieve this with op amp?

Perhaps it would be best if you say what you need the circuit for.

I have a fly wheel sensor which gives vp-p 14V of sine signal. I need to convert this signal to square and shift it, so that it can detected by arduino due for frequency measurement.

meme:
I have a fly wheel sensor which gives vp-p 14V of sine signal. I need to convert this signal to square and shift it, so that it can detected by arduino due for frequency measurement.

Are you using an edge triggered interrupt? What maximum frequency? If you are using edge triggered interrupts, it is important to use hysteresis so that you don't get multiple false triggers when the comparator transitions.

aarg:
Are you using an edge triggered interrupt? What maximum frequency? If you are using edge triggered interrupts, it is important to use hysteresis so that you don't get multiple false triggers when the comparator transitions.

Yes, I am using edge triggered event. The maximum frequency I can get around is 4000Hz.

meme:
Do you have a one in mind? I am not sure which one to go for.
And, we can't achieve this with op amp?

The LM393 could work.
Can be powered from 3.3volt, and you could use the internal pull up resistor of the Due as output load.
Reference input can be at or close to ground on a single supply.
Note that 14volt peak/peak can harm the comparator input if not current limited.
Leo..

Wawa:
The LM393 could work.
Can be powered from 3.3volt, and you could use the internal pull up resistor of the Due as output load.
Reference input can be at or close to ground on a single supply.
Note that 14volt peak/peak can harm the comparator input if not current limited.
Leo..

The only issue I have is, as my RPM increases my voltage increases. Let's say the max Voltage the sensor can reach is 20 vp-p of about 2000 RPM

meme:
Yes, I am using edge triggered event. The maximum frequency I can get around is 4000Hz.

Then you should provide some hysteresis by means of some positive feedback, or you are risking false triggering as I mentioned before.

aarg:
Then you should provide some hysteresis by means of some positive feedback, or you are risking false triggering as I mentioned before.

Can you suggest me a good one. Since, I have no experience in op amps.

Somebody else's turn to draw a circuit diagram for the questioner..

Allan.

meme:
Can you suggest me a good one. Since, I have no experience in op amps.

The LM393 that was mentioned is a good choice. Consult the datasheet for examples of hysteresis configuration, there is no need to duplicate those diagrams here. Figure 22 and 23 here:
http://www.ti.com/lit/ds/symlink/lm393-n.pdfThe inverting configuration is probably the best choice.

Comparators are way better than op-amps for comparison. They usually by default have a tiny amount
of in-built hyteresis, but you can add extra by a feedback resistor from the output to the +ve input.

Pitfalls: most comparators are open-collector output so you will need a pull-up resistor. You should
always decouple a comparator right at the relevant supply pins for correct operation.

Pitfalls of using an opamp as a comparator: some opamps are damaged if the input voltages are
widely different (see datasheets). Opamps are slow to recover from saturation, comparators are
well optimized for this. Basically opamps are designed with the intent that the two inputs are kept
at the same voltage by negative feedback. Comparators only use positive feedback, if at all.

MarkT:
Comparators are way better than op-amps for comparison. They usually by default have a tiny amount
of in-built hyteresis, but you can add extra by a feedback resistor from the output to the +ve input.

Pitfalls: most comparators are open-collector output so you will need a pull-up resistor. You should
always decouple a comparator right at the relevant supply pins for correct operation.

I've never heard of built in hysteresis in a comparator before. Can you provide an example? I realize that you know this, but for the benefit of the OP, an open collector output could be good for this application, not a pitfall, as it would allow the comparator to run on a different power supply than the Due, if desired. It is used in the circuit the OP posted.

BTW, the LM339 is more commonly stocked than the 393.

Ah, yes I get LM339 and 74HC393 mixed up sometimes!

Modern and especially high speed comparators do typically have a small amout of built in hysteresis,
or a hysteresis programming pin - it prevents bursts of oscillation on slow waveforms and speeds up
response (at the expense of precision).

I suspect you only have to layout the circuit on the chip the right way round for stray capacitance to
add a little (short-term) hysteresiss (the other way round would reduce the slew rate via Miller effect).

Fast comparators are basically unstable very high gain amplifiers (try to use one as an opamp and it will oscillate),
so there are always going to be internal feedback paths wanted or not, it makes sense to ensure positive
feedback wins over negative. If the feedback is only capacitive then the dc offset precision need not
be affected - in otherwords the in-built hysteresis might not have any effect on low speed performance.
(other than to remove/reduce oscillatory bursts at cross-overs)

After looking your conversation it's better to go with comparator than op amp which has many pitfalls.

So, I'll just buy both LM 339 and LM 393. I would really prefer one which give output voltage swing as close to ground that is zero to 3.3 V in my case. Once, I have the clear signal, then due can pretty much do the rest.

I have checked both datasheets, they both have low offset voltage.

EDIT:
It was pretty evident that, LM 741 was a bad choice. The voltage doesn't swing close to zero.

Thanks,
Meme