Continue to Site

# [SOLVED]LM339 with Hysteresis - maths not matching results?

Status
Not open for further replies.

#### Picit

##### Newbie level 5
I'm using an LM339 as a non-inverting comparator with Hysteresis.

I'm using the circuit provided in the datasheet (see attached image) but my results don't match the maths?

I'm getting close to my desired output using trial and error, but can anyone help me with the calculations:

My values are:
Vcc is 5V
GND = 0V

Rref 14.7k
R1 10k
R2 330k
R3 1M

Vin is a 0-3v analog signal.

Actual Results
VO goes high at 2.63v and goes low at 1.07v using the formulas provided I get very different theoretical results.

Calculated Results
VOHigh : 2.64
VLOw : 1.40
Vref : 2.03

Any help in calculating the actual results would be much appreciated. Thanks.

Last edited:

I think your calculations assume the LM339 output goes all the way up to +5V and all the way down to 0V. You need to measure the actual V0(max) and V0(min) and base your calculations on that.

The error is due to the tolerance in the resistors you are using. If you use high precision resistors you will get more accorate results but with added cost.

I think your calculations assume the LM339 output goes all the way up to +5V and all the way down to 0V. You need to measure the actual V0(max) and V0(min) and base your calculations on that.

Thanks for the response. Using a scope the output does goes rail to rail 0-5V. Are you suggesting that I should use the amount of hysteresis instead?

- - - Updated - - -

The error is due to the tolerance in the resistors you are using. If you use high precision resistors you will get more accorate results but with added cost.
Thanks for your response. I had considered that. However, if I allow for a 5% error in all the resistors my calculated Vlow is still 1.34v. That's way off the 1.07v that I'm actually getting. Hence there appears to be something more fundamental wrong.

Your measured results seem about right. I am not sure how you arrive at your calculated values but the hysteresis will be non-symetrical about the 2V reference. This is because your output voltage is not symetrical about the 2V reference.

When the output is at 5V, the input will trigger when (2V-Vin)/330k = (5V-2V)/1M or around 1.01V. This ignores the input bias current (and approximates Vref to 2V). How did you get 1.4v?

Keith.

Picit

### Picit

Points: 2
How did u calculte VLow and VHigh? I think you made some mistake in calculation.

Your measured results seem about right. I am not sure how you arrive at your calculated values but the hysteresis will be non-symetrical about the 2V reference. This is because your output voltage is not symetrical about the 2V reference.

When the output is at 5V, the input will trigger when (2V-Vin)/330k = (5V-2V)/1M or around 1.01V. This ignores the input bias current (and approximates Vref to 2V). How did you get 1.4v?

Keith.

Hi Keith. I didn't realise that the hysteresis would be non-symetrical. The way I calculated it was to use the formula from the datasheet (attached above) and then split VH equally about the reference point. So:

Vref =
 VCC*R1 5 * 10k ----------- ------------- Rref + R1 14.7k + 10k Giving a Vref of 2.024V

VH =
 R2 330k --------- * VO(max)-VO(Min) ------------ *5 R2 + R3 330k + 1M Giving a VH of 1.24V (Hysteresis)

I then assumed that 1.24V would be symetrical around the Vref point:

1.24v
-----
2 =0.62V Therefore VHigh = 2.64V (Vref of 2.02V + 0.62V) and VLow = 1.40V (Vref of 2.02V - 0.62V)

I accept I've probably done this completely wrong, hence I'm requesting help. Thanks for your time it's appreciated.

Last edited:

Picit

### Picit

Points: 2

Thanks. The ON Semiconductor equation is wrong. It will give the correct answer for small values of hysteresis, but not large values. However, as the correct equation, show on page 17 of the ST document is even simpler, I don't know why they don't use that!

Hopefully now you have the correct equations you will have no problem getting the right answers.

Keith

Thanks. The ON Semiconductor equation is wrong. It will give the correct answer for small values of hysteresis, but not large values. However, as the correct equation, show on page 17 of the ST document is even simpler, I don't know why they don't use that!

Hopefully now you have the correct equations you will have no problem getting the right answers.

Keith

Keith, thank you very much. I would never have worked out that the equation was wrong. I thought it was my maths.
You've been extremely helpful, I spent a lot of time trying to solve it. Thanks once again.

Status
Not open for further replies.