Temperature indicator circuit with LEDs - Page 1
Forum section: electronics / beginners

author: dazz
author_rank: Frequent Contributor
timestamp: August 19, 2018, 07:46:56 pm
content: 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 aTMP36which 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ºCSo 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 lossAny suggestions please? Thanks.EDIT: added the LTSpice asc file in case it helps

author: Zero999
author_rank: Super Contributor
timestamp: August 19, 2018, 08:38:08 pm
content: 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.htmlhttps://www.electronics-tutorials.ws/opamp/op-amp-comparator.html

author: dazz
author_rank: Frequent Contributor
timestamp: August 20, 2018, 01:06:34 am
content: Quote from: Hero999 on August 19, 2018, 08:38:08 pmYeah, I'm using non standard parts (LEDs & MPSA13 transistor) in standard.dio & standard.bjt, sorry about that.The non standard models are:Code:.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.Quote from: Hero999 on August 19, 2018, 08:38:08 pmThanks, I'll see if I can figure out if that's what's going on here. First lesson learnedQuote from: Hero999 on August 19, 2018, 08:38:08 pm...and second lesson learned.Quote from: Hero999 on August 19, 2018, 08:38:08 pmGreat stuff, I'll check that out, thank you

author: james_s
author_rank: Super Contributor
timestamp: August 20, 2018, 05:41:32 am
content: 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.

author: dazz
author_rank: Frequent Contributor
timestamp: August 20, 2018, 05:49:54 am
content: 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

author: james_s
author_rank: Super Contributor
timestamp: August 20, 2018, 05:55:53 am
content: 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.

author: dazz
author_rank: Frequent Contributor
timestamp: August 20, 2018, 06:09:51 am
content: Quote from: james_s on August 20, 2018, 05:55:53 amThat's the idea, I'd like the leds to get progressively brighter as temp increasesQuote from: james_s on August 20, 2018, 05:55:53 amOK, I'll do some measurements with one LED alone at different current levels to see how much brighter they get as the current increases

author: Zero999
author_rank: Super Contributor
timestamp: August 20, 2018, 08:09:33 am
content: Quote from: dazz on August 20, 2018, 05:49:54 amThat 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.

author: dazz
author_rank: Frequent Contributor
timestamp: August 20, 2018, 08:47:28 am
content: Quote from: Hero999 on August 20, 2018, 08:09:33 amThanks. 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...

author: dazz
author_rank: Frequent Contributor
timestamp: August 20, 2018, 09:23:31 am
content: 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

author: Zero999
author_rank: Super Contributor
timestamp: August 20, 2018, 11:27:30 am
content: Quote from: dazz on August 20, 2018, 09:23:31 amIt'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.

author: dazz
author_rank: Frequent Contributor
timestamp: August 20, 2018, 02:47:18 pm
content: Quote from: Hero999 on August 20, 2018, 11:27:30 amWell, 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.

author: james_s
author_rank: Super Contributor
timestamp: August 20, 2018, 03:25:05 pm
content: 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.

author: dazz
author_rank: Frequent Contributor
timestamp: August 20, 2018, 06:16:05 pm
content: 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. 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

author: Zero999
author_rank: Super Contributor
timestamp: August 20, 2018, 07:07:00 pm
content: Quote from: dazz on August 20, 2018, 06:16:05 pmWhich circuit did you build? None of the circuits you've posted in this thread should fail like that.

author: dazz
author_rank: Frequent Contributor
timestamp: August 20, 2018, 07:15:04 pm
content: Quote from: Hero999 on August 20, 2018, 07:07:00 pmThe last one, the one with the darlington MPSA13's. Maybe the heat was affecting the LEDs even more than the transistors?

author: Zero999
author_rank: Super Contributor
timestamp: August 20, 2018, 08:04:31 pm
content: Quote from: dazz on August 20, 2018, 07:15:04 pmThe 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.

author: dazz
author_rank: Frequent Contributor
timestamp: August 20, 2018, 08:25:07 pm
content: With one of these. I'll double check everything, thanks a lot

author: dazz
author_rank: Frequent Contributor
timestamp: August 21, 2018, 02:54:49 pm
content: 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!I also scavenged three C946 NPN transistors from an old, dead computer power supply I had forgottten about, maybe those perform better temp wise

author: dazz
author_rank: Frequent Contributor
timestamp: August 21, 2018, 05:11:54 pm
content: It's a lot better with those NPN's, just as Hero predictedNow 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

author: dazz
author_rank: Frequent Contributor
timestamp: August 21, 2018, 07:05:18 pm
content: Quote from: Hero999 on August 20, 2018, 08:04:31 pmBTW, I misread the current there. The red LED went from 150uA to almost 2mA, not 150mA & 2A. The yellow one was probably above 20mA

author: Eka
author_rank: Regular Contributor
timestamp: August 21, 2018, 08:07:48 pm
content: Quote from: james_s on August 20, 2018, 05:41:32 amWith 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.pdfSo 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.

author: dazz
author_rank: Frequent Contributor
timestamp: August 21, 2018, 08:24:10 pm
content: Quote from: Eka on August 21, 2018, 08:07:48 pmI know the gradual intensity thing is far from optimal, but it goes well with the overall shoddiness of my amp buildI'll definitely keep those suggestions in mind and will eventually do it "the right way". Thanks for the info, EkaETA: just to add a video by Dave showcasing the LM3914

author: dazz
author_rank: Frequent Contributor
timestamp: August 30, 2018, 08:20:40 pm
content: 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

author: Zero999
author_rank: Super Contributor
timestamp: August 31, 2018, 08:06:51 am
content: 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.

