Author Topic: Temperature indicator circuit with LEDs  (Read 1269 times)

0 Members and 1 Guest are viewing this topic.

Offline dazz

  • Contributor
  • Posts: 40
  • Country: es
Temperature indicator circuit with LEDs
« on: August 20, 2018, 05:46:56 am »
I'm trying to build a circuit to monitor the temperature of an IC, it's a TPA3118D2 in a guitar amp. I know I can do this with an Arduino but thought I might try something of my own and see if I can learn something. The sensor is a TMP36 which outputs a voltage between 100mV and 2V, 750 mV at 25°C and each degree Cº increments the output by 10mV.

I attached the schematic of the circuit I came up with. It consists of a voltage amplifying opamp feeding a voltage follower transistor as a current source for the three LEDs, each with different cutoff voltages to have them lit up at different temperatures.

The LTSpice simulation looks ok to me, the green LED reaches 0.5mA and gets lit at about 1V in the input (50ºC), the yellow LED reaches 0.5mA at 1.2V or 70ºC, and the red one at 1.4V / 90ºC

So far I have breadboarded the opamp section, and it's not working at all. I put 0 to 2V in the input through a voltage divider made with a 1M resistor to a 9V battery and a 250K pot to ground. With the pot at 250K I get 1.8V as should be, but as soon as I connect the opamp input to it, the voltage drops to zero and of course nothing at the opamp output either. Aren't opamps supposed to have high impedance inputs? I'm at a loss

Any suggestions please? Thanks.

EDIT: added the LTSpice asc file in case it helps
« Last Edit: August 20, 2018, 05:56:57 am by dazz »
 

Offline Hero999

  • Super Contributor
  • ***
  • Posts: 11082
  • Country: gb
Re: Temperature indicator circuit with LEDs
« Reply #1 on: August 20, 2018, 06:38:08 am »
I couldn't simulate the circuit, because it uses non-standard models and you forgot to include them, which can be done by copying and pasting them into the schematic. Open the model in a text editor, select it all and copy it to the clipboard. Open the schematic in LTSpice, click the ".op" button on the tool bar, paste the model in the text box (model than one model can be pasted, one after the other), click OK and place on a clean part of the schematic.

What op-amp are you using? I notice you're using an idealised op-amp model. Real op-amps don't work like that. Their outputs and inputs don't normally work over the entire supply range.

One possibility is the op-amp's common mode range is being exceeded, which will mean its inputs no longer have a high impedance.

In any case, it's bad design practise to rely on LED forward voltages for thresholds like this, because they vary from one LED to another and the temperature. The correct way is to use a comparator such as the LM339, and a voltage reference (a zener diode will do)  to derive the threshold voltages, at which the LEDs turn on.

See the links below, for information on comparators:
https://www.electronics-tutorials.ws/opamp/op-amp-comparator.html
https://www.electronics-tutorials.ws/opamp/op-amp-comparator.html
 
The following users thanked this post: dazz

Offline dazz

  • Contributor
  • Posts: 40
  • Country: es
Re: Temperature indicator circuit with LEDs
« Reply #2 on: August 20, 2018, 11:06:34 am »
I couldn't simulate the circuit, because it uses non-standard models and you forgot to include them, which can be done by copying and pasting them into the schematic. Open the model in a text editor, select it all and copy it to the clipboard. Open the schematic in LTSpice, click the ".op" button on the tool bar, paste the model in the text box (model than one model can be pasted, one after the other), click OK and place on a clean part of the schematic.

What op-amp are you using? I notice you're using an idealised op-amp model. Real op-amps don't work like that. Their outputs and inputs don't normally work over the entire supply range.

Yeah, I'm using non standard parts (LEDs & MPSA13 transistor) in standard.dio & standard.bjt, sorry about that.
The non standard models are:

Code: [Select]
.MODEL LED_RGYA D (IS=93.1P RS=42M N=4.61 BV=4 IBV=10U CJO=2.97P VJ=.75 M=.333 TT=4.32U)
.MODEL MPSA13 NPN (IS=360F NF=1 BF=337 VAF=98.6 IKF=.5 ISE=637F NE=2 BR=4 NR=1 VAR=40 IKR=.75 RE=3.5 RB=14 RC=1.4 XTB=1.5 CJE=133P VJE=.74 MJE=.45 CJC=14.1P VJC=1.1 MJC=.24 TF=1.27323N TR=17.4N)
.model 1N4007 D(IS=7.02767n RS=0.0341512 N=1.80803 EG=1.05743 XTI=5 BV=1000 IBV=5e-08 CJO=1e-11 VJ=0.7 M=0.5 FC=0.5 TT=1e-07 mfg=OnSemi type=silicon)
.MODEL 1N34A D(IS=2.6u RS=6.5 N=1.6 CJO=0.8p EG=0.67 BV=25 IBV=0.003 Type=GePunctualContact)

