Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Thermistor and Comparator Circuit

Status
Not open for further replies.
While I'm a big supporter (in my heart at least) of privacy of an individual as a right, I also believe an innocent person has nothing to hide, so I wouldn't mind that kind of personal inspection, if it were required for clearance for a job or what not. Personal curiosity wishes I knew why you had the clearance though =)

Sent you a PM.
 
Al,

I want to maintian the temperature as close to -3 C as possible. I have figured out the voltages at -5 C and -1 C. They are 2.37 V and 2.65 V respectively. I sized the feedback resistor so that the hysteresis band (if that's even the right term) would be from 2.37 to 2.63 volts. So, if I'm right the heater should turn on just below -5 and turn off just above -1.

I understand what you're saying about the voltages being ratiometric. That makes sense.

The output of the comparator will be input into a NOR gate who's output will in turn drive an opto-coupler and triac arranegement. Do I still require pull up resistors?

Thanks.


Hi again,


Oh ok, i see what you are doing now...



You seem to need voltages of:
VLL=2.3634 and VHH=2.6367

I am not sure what resistors you want to vary, but if you vary two resistors you can get those two
voltage right on with the following two formulas:

Code:
R17=-(sqrt((-4*Vs*R18*R20*VHH+Vs^2*R20^2+2*Vs^2*R18*R20+Vs^2*R18^2)*VLL^2+(4*Vs*R18*R20*VHH^2+(-2*Vs^2*R20^2+(2*Vs*Vsat-2*Vs^2)*R18*R20-2*Vs*Vsat*R18^2)*VHH)*VLL+(Vs^2*R20^2-2*Vs*Vsat*R18*R20+Vsat^2*R18^2)*VHH^2)+(Vs*R20+Vs*R18)*VLL+(-Vs*R20-Vsat*R18)*VHH)/(2*Vs*VLL-2*Vs*VHH)
R16=-(R17*R18*VLL)/((R18+R17)*VLL-Vsat*R18-Vs*R17)
by calculating R17 first and then R16. Note R20 is the pullup resistor that connects output to the power supply rail.

For example, for R20=1k and Vsat=0.25 and Vs=5 we get:
R17=81155.05774872
R16=9946.195557493

Just for reference, the two voltages can be calculated with:
VL=(R16*(Vsat*R18+Vs*R17))/(R17*R18+R16*R18+R16*R17)
VH=(Vs*R16*(R20+R18+R17))/(R18*R20+R16*R20+R17*R18+R16*R18+R16*R17)

where
Vsat is the comparator output saturation voltage (typically 0.25v)
Vs is the source voltage (5v in this application)
VL is the lower comparator trip voltage
VH is the upper comparator trip voltage
R20 is the pullup resistor
The other resistors are as per your schematic



 
Last edited:
OK, here's another schematic with all the tweaks everyone suggested:

Schmitt4.PNG

I'll crank my freezer down to its coldest setting tonight so it should be nice a frosty when I throw it into a breadboard probably tomorrow to do some testing. I have a DMM that's got a temp probe that I can use as a temp reference. I guess I'll just have to assume that it's accurate.

MrAl,

Just to make sure I'm understanding, a Vsat of .25V means that when the comparator is operating in saturation, the ouput will only be .25V. Is that correct? If so, I now understand why the pull up resistor is necessary.

Thanks everyone for the help.
 
Ok, this makes much more sense now. Just one question though. The wikipedia articles says when the output NPN turns on, the ouput is forced to 0V. But wouldn't it be forced to Vce?
 
Let me ask you this. If you have a circuit like below.

Gnd<-------[switch]----[A]------[4.7k res]-------->+5v

Looking at the crude drawing above the switch being simple single pole open/close switch.
What will the voltage at point A be if the switch is open?
What will the voltage at point A be if the switch is closed?
 
Last edited:
Didn't know that. All my clearances have come thorugh the military and now my current employer. Luckily I haven't had to shell out a dime for it. Just spend hours on tedious paperwork. It is kind of amusing though when you get a phone call from an old friend that you haven't spoken to in 10 years and they tell you someone called them asking about you.

What branch of service were you? What was you rating or MOS (Job)?
 
Let me ask you this. If you have a circuit like below.

Gnd<-------[switch]----[A]------[4.7k res]-------->+5v

Looking at the crude drawing above the switch being simple single pole open/close switch.
What will the voltage at point A be if the switch is open?
What will the voltage at point A be if the switch is closed?

Mike,

What will the voltage at point A be if the switch is open? 5V
What will the voltage at point A be if the switch is closed? 0V

I understand your drawing but perhaps I need to brush up on transistor basics. I was under the impression that even when a transistor is on (i.e. closed in your analogy), that there was still a voltage drop between the collector and the emitter. That's what I meant by Vce. Let me ask this, does the saturation voltage of .25V correspond to the high or low output state? Sorry if I'm not being clear, I just want to make sure I'm grasping this.

In answer to your other question, I was Army enlisted. I had 2 MOSs. 91B = Combat Medic and 13F = Fire Support Specialist (i.e. field artillery forward observer). I think they have changed the MOS codes since I was in though because I was talking to a current soldier a few months ago and he had a different idea of what a 91B and 13F were.
 
Mike,

What will the voltage at point A be if the switch is open? 5V
What will the voltage at point A be if the switch is closed? 0V

I understand your drawing but perhaps I need to brush up on transistor basics. I was under the impression that even when a transistor is on (i.e. closed in your analogy), that there was still a voltage drop between the collector and the emitter. That's what I meant by Vce. Let me ask this, does the saturation voltage of .25V correspond to the high or low output state? Sorry if I'm not being clear, I just want to make sure I'm grasping this.

In answer to your other question, I was Army enlisted. I had 2 MOSs. 91B = Combat Medic and 13F = Fire Support Specialist (i.e. field artillery forward observer). I think they have changed the MOS codes since I was in though because I was talking to a current soldier a few months ago and he had a different idea of what a 91B and 13F were.


hi vne,
Look at this plot of a 2N2222 transistor.

Vce sat is when the transistor is conducting hard and almost all the supply voltage is across the transistor load resistor.

Note the power dissipation peaking in the linear region of the transistor.

AAesp01.gif
 
hi vne,
Look at this plot of a 2N2222 transistor.

Vce sat is when the transistor is conducting hard and almost all the supply voltage is across the transistor load resistor.

Note the power dissipation peaking in the linear region of the transistor.

View attachment 37912

Hi Eric,

Thanks for the explanation. I think I understand now. If I read it correctly, it looks like from the plot that Vce sat is about .2V for the 2N2222. So with respect to the LM293 comparator, if it has a Vsat of .25V then output will never drop below that. Correct? I understand that's low enough for a logical low so in essence it's 0V but I just wanted to make sure I was understanding.

In other news, I think I figured out how I'm going to test the circuit. I breadboarded the comparator circuit and soldered the thermistor to some 2 conductor shielded wire and I grounded the shield. I got a cheap Tupperware container and cut a few holes in it. I mounted the thermistor inside, right next to the temperature probe from my multimeter which is also inside the Tupperware container. Last but not least I placed a 10Ω 10W power resistor inside the container. I also built an output circuit with an NPN and another resistor so when the comparator output is low, the NPN will conduct and the resistor will pump out about 2W.

I hope it should allow me to calibrate the set point and hysteresis band or at least make it equally inaccurate as my multimeter.

Thanks again everyone for the help and explanations. They are really helpful.

Edit: I forgot to mention a somewhat minor but extremly important detail about the testing. I'm going to stick the Tupperware container with everything inside into my freezer.
 
Last edited:
Hi Eric,

Thanks for the explanation. I think I understand now. If I read it correctly, it looks like from the plot that Vce sat is about .2V for the 2N2222. So with respect to the LM293 comparator, if it has a Vsat of .25V then output will never drop below that. Correct? I understand that's low enough for a logical low so in essence it's 0V but I just wanted to make sure I was understanding.

I hope it should allow me to calibrate the set point and hysteresis band or at least make it equally inaccurate as my multimeter.

Thanks again everyone for the help and explanations. They are really helpful.

Edit: I forgot to mention a somewhat minor but extremly important detail about the testing. I'm going to stick the Tupperware container with everything inside into my freezer.

hi,
The Vsat of the LM293 is about 250mV at about 4mA sink current, so choose your LM293 output resistor value to give this as a maximum current when the LM293 output is low.

If you have an old biscuit tin you can place your project in the tin and then heat it externally with a desk lamp.

BTW: if you put you projects in a freezer, when you take them out frozen, any humidity in the air will cause heavy condensation on the components.
I put the sensitive components in a sealed clear plastic bag until they get back upto room tempr.
 
Last edited:
Hi again,


Yes, the Vce is the saturation voltage of the output transistor used in the comparator and yes it is spec'd as 0.25v at 4ma. With 1k pullup
and 5v supply that's 5ma but the exact value of the pullup depends on what you are trying to drive (NOR gate). If the nor gate doesnt
take much current (CMOS) then a larger value resistor is ok too, but remember you need to go through the calculations for R16 and R17
again if you change any resistor. Also, it may help to measure the Vce sat voltage and enter that into the calculation too.
Using a CMOS gate might be a good idea as it will not load the pullup much.

That's great that you intend to put the entire circuit into the environment to be monitored, because that means the whole circuit will
track the temperature and that takes many of the unknowns out of the picture. That's the best way to do it as you can not always
depend on the ambient outside of the freezer to be stable. You do have to use parts that can work at those temperatures however.

I think we covered everything now, but one thing to note is that the calculation for R17 came out close to 81k, not 811k which you have
drawn in your new schematic. Double check that in case it was not simply a typo.

Lastly, even though we have calculated this circuit out completely you may require calibration anyway since you want to work with
such a tight temperature range. Also since you want such a range as that you may wish to take a look at your dv/dT for the thermistor
with various upper resistors (your 415k resistor) and see that you are getting the maximum voltage variation possible for the
chosen range (in case you havent done that already). That will increase the resolution of the measurements to the best possible or
at least to pretty good. You dont need super great linearity here but you do want good resolution.

Ok one more quick tip (chuckle)...
In temperature applications like this it is usually a good idea to have a back up plan in case the primary system goes down.
These electronic components are usually pretty good but can change over time. A simple method would be to build up a duplicate
of the system you are currently building and set the range just outside of the primary system (by say 2 degrees). That will
trigger an alarm just in case something goes wrong with the first system. It also should be powered from a separate power
supply to be sure just in case the first one goes down, and should also be checked periodically to make sure it can do it's
job properly when needed.

If it turns out that the resolution isnt good enough to get good repeatability or good results in general, you may have to move
to a digital temperature sensor and use a micro controller.
 
Last edited:
hi,
The Vsat of the LM293 is about 250mV at about 4mA sink current, so choose your LM293 output resistor value to give this as a maximum current when the LM293 output is low.

Got it! I think the fog has lifted.

If you have an old biscuit tin you can place your project in the tin and then heat it externally with a desk lamp.

BTW: if you put you projects in a freezer, when you take them out frozen, any humidity in the air will cause heavy condensation on the components.
I put the sensitive components in a sealed clear plastic bag until they get back upto room tempr.

The buscuit tin and desk lamp idea isn't bad but I need the freezer to get down to -3 C which is my target set point. I'll make sure to take your suggested precautions to avoid condensation because I live in Houston, TX. We don't actually have air down here, just humidity. Thanks.
 
Last edited:
hi,
For ref only, a simple LTspice of the last circuit you posted.

I would suggest you make R2 and R6 a combination of fixed and a variable resistor, this will give you some degree of control of the Vref and hysteresis.

Vyn1.gif
 
hi,
For ref only, a simple LTspice of the last circuit you posted.

I would suggest you make R2 and R6 a combination of fixed and a variable resistor, this will give you some degree of control of the Vref and hysteresis.

View attachment 37915

How come the output transitions from hi to low or vice versa when THntc crosses Vref? Shouldn't the output not transition until it crosses Vref ± the hysteresis? I thought when the voltage is decreasing, the output shouldn't transition until THntc is ≈2.37V and when increasing until it is ≈2.63V.

The fog has returned!:(

Edit: Sorry, I didn't see MrAl's post until after I wrote this so I think I know why the spice sim you posted yielded the results it did. Becuase of a typo on my part, the feedback resistor is an order of magnitude too large. I think that would explain why the hysteresis is barely noticable. Sunny skies again:)
 
Last edited:
Hi again,


Yes, the Vce is the saturation voltage of the output transistor used in the comparator and yes it is spec'd as 0.25v at 4ma. With 1k pullup
and 5v supply that's 5ma but the exact value of the pullup depends on what you are trying to drive (NOR gate). If the nor gate doesnt
take much current (CMOS) then a larger value resistor is ok too, but remember you need to go through the calculations for R16 and R17
again if you change any resistor. Also, it may help to measure the Vce sat voltage and enter that into the calculation too.
Using a CMOS gate might be a good idea as it will not load the pullup much.

OK, got it! I'll make sure to size my pullup and output resistors accordingly and recalc the other values. Also, I was planning on using a CMOS NOR gate.

That's great that you intend to put the entire circuit into the environment to be monitored, because that means the whole circuit will
track the temperature and that takes many of the unknowns out of the picture. That's the best way to do it as you can not always
depend on the ambient outside of the freezer to be stable. You do have to use parts that can work at those temperatures however.

I test EVERYTHING. It might just be a reflection of my lack of confidence as a result of my lack of knowledge at this point but I haven't built too much yet that worked right the first time.

Also, I have been trying to remain fairly diligent about ensuring my components are rated for the environment I plan to use the circuit in. That's why I'm using an 293 instead of a 393. It's a good reminder though, thanks.



I think we covered everything now, but one thing to note is that the calculation for R17 came out close to 81k, not 811k which you have
drawn in your new schematic. Double check that in case it was not simply a typo.

Oppps. I read your post late last night and I guess I wasn't paying close enough attention. It was just a transcription error but would have become a mistake in my circuit if you hadn't said something. Thanks.

Lastly, even though we have calculated this circuit out completely you may require calibration anyway since you want to work with
such a tight temperature range. Also since you want such a range as that you may wish to take a look at your dv/dT for the thermistor
with various upper resistors (your 415k resistor) and see that you are getting the maximum voltage variation possible for the
chosen range (in case you havent done that already). That will increase the resolution of the measurements to the best possible or
at least to pretty good. You dont need super great linearity here but you do want good resolution.

I kind of intuitively assumed that the maximum voltage variation would occur when the upper resistor was sized so that the voltage divider would give about half of the supply voltage. I'll dust off my calculus brain though and make certain of that.

Ok one more quick tip (chuckle)...
In temperature applications like this it is usually a good idea to have a back up plan in case the primary system goes down.
These electronic components are usually pretty good but can change over time. A simple method would be to build up a duplicate
of the system you are currently building and set the range just outside of the primary system (by say 2 degrees). That will
trigger an alarm just in case something goes wrong with the first system. It also should be powered from a separate power
supply to be sure just in case the first one goes down, and should also be checked periodically to make sure it can do it's
job properly when needed.

As far as I know, there's no life and death situation dependent on my circuit properly functioning but I'll give the backup idea some thought. the simplest way to do this might be with a mechanical thermostat. What do you think?

If it turns out that the resolution isnt good enough to get good repeatability or good results in general, you may have to move
to a digital temperature sensor and use a micro controller.

My first idea was to use a TC621CEPA. I requested some samples from Microchip but while I was waiting for them to arrive I started working on the LM293 idea. I am already using the LM293 for a very similar light sensing function in the same circuit and since it's a dual comparator, I thought it might be better to use that instead of adding an additional IC. I may go back to using the TC621 though if the testing doesn't go well. Even if don't end up using the 293 for the temperature, I'm glad I explored it because I feel I understand them much better now.

I could also use a µcontroller and in all honestly that would have been my first choice but this circuit will become a set of DIY plans. I think a majority of the people who might be building this circuit won't have the knowledge or resources to program a PIC and I don't want to sign up to having to mail programmed PICs to the four corners of the Earth.


Thanks for your thorough reply. I think this is coming together.
 
hi vne,
Re-run a sim with the feedback resistor divided by 10

vyn2.gif
 
Last edited:
Hi again,


Yes it appears that you have already thought about the resolution of the thermistor voltage and you probably got it right being about half way.

While we are talking about that, another idea would be to replace R18 with a 10k thermistor too. Since you are using a differential
element that would increase the sensitivity. It may be possible to use 10k thermistors for both thermistors, so you can use the same
exact type for both (changing R19 as well). Of course it would have to be 10k at the required temperature, or allow it to go higher and
change the other resistors accordingly. This would also mean we would have to recalculate the circuit for min and max temperature, but
that's not too much of a problem. The sensitivity would end up being about twice as good as with a single thermistor in that the equivalent
voltage change per ohm change would be double what it is now. Whether or not this is really necessary though remains to be seen.

Yes i see you are using an LM293 now and that's a good choice.

I see Eric did a nice simulation which shows we are on the right track too :)
 
Last edited:
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top