Please laugh with me, point sticks and tell me what is wrong  - Page 1
Forum section: electronics / general

author: Simon
author_rank: Unknown
timestamp: January 11, 2013, 09:26:57 am
content: We have been nutty enough to buy the attached circuit on strip board for an urgent project (despite the fact I could probably make it from scratch my way faster but you know.... management!)Is it just me or is this circuit totally screwed up and causing about as many problems as it solves. It is supposed to be a thermostat for the relay of a compressor clutch for an air con system to work between 3 deg C and 23 deg C with a hysterisis of 3-4 deg C so that the clutch does not keep coming on and off. I am going around in circles, and it seems that it won't switch when the sensor reaches the higher range.Resistance values on the chart are in K ohmsI am a little concerned that an op amp was used rather than a comparator, as far as I can tell it is an inverting amplifier with a gain of about 15 and a varying "0" point.

author: qno
author_rank: Frequent Contributor
timestamp: January 11, 2013, 09:37:46 am
content: What are the numbers in the sheet?

author: Simon
author_rank: Unknown
timestamp: January 11, 2013, 09:40:44 am
content: you mean the ones on the left ? that is the value in K ohms of the sensor at different temperatures

author: qno
author_rank: Frequent Contributor
timestamp: January 11, 2013, 09:56:46 am
content: Did you measure this in-circuit?

author: Simon
author_rank: Unknown
timestamp: January 11, 2013, 10:02:03 am
content: no they were measured with the probe disconnected.

author: TerraHertz
author_rank: Super Contributor
timestamp: January 11, 2013, 10:17:01 am
content: It's supposed to have hysteresis, but the op amp feedback is connected to the inverting input. Giving linear operation.Should be connected to the + input. Without even thinking about whether the values are sane.Edit: So there's a teeny bit of hysteresis provided by the schmitt trigger input of the 4096. Which will vary with the supply voltage.I wonder what geni-arse(sic) designed this?Edit2: Also, I'm having trouble finding data in the IN5365 zener. What?! What voltage is it? And why is it there?Purpose is maybe to prevent exceeding CMR on the op amp if the sensor is unplugged? But it will have some leakage current, and that's going to cause sensor inaccuracy. Same with the reversed IN4004, though not so much.

author: blackdog
author_rank: Frequent Contributor
timestamp: January 11, 2013, 10:19:02 am
content: Hi Simon, :-)This will not work the way you want it...There is no hysterisis, only gain.The feedback resistor should be going to the + input of the opamp.You have to do the math for the 51K and the 470K resistor for the 3C hysterisis.Kind regartsBlackdog

author: Kremmen
author_rank: Super Contributor
timestamp: January 11, 2013, 10:19:37 am
content: Quote from: TerraHertz on January 11, 2013, 10:17:01 amYou beat me to it. Exactly the same observation: the amp is working as an amp, not a comparator. It doesn't make sense in the context of this application - you want a comparator, not an amp per se.You sure the feedback goes to the neg input actually?

author: Simon
author_rank: Unknown
timestamp: January 11, 2013, 10:23:40 am
content: yes it does go there, I suspect the person supplying the diagram is having us on in case we try to make it ourselves instead of pay him to, we in turn had it made by someone else cheaper and the result is that I've spent a week trying to work out what my employers is doing with the output, what control positions they want to do what and any errors made by the guy who made it.

author: Kremmen
author_rank: Super Contributor
timestamp: January 11, 2013, 10:36:19 am
content: Sure is a lot of work for an essentially trivial thing like thatJust make it yourself and don't confess if they ask %-B

author: TerraHertz
author_rank: Super Contributor
timestamp: January 11, 2013, 10:37:19 am
content: I can sort of see his thought process. He used the op amp to scale the sensor signal, then low pass filtered it with an RC, then used the 4096 to provide a (roughly) constant amount of hysteresis. I bet the sensor is wired some distance away, right? And maybe the +12V supply is horrible - noisy and varying - especially when the output load (a relay?) is turned on or off. Thus feedback from output state to all the imperfections in the circuit, providing a complex behavior mess.

author: Simon
author_rank: Unknown
timestamp: January 11, 2013, 10:56:21 am
content: I have wired up a second board and it is working now to a fashion although I still have heating and cooling reversed but that is probably due to use using a NC relay instead of a NO relay. The sensor could be some distance away and the power supply was in the box, we now have the op amp section working off 28V and the NAND gate working off 12V from a regulator (a mod the assembler made). The problem with this circuit is that it seems to be very convoluted and unless you wire it up just right it all goes very very wrong. This guy is very old school. I'd have used a micro probably as there are other circuits needed like fan speed controls. In any event it could have been more simply built with a proper comparator and using a mosfet on the output.