The opamp is the UniversalOpamp2 and it's standard.

One possibility is the op-amp's common mode range is being exceeded, which will mean its inputs no longer have a high impedance.

Thanks, I'll see if I can figure out if that's what's going on here. First lesson learned  :-+

In any case, it's bad design practise to rely on LED forward voltages for thresholds like this, because they vary from one LED to another and the temperature.

...and second lesson learned.

The correct way is to use a comparator such as the LM339, and a voltage reference (a zener diode will do)  to derive the threshold voltages, at which the LEDs turn on.

See the links below, for information on comparators:
https://www.electronics-tutorials.ws/opamp/op-amp-comparator.html
https://www.electronics-tutorials.ws/opamp/op-amp-comparator.html

Great stuff, I'll check that out, thank you
« Last Edit: August 20, 2018, 11:09:30 am by dazz »
 

Offline james_s

  • Super Contributor
  • ***
  • Posts: 6473
  • Country: us
Re: Temperature indicator circuit with LEDs
« Reply #3 on: August 20, 2018, 03:41:32 pm »
You can get LED bargraph driver ICs like the LM3914 that are meant to do exactly what you want. Internally they have a series of comparators and a voltage reference and can be configured to display in either bar or dot mode.
 
The following users thanked this post: dazz

Offline dazz

  • Contributor
  • Posts: 40
  • Country: es
Re: Temperature indicator circuit with LEDs
« Reply #4 on: August 20, 2018, 03:49:54 pm »
How about this design? I'm using 3 NPN transistors to drive the LEDs now, the first one driving the green LED starts conducting at 0.7V (25ºC). The second & third ones take a progressively lower input through the voltage dividers so that they start conducting at a higher input voltage.

I'll breadboard it latter today, but if you guys have any comments that's much appreciated.

I'll be ordering some LM339 to experiment with those, but in the meantime I'd like to try something with what I already have, also I sort of like the idea of LEDs lighting up progressively
 

Offline james_s

  • Super Contributor
  • ***
  • Posts: 6473
  • Country: us
Re: Temperature indicator circuit with LEDs
« Reply #5 on: August 20, 2018, 03:55:53 pm »
That isn't likely to work properly, the transistors don't just suddenly start conducting as the base current rises, they progressively conduct more and more. LEDs take very little current to glow so they will probably all light up at once, then get brighter as the voltage rises.
 
The following users thanked this post: dazz

Offline dazz

  • Contributor
  • Posts: 40
  • Country: es
Re: Temperature indicator circuit with LEDs
« Reply #6 on: August 20, 2018, 04:09:51 pm »
the transistors don't just suddenly start conducting as the base current rises, they progressively conduct more and more.

That's the idea, I'd like the leds to get progressively brighter as temp increases

LEDs take very little current to glow so they will probably all light up at once, then get brighter as the voltage rises.

OK, I'll do some measurements with one LED alone at different current levels to see how much brighter they get as the current increases  :-+
 

Offline Hero999

  • Super Contributor
  • ***
  • Posts: 11082
  • Country: gb
Re: Temperature indicator circuit with LEDs
« Reply #7 on: August 20, 2018, 06:09:33 pm »
How about this design? I'm using 3 NPN transistors to drive the LEDs now, the first one driving the green LED starts conducting at 0.7V (25ºC). The second & third ones take a progressively lower input through the voltage dividers so that they start conducting at a higher input voltage.

I'll breadboard it latter today, but if you guys have any comments that's much appreciated.

I'll be ordering some LM339 to experiment with those, but in the meantime I'd like to try something with what I already have, also I sort of like the idea of LEDs lighting up progressively
That stands more of a chance of working, than the other circuit, but the base-emitter threshold of transistors is also temperature dependant. I don't see the need for Darlington transistors. It does result in a higher input impedance, but will make the temperature coefficient due to the base-emitter junctions worse.

If you want the LEDs to gradually increase in brightness, then the LM339 will not do what you want, but the ways of doing that are a bit more complex. Try your current circuit.
 
The following users thanked this post: dazz

Offline dazz

  • Contributor
  • Posts: 40
  • Country: es
Re: Temperature indicator circuit with LEDs
« Reply #8 on: August 20, 2018, 06:47:28 pm »
How about this design? I'm using 3 NPN transistors to drive the LEDs now, the first one driving the green LED starts conducting at 0.7V (25ºC). The second & third ones take a progressively lower input through the voltage dividers so that they start conducting at a higher input voltage.