author: dazz
author_rank: Frequent Contributor
timestamp: August 31, 2018, 12:09:00 pm
content: Cheers Hero. I really need to learn to read datasheets more carefully."Output Load Current... max 50uA"doesn't get much clearer than thatQuote from: Hero999 on August 31, 2018, 08:06:51 amWouldn't that opamp need to be full rail to rail output?

author: Zero999
author_rank: Super Contributor
timestamp: August 31, 2018, 12:44:51 pm
content: Quote from: dazz on August 31, 2018, 12:09:00 pmWhy do you think you'd need full rail to rail operation?What range of voltages are you expecting from the temperature sensor? As long as the op-amp's inputs and outputs work over the range of voltages from the temperature sensor, then it will be fine.

author: dazz
author_rank: Frequent Contributor
timestamp: August 31, 2018, 01:05:14 pm
content: Quote from: Hero999 on August 31, 2018, 12:44:51 pmThe sensor output range is 100mV to 2V, but I'm just using the interval between 800mV - 2V really.I'm confused now. The reason for my concern is that I simulated the buffer with a TL082 (that's the only opamp I have right now) and the output doesn't go all the way to zero. The TL082 datasheet states that the voltage swing for a +/-15V supply is -13.5 to +13.5V which seems consistent with the simulation showing the buffer kicks in when the input voltage gets above 1.5VIf I'm reading the datasheet correctly, the LM358's swing is pretty much the same:"Input Common-Mode V+−1.5 VVoltage Range

author: Zero999
author_rank: Super Contributor
timestamp: August 31, 2018, 02:58:16 pm
content: Quote from: dazz on August 31, 2018, 01:05:14 pmYes, the TL082 is unsuitable for this because its inputs don't function close enough to the negative rail.The LM358 should be fine for what you're doing. The part of the data sheet you've quoted is the maximum i.e. the highest end of the common mode range, which is V+-1.5V. The lower end is 0V and is specified with a single 5V supply. In other words, the LM358 will work with its inputs between the voltage on pin 4 and pin 8 minus 1.5V. In fact the LM358 is slightly better than the data sheet suggests because it will work when its inputs are slightly below 0V, down to about -0.3V but it's not guaranteed to, so be cautious about using it in designs where it inputs can go too negative.In short you don't need a rail-to-rail op-amp, just a single supply op-amp, which the LM358 is.

author: dazz
author_rank: Frequent Contributor
timestamp: August 31, 2018, 03:13:55 pm
content: Oh, I see.thanks again, Hero

author: dazz
author_rank: Frequent Contributor
timestamp: August 31, 2018, 04:16:44 pm
content: I love LTSpice, I just love it

author: Zero999
author_rank: Super Contributor
timestamp: September 01, 2018, 06:13:31 pm
content: Quote from: dazz on August 31, 2018, 04:16:44 pmI love LTSpice too, but be careful, it can trip you up. It's easy to design a bad circuit which will work perfectly in LTSpice but perform really poorly or not work at all, in real life.Here's an example..asc filehttps://www.eevblog.com/forum/projects/unstable-dc-opamp-sinusoidal-signal-centering/msg1714391/#msg1714391

author: dazz
author_rank: Frequent Contributor
timestamp: September 01, 2018, 07:34:08 pm
content: Quote from: Hero999 on September 01, 2018, 06:13:31 pmI understand that there are limitations to what spice can simulate and I will definitely follow your advice. I'm wondering if swapping the universal opamp for a TL082 would make it fail the way it does in real life

author: Zero999
author_rank: Super Contributor
timestamp: September 02, 2018, 09:51:06 am
content: Yes, the circuit will not work with the TL082, because its inputs need to be a couple of volts from the TL082's negative rail for it to work. A single supply op-amp, such as the LM358 is required for it to work.

author: dazz
author_rank: Frequent Contributor
timestamp: September 02, 2018, 10:08:52 am
content: Quote from: Hero999 on September 02, 2018, 09:51:06 amI don't understand why the circuit you posted wouldn't work in RL though. The inputs of the opamps are nowhere near -15V at any time, right?Also, the simulation I did with the TL082 seems to suggest that it would work simply by adding a coupling cap at the OP output. What am I missing here please?

author: Zero999
author_rank: Super Contributor
timestamp: September 02, 2018, 10:35:10 am
content: Quote from: dazz on September 02, 2018, 10:08:52 amPlease disregard my previous post. It was about the temperature indicator circuit, not the circuit I posted.The circuit I posted will not work because the two op-amps will not have exactly the same gain and offset voltages, as is the case with component models. U1 is operating as an inverting amplifier, with a gain of 10 and as you can see, is working perfectly in your circuit. The problem is U2 which has no negative feedback and is operating open-loop. In your circuit, the TL082 model must work slightly differently, when the inputs are connected the opposite way, presumably because of its offset voltage, which is taking the output more positive, but it still has the same gain, so the signal is the same amplitude. If you built this in real life, expect this to be worse. U2's output will most likely saturate at either supply rail. It might also output a square wave or a very tiny signal biased somewhere in between the power rails. The behaviour will be unpredictable, because the open loop gain and the offset voltage of U2 is unknown.

author: dazz
author_rank: Frequent Contributor
timestamp: September 02, 2018, 11:20:19 am
content: Gotcha! Thanks for the detailed explanation. So I guess that's why open loop configurations are used only for things like comparators & ADC's where they're supposed to operate with the output at the rails

author: Zero999
author_rank: Super Contributor
timestamp: September 02, 2018, 06:31:48 pm
content: Quote from: dazz on September 02, 2018, 11:20:19 amYes, op-amps are only used open loop in comparator applications. The negative feedback in a linear circuit stabilises the gain, so the op-amp's open loop gain makes little different to the total gain of the circuit.