author: qno
author_rank: Frequent Contributor
timestamp: January 11, 2013, 11:25:23 am
content: The inverter is there because the circuit is working in the oposite way.As temperature rises the output will go low.He should have connected the sensor between +12V and the input and swap the + and - input of the opamp.The hysteresis resistor should go to the + of the opamp as described before.Hysteresis is a bit variable due to the change in sensor resistance.You will have to find a good compromise over the temperature range.Power supply disturbance can be solved by operating the circuit on 5V generously decoupled.You can stick the circuit on an experimenters board.Is he using any of the other opamps in the LM124 or other gates of the 4093?

author: Simon
author_rank: Unknown
timestamp: January 11, 2013, 11:43:42 am
content: he is using only one opamp and one gate. He seems to be using the gate for the hysterysis as we have establishded that at the moment the circuit is working as a differential amplifier essentially. So what I will do now is use another gate to re negate the output to what we want.

author: Simon
author_rank: Unknown
timestamp: January 11, 2013, 02:34:09 pm
content: adding another not gate just kept the output permanently on, The guy doing the wiring has finally conceded to just swap his relay contacts (yes it took some bloody convincing) and I'll take the gate back out. I think the problem is that we now have the op amp on 28V and the logic gate on 12V and now that we realize that the gate is taking an analogue input in and is providing the hysteresis. Yes i could adapt it to power the whole thing from 12V but I've been told not to meddle any more in case we make more problems.

author: free_electron
author_rank: Super Contributor
timestamp: January 11, 2013, 03:57:38 pm
content: Really? 1/4 of an 424 and 1/4 of a 4093 to make an invertor ( schmitt i know )Could be done usong 1 lm393... First half comparator , second half comparator with hysteresis. The delay is the rc constant between them...

author: Simon
author_rank: Unknown
timestamp: January 11, 2013, 04:19:29 pm
content: yep quite although this is a section of schematic from a larger schematic so it could be that the rest were used elsewhere. Yes I'd have just used a comparator, but what is the point of a comparator followed by another comparator with hysterysis, surely the first will output high or low making a following one pointless ?

author: SeanB
author_rank: Super Contributor
timestamp: January 11, 2013, 04:27:43 pm
content: He did say point sticks...... Simon could do better with half the parts anyway.Anyhow you can use a comparator and do the logic right with it anyway first time.

author: Simon
author_rank: Unknown
timestamp: January 11, 2013, 04:41:49 pm
content: Quote from: SeanB on January 11, 2013, 04:27:43 pmQuite, that is what I don't understand this guy is just converting levels from positive to negative and back to positive. Am I deluding myself or can the hysteresis be made to work either way round ?

author: SeanB
author_rank: Super Contributor
timestamp: January 11, 2013, 05:15:25 pm
content: Yes, it will do an offset on either the input or the reference depending on how you wire the comparator, and this provides the hysteresis. providing you are not using multiple comparators off the same point it has no effect otherwise.

author: Simon
author_rank: Unknown
timestamp: January 11, 2013, 06:10:52 pm
content: whoever designed this is either very clever () or does not have a clue what he is doing.

author: miceuz
author_rank: Frequent Contributor
timestamp: January 11, 2013, 06:46:29 pm
content: I've made similar circuit just yesterdayI've used LM35 temp sensor and LM358. As I needed it to work somewhat in range of 0 - 4 C, I've added two diodes in series on the ground connection of LM35. As diode voltage drop drifts with temperature, I've added the same two diodes to bottom of trimpot and have chosen trimpot value so current thru it would be equal to quiscient current of LM35, so diodes drift the same, that sets the temperature point, buffered it with half of LM358 and used second half as a comparator with hysetesis. Just works..

author: helloworld922
author_rank: Regular Contributor
timestamp: January 11, 2013, 07:23:53 pm
content: I always thought this was the recommended way for designing a comparator circuit with hysteresis (attached circuit).Vhyst = R1 * (Voh - Vol) / (R1 + R2)Voh is the high output level (in this case pullup to relay source voltage) and Vol is the low output level (assuming an actual open collector/drain comparator, this should be 0).I have the pnp transistor in there which means if Vsense > Vref the coil will energize, otherwise it won't. You can of course just as easily have an npn transistor in there to do the opposite (or use MOSFET's instead).R3 is your variable resistance temp sensor, R4 is to provide a voltage divider to get Vsense.Reference:Analog Devices: Curing Comparator Instability with Hysteresis

