comparator's with hysteresis - Page 1
Forum section: electronics / beginners

author: CameronHanson20
author_rank: Contributor
timestamp: March 18, 2015, 11:35:33 pm
content: Hello everybody, so I have been playing around with comparator's and positive feedback after watching w2aew's video on analog control for a rc servo motor. The link to it ishttp://m.youtube.com/watch?v=iaGZOO33Z-o. I'm having a bit of trouble with the calculations. In the video, he has some formulas. Vth = vref + vref(R1\R2) and vth = vref - vref(R1\R2). My question is why is it a proportion of R1 and R2 instead of the voltage divider rule. I've attached a picture of some of my math. I'd like to know if I'm doing the calculations correctly as well.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: March 19, 2015, 10:17:23 am
content: I haven't watched the video so I don't know exactly how he's defined the thresholds; but...The main problem with positive feedback is, you don't have one threshold, it splits into two, the rising and falling thresholds.The analysis is simple. When the comparator is in the output-high state, evaluate the node voltages and all that. You'll see the voltage gain (meaning, from Vin to +in) is defined by resistor ratios, and the threshold by Vout, Vref and some resistor ratios. Repeat the process for the output-low state.Once you've done that, subtract the two thresholds, and you have the hysteresis band Vhyst.Now, if you prefer to think in terms of a single threshold, you can average them together. The meaning of a single threshold with hysteresis is, at Vth, you must either add or subtract slightly more than Vhyst/2 to cause the comparator to change state. It's a symmetry point, because the amount added or subtracted, that causes it to change state, is equal.Just from your description anyway, I don't understand which definition he's using, because you only mention a single threshold, no hysteresis band, and none of the relations depend on Vout. As I say above, it is possible to define a meaningful "threshold" (that is, a single one) for such a circuit, but it's not clear if this is what is meant; and in any case, it is insufficient information, because two thresholds means two thresholds, period, no matter what: a complete definition must always be either: the two thresholds as such, or the average with hysteresis band.Note that, since the threshold depends on the output voltage, it further matters what type of comparator is used, and what circuit it is used within. Comparators are often open-collector output types, which require a pull-up. If the pull-up is a resistor (and the load doesn't affect the voltage at all), then this resistor is in series with the feedback resistor when the output is high, but not when it is low. If the output voltage is constrained (a typical application would be: the OC comparator drives a bipolar transistor base, which means it's clamped to +0.7V when "high"), then that must be used in the analysis. If the output is active driven (typical of some general-purpose comparators, and many high-speed comparators), you use V_OH and V_OL in the analysis.Tim

author: IanB
author_rank: Super Contributor
timestamp: March 19, 2015, 11:37:19 pm
content: Yeah, double post.Anyways, here is a screen shot from Alan's video showing the comparator schematic and the calculations for the rising and falling thresholds.If you examine the diagram and the annotations you can verify the expressions shown.Quote from: CameronHanson20 on March 18, 2015, 11:35:33 pmUnderstanding is more important than rules. If you don't have understanding you may apply "rules" incorrectly and get wrong answers.

author: CameronHanson20
author_rank: Contributor
timestamp: March 20, 2015, 12:41:39 am
content: Sorry about the double post. My question really comes down to why is it R1/R2 instead of R1/(R1+R2)?

author: IanB
author_rank: Super Contributor
timestamp: March 20, 2015, 12:49:16 am
content: Quote from: CameronHanson20 on March 20, 2015, 12:41:39 amWell, assume the comparator has a single rail supply that goes from 0 to +Vcc, and assume that the rail-to-rail output can swing all the way between 0 and +Vcc likewise. Now consider the switching condition when the output is low and the input is rising. At the time that the switch happens, write down an equation relating Vin, Vref, R1 and R2. What equation do you get? How does this equation compare to what Alan shows in the notes?

author: mrflibble
author_rank: Super Contributor
timestamp: March 20, 2015, 12:59:31 am
content: You can work it out real quick yourself. Apply two simple characteristics about an ideal opamp.1) virtual ground between the + and - output. As in, V- (the negative input of the opamp) is at Vref voltage. Due to that virtual ground the V+ (positive opamp input) is also at a voltage of Vref.2) no current flows into the opamp inputs. So you have your Vinput on one side of that R1 resistor and Vref is the potential on the other side. That gives you the current flowing through that resistor R1. And since no current is flowing into the opamp at the V+ node, all that current flows through R2 to Vout. And that allows you to work out Vout...

author: CameronHanson20
author_rank: Contributor
timestamp: March 20, 2015, 01:24:16 am
content: I have come up with an equation. It looks similar to Alan's except for the(R1\R1+R2). I have attached a photo. I just cannot figure out why he uses just (R1\R2).

author: IanB
author_rank: Super Contributor
timestamp: March 20, 2015, 01:52:17 am
content: Quote from: CameronHanson20 on March 20, 2015, 01:24:16 amOK, then, let's see.Quote from: IanB on March 20, 2015, 12:49:16 amIf the output can swing from rail to rail and the output is low, then the output will be at 0.At the time the switch happens, we know that the voltages will be equal on the two input terminals. So V+ = V- = Vref.What equation can we write down for this condition? Well, we know that the current in R1 must equal the current in R2 (because where else can it go?). So let's write down that equation:Current in R1 = Current in R2Current in R1 = (Vinput - Vref) / R1Current in R2 = (Vref - 0) / R2Therefore:(Vinput - Vref) / R1 = (Vref - 0) / R2Multiplying by R1:Vinput - Vref = Vref * R1/R2Then moving Vref to the right hand side:Vinput = Vref + Vref * R1/R2This is Alan's equation for the positive going threshold. You can do a similar analysis for the negative going threshold.

author: CameronHanson20
author_rank: Contributor
timestamp: March 20, 2015, 02:06:51 am
content: Ohhhhhhhh. I get it now. I was thinking of adding in the voltage by doing a kvl and kcl. I didnt need to do that :p i feel silly now. Thats where I was getting the voltage divider because I was told that it feeds a portion of the ouput back to the input. Thats why I used the voltage divider formula. But anyways. Thank you. I really appreciate you helping me.

author: w2aew
author_rank: Super Contributor
timestamp: March 20, 2015, 02:32:10 am
content: Thanks for the backup, IanB!

author: T3sl4co1l
author_rank: Super Contributor
timestamp: March 20, 2015, 07:11:14 am
content: Tricky part about a divider between things is, don't forget to subtract the baseline, then add it back in at the end.For voltages V1 and V2 at either end of a voltage divider, the middle voltage is:V1----R1----Vm----R2----V2When V2 == 0, we have Vm' = V1' * R2/(R1+R2). But this isn't the case now, hence writing the other voltages as prime. We need to subtract V2 to offset both nodes correctly:Vm - V2 = (V1 - V2) * R2/(R1+R2)which can be rearranged toVm = V1 * R2/(R1+R2) - V2 * R2/(R1+R2) + V2= V1 * R2/(R1+R2) + V2 * [1 - R2/(R1+R2)]= V1 * R2/(R1+R2) + V2 * [(R1+R2) - R2]/(R1+R2)= (V1*R2 + V2*R1) / (R1+R2)Which looks like the weighted average of the two voltages, the one voltage being weighted by the opposite side resistor, which might seem strange to say, but makes sense given the nature of the voltage divider.If R1=R2 (which is the case in the picture, at Vref = Vcc/2 -- thanks Ian), the weights go away and you get the simple average. Stuff like that.So, it appears it's a much simpler, specific case, not a general case example or formula -- as said, watch out how you apply it!Tim