Thank you. Was that so hard?
To be strict, this wasn't exactly what we asked you. Also, the blue line at some point is both below 30cm and 90cm which doesn't make much sense but we get your point.
The transfer function we wanted you to plot, was the following:
View attachment 51574
See how different this transfer function is compared to the one from the hysteretic comparator?
I 'd like to make sure you understand why a comparator with hysteresis wouldn't be suitable for your problem. If you don't please ask for clarification.
Now, about the dual comparators.
Yes, this is a good choice, especially with the LM339 OpAmps; Since they are open collector type (which means that they only sink current, they can't source any), they can't short circuit their outputs, in case they want to show a different result.
You will need to tweak the circuit you posted, though. Remember, a comparator, will go to Voh when V+>V- and to Vol when V+<V-. Based on that, in which pins do you think that you should connect the limit reference voltages and in which the sensor output?
You should also consider your output specifications. You mentioned Vol=4V and Voh=10V. Where did you get those numbers from? These should reflect some requirements for your load (buzzer, light etc). You should also justify this choice.
Finally, the LM339 needs to operate with a large resistor from Vcc to its output (thousands of ohms). This will constrain its drive capabilities. Consequently, you will need another driver stage after the comparators, which will depend on the load.
Vol =4 V aND Voh=9V,you say above the output will go to Voh and Vol when V+>V- and V+<V-..These Vol and Voh were not the reference voltages?I thougth the output of the comparator would go to +VCC if the input tensions were >Voh and <Vol...Remember, a comparator, will go to Voh when V+>V- and to Vol when V+<V-. Based on that, in which pins do you think that you should connect the limit reference voltages and in which the sensor output?
No i mentioned Vol=3V and Voh=9V.I got these numbers through the function that gives output tension of sensor in order of the water level..You should also consider your output specifications. You mentioned Vol=4V and Voh=10V. Where did you get those numbers from? These should reflect some requirements for your load (buzzer, light etc). You should also justify this choice.
I already knew that.The driver could be somehting like thisConsequently, you will need another driver stage after the comparators, which will depend on the load.
Vol means Voltage output low and
Voh means Voltage output high.
They are bot quantities that refer to your comparator stage output. They have nothing to do with the water level sensor voltage output or the comparator inputs.
The comparator inputs and voltage thresholds should be referred to as Vil/Vih (Voltage input) or Vtl/Vth (Voltage threshold).
Did you draw the window comparator circuit yourself? If so, I will assume that the voltage source refers to the water level sensor. I will refer to that signal voltage source as Vs.
Your Vih is 10V and Vil is 4V as you specified in post#1.
If Vs=3V (level<30cm) then for the upper comparator you have V+>V- and it outputs Voh. For the lower comparator you have V+<V- and it outputs Vol. The total output of your circuit is Vol.
If Vs=5V (30cm<level<90cm) then for the upper comparator you have V+>V- and it outputs Voh. For the lower comparator you have V+>V- and it outputs Voh. The total output is Voh.
If Vs=11V (level>90cm) then for the upper comparator you have V+<V- and it outputs Vol. For the lower comparator you have V+>V- and it outputs Voh. The total output is Vol.
The resulting transfer function is completely opposite than the desired. An input pin reordering is in order. Take a second look.
If you have a better understanding of your circuit now, you should consider again your output specifications. The 3V and 9V selections are not justified. You can select the Vcc and Vee voltages of your comparators to suit your comparator stage needs.
The best way to select the output voltage limits and its driver circuit is to decide on your load first. It is not a good practice to propose driver circuits before stating your load.
Then there has a been a misunderstood,because what i intended and what the problem states is that when the output tension COMING FROM THE SENSOR is equal to 4V that means water level <=30cm and therefore i want Vout=Vcc and when the tension coming from the sensor is equal to 9V that means water level >=90cm and therefore Vo=VCCThey are bot quantities that refer to your comparator stage output. They have nothing to do with the water level sensor voltage output or the comparator inputs.
So the voltage source which in fact refers to the water level sensor should go in the non inverting inputs ?If Vs=3V (level<30cm) then for the upper comparator you have V+>V- and it outputs Voh. For the lower comparator you have V+<V- and it outputs Vol. The total output of your circuit is Vol.
If Vs=5V (30cm<level<90cm) then for the upper comparator you have V+>V- and it outputs Voh. For the lower comparator you have V+>V- and it outputs Voh. The total output is Voh.
If Vs=11V (level>90cm) then for the upper comparator you have V+<V- and it outputs Vol. For the lower comparator you have V+>V- and it outputs Voh. The total output is Vol.
The resulting transfer function is completely opposite than the desired. An input pin reordering is in order. Take a second look.
My load will just be a circuit that turns on a lamp ,so i can have some sort of relay(normaly open) that will be closed when the input tensions of the comparator were equal to 4v or 10vThe best way to select the output voltage limits and its driver circuit is to decide on your load first. It is not a good practice to propose driver circuits before stating your load.
I made an error there. The circuit you gave with the LM339 comparators is the one that should be used, even if its output is inverted. Let me show you what would happen if you switched the input pins of the two comparators:So the voltage source which in fact refers to the water level sensor should go in the non inverting inputs ?
Well, if you had supplied a sketch of what you needed, like was asked in the very first response in this thread, there wouldn't have been a misunderstanding or, if there had been, we could have got it cleared up right away. But you wouldn't take the five minutes to produce a sketch similar to the one attached, which only took me three minutes. Yet now, perhaps, you can appreciated how much time it would have saved.Then there has a been a misunderstood,because what i intended and what the problem states is that when the output tension COMING FROM THE SENSOR is equal to 4V that means water level <=30cm and therefore i want Vout=Vcc and when the tension coming from the sensor is equal to 9V that means water level >=90cm and therefore Vo=VCC
NO!!!!!!So the voltage source which in fact refers to the water level sensor should go in the non inverting inputs ?
What sort of relay? The output of the comparator circuit has to be compatible with this, as yet undefined, relay circuit.My load will just be a circuit that turns on a lamp ,so i can have some sort of relay(normaly open)
Now you are talking about 10V and not 9V. Which is it?!that will be closed when the input tensions of the comparator were equal to 4v or 10v
You keep interchanging values for Vs(90cm) between 10V and 9V. Given post #1, 10V is the correct value. Please pay more attention when you write. Making such typographic errors makes your posts very hard to understand.
That, or you are trying to convey something that I don't understand.
I made an error there. The circuit you gave with the LM339 comparators is the one that should be used, even if its output is inverted. Let me show you what would happen if you switched the input pins of the two comparators:
Water Level|h<30cm|30cm<h<90cm|h>90cm
High Comparator Output|LOW|LOW|HIGH
Low Comparator Output|HIGH|LOW|LOW
Total Circuit Output|LOW|LOW|LOW
The resulting function is a constant LOW, which is obviously wrong. This is caused by the fact that the LOW output of the LM339 is a strong signal while the HIGH output is a weak one. This cannot be changed.
What you can do is drive your load with an active LOW state and turn it off when the comparator output is HIGH.
Other than that, you insist on not telling us what the load is. Is it a 220V lamp? Is it a 6V one? This affects the relay choice. In turn, the relay choice dictates the Vcc value you should pick. Don't turn your back on advice.
Since you mentioned a relay to bridge the comparators with the driver, what could you do to activate the driver with a LOW signal?
Hint: Relays come with a normally open and a normally closed output.
Other than that, you insist on not telling us what the load is. Is it a 220V lamp? Is it a 6V one? This affects the relay choice. In turn, the relay choice dictates the Vcc value you should pick. Don't turn your back on advice.
My idea was to choose a normally open contact that close when the output is high.To trigger the relay with a low signal i could put a inverter intergrate(NOT) but that would imply to have a specific voltage in the output...Since you mentioned a relay to bridge the comparators with the driver, what could you do to activate the driver with a LOW signal?
Hint: Relays come with a normally open and a normally closed output.
What i intend to do is exactly what you have posted in your sktech,and yes the light will have to still on if water is <= 30 cm or >=90 cmWell, if you had supplied a sketch of what you needed, like was asked in the very first response in this thread, there wouldn't have been a misunderstanding or, if there had been, we could have got it cleared up right away. But you wouldn't take the five minutes to produce a sketch similar to the one attached, which only took me three minutes. Yet now, perhaps, you can appreciated how much time it would have saved.
You also need to be more precise in your descriptions. An output from the sensor of 4V does NOT mean that the water level is <=30cm. It only means that the water level is equal to 30cm. A sensor output of <=4V means that the water is <=30cm. Similar for the high side.
If i had a water level of 60 cm then the output tension from the sensor would be V(0.60 m )=1+10*0.6=7 V.What i want in thsis case is Vout=LOW.So in my circuit we have Vin=6V so the output of the first comparator is LOW and of the second one is HIGH so we get LOW in the output since LOW wins over the HIGH(because its like an open circuit has you said)NO!!!!!!
It has been stated several times that the output of the comparator goes LO whenever the voltage at the V- input is greater than the voltage at the V+ input and that the output goes HI (or, in the case of a 339, look like an open circuit) if V+ is greater than V-.
So pick a sensor output voltage level in the middle of your range (say, for water at 60cm) and determine which signals need to go where to get the desired outout.
The values are te ones in the first post.Its just applying the V=1+10*LWhat sort of relay? The output of the comparator circuit has to be compatible with this, as yet undefined, relay circuit.
Now you are talking about 10V and not 9V. Which is it?!
That sounds like i am going to need a transistor operating in two points and what would define the transistion between those points would be the output tensions (10 V and 4V if i am not confusing the values anyway so its better just compute 1+10*0.9m=10 V and 1+10*0.3m=4vAnd you don't want the relay to be closed only when the input voltage to the comparator is "equal" to 4V or 10V, you want it closed when the input voltage to the comparator is "less than or equal to 4V" or "greater than or equal to 10V". Otherwise, you are saying you want it closed for 4V, but not 3.95V.
So i can either reorder the pins of my circuit so that the output is HI within the window and LO outside of it or put an inverter following the comparator.But if the ouput in the middle of the windows limits wont my output be also high with an inverter?First, a mea culpa is in order on my part.
In my last post (post #26) I suggested something off the top of my head and it turns out this is wrong. It also turns out that Georacer had made the same mistake and had caught it and wrote it up in post #25, which I didn't see while I was writing my response (and tending to the dogs and a few other chores).
If you want the output to be LO within the window and HI on either side of it, then a simple LM339-based window comparator won't work. The reason, as Georacer points out, is that in the outer regions where you want the output to be HI, at least one of the comparator outputs will be LO. You can make it work with some minor adjustments, but an easier way is to redefine the output so that it is HI within the window and LO outside of it. That way, each comparator is only asserting a LO on it's side of the window. Within the window, neither is asserting a LO and the resistor can pull it to a HI. If you need the original output polarity, simply follow the window comparator with an inverter.
If it is HI within the window and LO outside the window, and inverter will flip these so that it is LO within the window and HI outside the window. That's what an inverter (the logic type, not the power type) does.So i can either reorder the pins of my circuit so that the output is HI within the window and LO outside of it or put an inverter following the comparator.But if the ouput in the middle of the windows limits wont my output be also high with an inverter?
Thanks
So i can either reorder the pinns in order to get the output HI within the window and LO outside of it or i can add an inverter to the output of the comparator ,but in this in case wont i get a LO output if the input voltage is inside the limits of comparator(lets say 6V)First, a mea culpa is in order on my part.
In my last post (post #26) I suggested something off the top of my head and it turns out this is wrong. It also turns out that Georacer had made the same mistake and had caught it and wrote it up in post #25, which I didn't see while I was writing my response (and tending to the dogs and a few other chores).
If you want the output to be LO within the window and HI on either side of it, then a simple LM339-based window comparator won't work. The reason, as Georacer points out, is that in the outer regions where you want the output to be HI, at least one of the comparator outputs will be LO. You can make it work with some minor adjustments, but an easier way is to redefine the output so that it is HI within the window and LO outside of it. That way, each comparator is only asserting a LO on it's side of the window. Within the window, neither is asserting a LO and the resistor can pull it to a HI. If you need the original output polarity, simply follow the window comparator with an inverter.
Draw a picture and think about it!!!So i can either reorder the pinns in order to get the output HI within the window and LO outside of it or i can add an inverter to the output of the comparator ,but in this in case wont i get a LO output if the input voltage is inside the limits of comparator(lets say 6V)
Thanks