author: lewis
author_rank: Frequent Contributor
timestamp: January 11, 2013, 08:31:57 pm
content: Simon, if you must use an op-amp instead of a comparator, use something like this (attached). I bet the designer of the original circuit stuck the logic gate in there because the output offset voltage of the op-amp when 'off' was enough to turn on the transistor driving the relay at all times. Putting a low value zener in the base circuit gets around this without resorting to a schmitt trigger. The 4.7K resistor provides enough pulldown to overcome the leakage of the zener. It might need to be lower, 1K-2.2K.The 1N914 diodes provide ESD protection for the op-amp if the temperature sensor is mounted remotely. Another pair of diodes will need to go on the set-point potentiometer if that is mounted remotely too.This circuit will energise the coil when the temperature is lower than the set point. If you want the relay to work the other way, reverse the inverting and non-inverting inputs, but move the feedback resistor to the non-inverting input and exchange the 1uF and 100nF caps. The 100nF is a bit low for noise smoothing, but speeds up the hysteresis action. Try changing it to 1uF. Or, just swap the temp sensor and it's pullup for the same effect.You'll need to select the unlabelled resistors for your application.You might want to run everything to the left of the relay coil from a voltage regulator if the supply is noisy or if it's likely to go over 32V, even transiently. The op-amp doesn't like it up it.The diode in reverse parallel with the relay coil is a 1N4007, transistor can be TIP122 if the relay is a big bastard, or BC337-40 or something if <50mA coil current. No zener in parallel needed.Remember, if you do use a comparator, it will probably have an open collector output and a pullup on its output will be necessary.In theory it's easy to do with bugger all parts, but in the real world where there's noise, ESD and crap, additional protection components are required. I've probably forgotten something, I'm sure someone will point out if so!

author: Simon
author_rank: Unknown
timestamp: January 11, 2013, 08:40:42 pm
content: if it were me I'd use a comparator, I have no idea what the hell he thought he was doing. I'd rather do it with a micro-controller and then the hysterysis would not be needed because I can just stipulate in software that the coil has to be off for at least a minute before it can be turned back on again, as all it is about is not overwhering the compressor clutch or relay, although I'd swap that for a mosfet.

author: Simon
author_rank: Unknown
timestamp: January 14, 2013, 11:47:00 am
content: If I just reverse the op amp inputs what will happen ? I tried it and my output just stayed on.

author: lewis
author_rank: Frequent Contributor
timestamp: January 14, 2013, 02:51:38 pm
content: Hi Simon, you need to make sure the feedback resistor always goes to the + input.So if you just reverse the inputs on the diagram I attached, the feedback resistor will now go to the - pin. You need to change this so it goes to the + pin.If you want it done with a microcontroller let me know. We do do customised design and product development on a daily basis, if you need things like this done on the cheap and very quickly, drop me an e-mail atwww.abeltronics.co.uk/contact

author: Simon
author_rank: Unknown
timestamp: January 14, 2013, 03:10:35 pm
content: I meant swapping the pins on the circuit I posted.we are sending these as they are (nuts I know, we have thermostats in stocks that cost a fiver each that we have used for years but they want this junk). Ultimately I am hoping to redesign the wholes thing myself with a micro to do thermostat, fan speed and a delayed power line to a small pump.

author: lewis
author_rank: Frequent Contributor
timestamp: January 14, 2013, 05:10:51 pm
content: Hi Simon, should be the same thing in theory. I suspect the output offset voltage of the op-amp is just enough to keep the gate triggered in one direction. What supply voltage are you using? It says 12V on the diagram but also 24V/28V DC next to where it says 12V. Don't power the gate from more than 15-18V whatever you do...I'd measure the output of the op-amp with a voltmeter while adjusting the preset pot, and do the same while heating the thermistor with your fingers or a soldering iron. Remember that circuit is configured as an amplifier, not a comparator, and is a complete lash-up. You're relying on the triggering threshold of the logic gate for the 'comparator' bit which is extremely variable. (Well, notextremelyas such, but extreme enough). You need to see what the op-amp output voltage is doing when you adjust the op-amp's inputs.I reallyreallywouldn't recommend using that circuit, it is far from satisfactory. The offset voltage and schmitt trigger threshold will vary with temperature and if you have a marginal design on the bench it will almost certainly fail in the real world. The microcontroller idea is much better, I've replaced plenty of comparators with microcontrollers in commercial designs in the past.

author: Simon
author_rank: Unknown
timestamp: January 14, 2013, 09:50:54 pm
content: I tried using the schematic in the PDF that someone posted to make a quick breadboard circuit. It was a mess with no hysterysis. I still ended up with op amp type behavior (fading LED) from an LM339..... surely the only way to have histerysis is to put a resistor from output to +input so that as the output switched the resistor is put in parallel with either one side of the other of the reference voltage divider or (assuming compatible) voltage divider formed by the sensor resistor and it's accompanying fixed resistor.

author: lewis
author_rank: Frequent Contributor
timestamp: January 14, 2013, 11:44:44 pm
content: Absolutely right! Were you using my circuit?