I'll breadboard it latter today, but if you guys have any comments that's much appreciated.

I'll be ordering some LM339 to experiment with those, but in the meantime I'd like to try something with what I already have, also I sort of like the idea of LEDs lighting up progressively
That stands more of a chance of working, than the other circuit, but the base-emitter threshold of transistors is also temperature dependant. I don't see the need for Darlington transistors. It does result in a higher input impedance, but will make the temperature coefficient due to the base-emitter junctions worse.

If you want the LEDs to gradually increase in brightness, then the LM339 will not do what you want, but the ways of doing that are a bit more complex. Try your current circuit.

Thanks. The only reason for choosing those darlingtons is because that's what I have right now.   :-\
I'll try testing the circuit at different temperatures to see how much temp affects the output.

If it doesn't work and I must go digital, I guess I'll just pick an Arduino Nano and be done with it, since I can probably do more fancy stuff like blinking LEDS beyond a certain temp threshold, etc...
 

Offline dazz

  • Contributor
  • Posts: 40
  • Country: es
Re: Temperature indicator circuit with LEDs
« Reply #9 on: August 20, 2018, 07:23:31 pm »
Oh, one more question, please. How well will that TMP36 (TO-92) work to measure the IC temp? The plan is to glue it to the chip, or perhaps to the bottom of the board since the bottom ground layer acts as a heatsink. I mean, I'm building a circuit based on a sensor but I don't even know if there are better solutions for that purpose
 

Offline Hero999

  • Super Contributor
  • ***
  • Posts: 11082
  • Country: gb
Re: Temperature indicator circuit with LEDs
« Reply #10 on: August 20, 2018, 09:27:30 pm »
Oh, one more question, please. How well will that TMP36 (TO-92) work to measure the IC temp? The plan is to glue it to the chip, or perhaps to the bottom of the board since the bottom ground layer acts as a heatsink. I mean, I'm building a circuit based on a sensor but I don't even know if there are better solutions for that purpose
It'll just measure the case temperature. The actual temperature of the chip will be higher and will depend on how much power it's dissipating, he heatsink and ambient temperature.

Why do you want to do this? The IC has over-temperature protection built-in. Make sure the heatsink is good enough and it should be fine. The only thing that might be required in extreme cases is a fan, which could only be turned on when it's hot, which will be when the volume level is so high, it will drown out the fan noise.
 
The following users thanked this post: dazz

Offline dazz

  • Contributor
  • Posts: 40
  • Country: es
Re: Temperature indicator circuit with LEDs
« Reply #11 on: August 21, 2018, 12:47:18 am »
It'll just measure the case temperature. The actual temperature of the chip will be higher and will depend on how much power it's dissipating, he heatsink and ambient temperature.

Why do you want to do this? The IC has over-temperature protection built-in. Make sure the heatsink is good enough and it should be fine. The only thing that might be required in extreme cases is a fan, which could only be turned on when it's hot, which will be when the volume level is so high, it will drown out the fan noise.

Well, I started a thread a few days ago because I was concerned about the board's heat dissipation capabilities. I know there's thermal protection implemented in the chip, but the hotter runs, the more it distorts, so I thought I could try adding a heatsink and measuring the temperature to see if that helps and how much. Of course the LED indicator would only give limited information about the chip temp (between 40ºC and 60º, 60ºC and 80ºC, and above 80ºC) but I thought it would be cool to have something to warn me if temps are getting too high if, for example, I was to load it with 4ohms and feed it 24V while playing with distortion effects, hence pushing the output power above "normal operating" conditions. 
 

Offline james_s

  • Super Contributor
  • ***
  • Posts: 6473
  • Country: us
Re: Temperature indicator circuit with LEDs
« Reply #12 on: August 21, 2018, 01:25:05 am »
For an actual useful measurement, your finger will probably be more precise than a few LEDs. Generally I figure if I can't touch it for at least a second or two without burning my finger then it's too hot.
 
The following users thanked this post: dazz

Offline dazz

  • Contributor
  • Posts: 40
  • Country: es
Re: Temperature indicator circuit with LEDs
« Reply #13 on: August 21, 2018, 04:16:05 am »
Ahh, this is a massive fail. As Hero999 suggested, it's too temperature sensitive. I had the circuit breadboarded and working nicely, but as soon as I heated it up with an electric heater, one of those that blow hot air, the amps shooted up by a lot. The red LED went from 150mA to almost 2A  :palm: :-DD. I wasn't measuring the current through the yellow LED, but I could tell it was about to blow up.

