# Hysteresis Op Amp weird behaviour (LM358p)

Hi

I got the following circuit and with the help of this website I know that R2 = 10k, R1 = 200R, R3 = 1M.

Vref is 4,1V, I apologise for the bad writing.

The problem is that when I connect R1 to R3 and the photodiode + pin, the voltage that usually is 4.56 and above drops immediately to a few 300mV in that node.

The Op-Amp is the LM358p (Datasheet).

What am I doing wrong?
I assembled the circuit as it is in the schematic, but I can send a photo if needed.

Please provide the diagram with all the resistor values. R3 is crucial for instance.

And have you checked the input and output voltage ranges for the opamp? You perhaps want a real rail-to-rail opamp?

BTW not all opamps can be used as comparators, rail-to-rail or otherwise, and in general you should use a comparator as a comparator, not an opamp, because they are way way better at the job.

R3 is 1M.
I was thinking about using a single supply Op-Amp since the output will be connected to an Arduino board input.

MarkT:
And have you checked the input and output voltage ranges for the opamp? You perhaps want a real rail-to-rail opamp?

Yes, I have, it is powered correctly.

No, I mean have you checked the input and output voltages for the opamp in the datasheet? You are expecting them to work at 4.1V from 5V supply, but they can't.

At 1M that R3 has no effect at all on the circuit as R1 will completely dominate.

Where did you get this circuit?

What are you trying to do?

I was trying to get a voltage comparator with Hysteresis so that when a fast object passed in front of the photodiode the comparator would detect the small voltage drop and give a signal to an Arduino board.
In the datasheet, is the topic 7.7 "INPUT VOLTAGE RANGE" the reason it won't operate from 4.1 to 5V? In other words, it's range is only 0 to 3.5V if Vs=5V?

Alas you chose the wrong configuration which heavily loaded the voltage you were trying to sense.

You want to observe the voltage at the junction of the photodiode and 1M resistor? The you need an impedance much higher than 1M (not 200 ohms!).

You need a true rail-to-rail device for this, be it a comparator or an opamp, if you want to work right up against the +ve rail.

Make life easy and work down near ground - far more devices go to the -ve rail than to the +ve rail. In particular the LM358 should work close to its negative rail.

So redo the divider: photodiode to ground, 1M to 5V.

The way to wire this is inverting input sensing the photodiode, non-inverting input to the voltage reference (which would be 0.9V with things the other way up), adding hysteresis in that part of the circuit where it doesn't load the diode divider.

I think I understand now. I had no idea that there was such a thing as the Input and Output voltage range.