author: Simon
author_rank: Unknown
timestamp: January 15, 2013, 06:43:27 am
content: No I was trying to follow the analog devices pdf someone posted early on that gave formulas and everything but it had no histerysis when I tried it.http://www.analog.com/library/analogDialogue/archives/34-07/comparators/

author: Kremmen
author_rank: Super Contributor
timestamp: January 15, 2013, 07:31:17 am
content: Quote from: Simon on January 14, 2013, 09:50:54 pmIf you mean the hand drawn schematic then there is one small but crucial mistake: the comparator output is missing the collector pull-up resistor. If you use an LM339 or similar part, it has an open collector output that does not pull up actively. Thus the relay transistor is never driven properly, unless you insert a pull-up resistor into the circuit.Otherwise the hysteresis part is correct: it is done using positive feedback. But that also will behave strangely if you dont pull the output up properly.

author: Simon
author_rank: Unknown
timestamp: January 15, 2013, 07:53:26 am
content: No I was referring to the Analog Devices PDF that I linked to above. Yes I did use a pull up resistor.

author: helloworld922
author_rank: Regular Contributor
timestamp: January 15, 2013, 08:05:09 am
content: You mean the one I linked to (edit: I guess you linked to it, too)? It has hysteresis, but I think comparators might have troubles sinking significant current so they may not be able to drive the relay coil directly.My circuit used an additional transistor (I chose a PNP, but could be a P-channel MOSFET instead or the NPN/N-chan variant for opposite logic) to drive the coil.The one possible issue is I wasn't quite sure where the pullup resistor should tie up to (R6). I picked the relay power source so the transistor will be fully off/on on both high and low levels, but this may cause havoc on the rest of the circuit (haven't calculated it). R5 is used to limit base current so it may not be required if using a MOSFET solution.You do have the comparator in a positive feedback configuration, right?

author: Simon
author_rank: Unknown
timestamp: January 15, 2013, 08:10:27 am
content: yes I'd use a transistor too (a mosfet not a flipping darlington like this old fart did) but my concern at the moment is understanding and getting the comparator to work WITH histerysis.

author: Simon
author_rank: Unknown
timestamp: January 15, 2013, 08:44:55 am
content: The attached is what I deem to be a comparator with histerysis, the "sensor" could be any of those resistors to suit.

author: Kremmen
author_rank: Super Contributor
timestamp: January 15, 2013, 10:02:28 am
content: Yep, sure is. You can tell by the Mk 1 eyball but attached a snap simulation confirming the same. Sorry about the ridiculous comparator symbol, that was the best Multisim could come up with a moment's notice.By the way, you can't really have a voltage source connected to the comparator output. That will be an effective short when the output transistor conducts. I left that out and it simulates just fine without it.P.S. scope traces are color coded in the schematic. All traces 5 V/div.

author: lewis
author_rank: Frequent Contributor
timestamp: January 15, 2013, 12:57:28 pm
content: Quote from: Kremmen on January 15, 2013, 07:31:17 amMy circuit uses an op-amp, Simon seemed to want to use an op-amp.

author: Simon
author_rank: Unknown
timestamp: January 15, 2013, 12:59:13 pm
content: No I'm happy with a comparator, the idiot that designed the hand drawn schematic used an opamp, probably because he was using the other 3 for something else in the grander scheme of things.I generally have LM339's knocking around for breadboarding.

author: lewis
author_rank: Frequent Contributor
timestamp: January 15, 2013, 01:09:00 pm
content: Quote from: Simon on January 15, 2013, 08:44:55 amThis circuit should work mate, what's it doing?

author: Simon
author_rank: Unknown
timestamp: January 15, 2013, 02:02:17 pm
content: not tried it, we are currently bunging the nut jobs circuit in and forgetting it (along with some hashing up). Wrng i know, but I'm not in charge, I've already recomended we use the comercial thermostats we have around with the necesary protection circuitry added.

author: helloworld922
author_rank: Regular Contributor
timestamp: January 15, 2013, 03:50:41 pm
content: QuoteThat's one of the "oddities" of using TINA-TI: you add in "voltage measurement" components (VM1).Your circuit looks fine, though maybe a larger pullup resistor would work better? You're drawing ~12mA through the pullup when output goes low. The datasheet specs a min rated output current sink of 5mA which would cause Vo = 1.5V.QuoteYeah, it is funny why you guys don't use a commercial temperature trip sensor. These puppies have all this stuff built in and output a digital signal when the trip point is reached. Even have hysteresis built inI think Dave had a video where he ranted about dumb management (actually, a few different videos)...

author: Simon
author_rank: Unknown
timestamp: January 15, 2013, 04:27:14 pm
content: yea quite, it's called we conned ourselves out of the money we spent on them so now we must use them, we have commercial stats that do what we want but they won't use them.