Oh well, off to shop an Arduino I guess  |O
« Last Edit: August 21, 2018, 04:51:02 am by dazz »
 

Offline Hero999

  • Super Contributor
  • ***
  • Posts: 11082
  • Country: gb
Re: Temperature indicator circuit with LEDs
« Reply #14 on: August 21, 2018, 05:07:00 am »
Ahh, this is a massive fail. As Hero999 suggested, it's too temperature sensitive. I had the circuit breadboarded and working nicely, but as soon as I heated it up with an electric heater, one of those that blow hot air, the amps shooted up by a lot. The red LED went from 150mA to almost 2A  :palm: :-DD. I wasn't measuring the current through the yellow LED, but I could tell it was about to blow up.

Oh well, off to shop an Arduino I guess  |O
Which circuit did you build? None of the circuits you've posted in this thread should fail like that.
 
The following users thanked this post: dazz

Offline dazz

  • Contributor
  • Posts: 40
  • Country: es
Re: Temperature indicator circuit with LEDs
« Reply #15 on: August 21, 2018, 05:15:04 am »
Ahh, this is a massive fail. As Hero999 suggested, it's too temperature sensitive. I had the circuit breadboarded and working nicely, but as soon as I heated it up with an electric heater, one of those that blow hot air, the amps shooted up by a lot. The red LED went from 150mA to almost 2A  :palm: :-DD. I wasn't measuring the current through the yellow LED, but I could tell it was about to blow up.

Oh well, off to shop an Arduino I guess  |O
Which circuit did you build? None of the circuits you've posted in this thread should fail like that.

The last one, the one with the darlington MPSA13's. Maybe the heat was affecting the LEDs even more than the transistors?
 

Offline Hero999

  • Super Contributor
  • ***
  • Posts: 11082
  • Country: gb
Re: Temperature indicator circuit with LEDs
« Reply #16 on: August 21, 2018, 06:04:31 am »
Ahh, this is a massive fail. As Hero999 suggested, it's too temperature sensitive. I had the circuit breadboarded and working nicely, but as soon as I heated it up with an electric heater, one of those that blow hot air, the amps shooted up by a lot. The red LED went from 150mA to almost 2A  :palm: :-DD. I wasn't measuring the current through the yellow LED, but I could tell it was about to blow up.

Oh well, off to shop an Arduino I guess  |O
Which circuit did you build? None of the circuits you've posted in this thread should fail like that.

The last one, the one with the darlington MPSA13's. Maybe the heat was affecting the LEDs even more than the transistors?
The LEDs all have resistors in series with them, so the current shouldn't go that high.

On the previous schematic you posted, the red LED has a 100R resistor in series with it, which would limit the current to 90mA, even if the transistor and LED failed short circuit.


How hot did you heat it? If it got so hot, it started to overheat and char the resistors, then it's possible they could fail short circuit, but it would start to release smelly fumes, before then.
 
The following users thanked this post: dazz

Offline dazz

  • Contributor
  • Posts: 40
  • Country: es
Re: Temperature indicator circuit with LEDs
« Reply #17 on: August 21, 2018, 06:25:07 am »
With one of these. I'll double check everything, thanks a lot

« Last Edit: August 21, 2018, 06:28:18 am by dazz »
 

Offline dazz

  • Contributor
  • Posts: 40
  • Country: es
Re: Temperature indicator circuit with LEDs
« Reply #18 on: August 22, 2018, 12:54:49 am »
OK, I built the circuit from scratch and it seems fine now. I have no idea what I did wrong the first time but it now seems to take temp variation better. I put it in the fridge and lowered it's temperature from 30ºC to 10ºC. The current in one LED dropped from 550uA to 320uA. That's the equivalent of lowering the input from 70ºC to 62ºC. So a 20ºC drop in ambient temp shifts the measurement 8ºC. Not ideal but not terribly bad either I guess.

I'm gonna try now upping the temp to 50ºC in the oven. All for the science!  :-DD

I also scavenged three C946 NPN transistors from an old, dead computer power supply I had forgottten about, maybe those perform better temp wise
 

Offline dazz

  • Contributor
  • Posts: 40
  • Country: es
Re: Temperature indicator circuit with LEDs
« Reply #19 on: August 22, 2018, 03:11:54 am »
It's a lot better with those NPN's, just as Hero predicted  :-+ Now a 20ºC ambient temp variation shifts the measured temp by only 4ºC. This is not a precision gauge so I'm gonna call that good. Thanks everyone!

ETA: pic attached
« Last Edit: August 22, 2018, 04:20:41 am by dazz »
 

Offline dazz

  • Contributor
  • Posts: 40
  • Country: es
Re: Temperature indicator circuit with LEDs
« Reply #20 on: August 22, 2018, 05:05:18 am »
The red LED went from 150mA to almost 2A  :palm: :-DD. I wasn't measuring the current through the yellow LED, but I could tell it was about to blow up.
The LEDs all have resistors in series with them, so the current shouldn't go that high.

On the previous schematic you posted, the red LED has a 100R resistor in series with it, which would limit the current to 90mA, even if the transistor and LED failed short circuit.

How hot did you heat it? If it got so hot, it started to overheat and char the resistors, then it's possible they could fail short circuit, but it would start to release smelly fumes, before then.

BTW, I misread the current there. The red LED went from 150uA to almost 2mA, not 150mA & 2A. The yellow one was probably above 20mA
« Last Edit: August 22, 2018, 06:17:46 am by dazz »
 

Offline Eka

  • Regular Contributor
  • *
  • Posts: 152
  • Country: us
Re: Temperature indicator circuit with LEDs
« Reply #21 on: August 22, 2018, 06:07:48 am »
You can get LED bargraph driver ICs like the LM3914 that are meant to do exactly what you want. Internally they have a series of comparators and a voltage reference and can be configured to display in either bar or dot mode.
With the bar graph driver ICs like the LM3914, it is possible in bar graph mode to combine outputs so it increases LED brightness as more outputs add their current to the LED. So, set the LED drive current to 5mA. Group three outputs per LED. When 5 outputs are driven, LED1 will be on full, LED2 will be 2/3 intensity, and LED3 will be off. Unfortunately LED intensities are not linear. Trimming resistors between the outputs and LEDs can help make them look more linear. Also LM3914s can be strung together for more outputs.

TI has good application notes for their parts.
http://www.ti.com/lit/ds/symlink/lm3914.pdf
So I try to buy from them is not outrageous.

Another thing to note is the human eye isn't that great at absolute intensity when the background illumination is different. Your display intensity will look very different when the room is lit versus relatively dark.
 
The following users thanked this post: dazz

Offline dazz

  • Contributor
  • Posts: 40
  • Country: es
Re: Temperature indicator circuit with LEDs
« Reply #22 on: August 22, 2018, 06:24:10 am »
You can get LED bargraph driver ICs like the LM3914 that are meant to do exactly what you want. Internally they have a series of comparators and a voltage reference and can be configured to display in either bar or dot mode.
With the bar graph driver ICs like the LM3914, it is possible in bar graph mode to combine outputs so it increases LED brightness as more outputs add their current to the LED. So, set the LED drive current to 5mA. Group three outputs per LED. When 5 outputs are driven, LED1 will be on full, LED2 will be 2/3 intensity, and LED3 will be off. Unfortunately LED intensities are not linear. Trimming resistors between the outputs and LEDs can help make them look more linear. Also LM3914s can be strung together for more outputs.

TI has good application notes for their parts.
http://www.ti.com/lit/ds/symlink/lm3914.pdf
So I try to buy from them is not outrageous.

Another thing to note is the human eye isn't that great at absolute intensity when the background illumination is different. Your display intensity will look very different when the room is lit versus relatively dark.

I know the gradual intensity thing is far from optimal, but it goes well with the overall shoddiness of my amp build  ;D
I'll definitely keep those suggestions in mind and will eventually do it "the right way". Thanks for the info, Eka

ETA: just to add a video by Dave showcasing the LM3914

« Last Edit: August 22, 2018, 07:32:22 pm by dazz »
 

Offline dazz

  • Contributor
  • Posts: 40
  • Country: es
Re: Temperature indicator circuit with LEDs
« Reply #23 on: August 31, 2018, 06:20:40 am »
Let me dig up my thread here to ask another question, if I may.

I'm now concerned that this may not work without an input buffer because of the current draw in the voltage dividers. I measured the current draw at the input at 5mA. I don't think the TMP36 sensor can drive that kind of load, right?

Here's the datasheet and the circuit again.

http://www.analog.com/media/en/technical-documentation/data-sheets/TMP35_36_37.pdf

 

Offline Hero999

  • Super Contributor
  • ***
  • Posts: 11082
  • Country: gb
Re: Temperature indicator circuit with LEDs
« Reply #24 on: August 31, 2018, 06:06:51 pm »
You're right, a buffer is required. The maximum current the output the TMP36 can drive is 50μA. An emitter follower could be added, but that would add an extra voltage drop and the associated temperature coefficient. A unity gain buffer, made with the cheap and cheerful LM358 will be better.
 
The following users thanked this post: dazz


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf