help creating analogue temp and fuel guage

Thread Starter

Bear_2759

Joined May 23, 2008
120
The problem is that a standard bjt 555's output doesn't go all the way to Vcc; it's about Vcc-1.7v. That might cause a P-ch MOSFET to be conducting in linear mode (ie: high resistance) which you don't want. That's why a driver is necessary.
aahhh, I get it now... so a driver, I'm taking a bit of a stab in the dark here as I've never worked with transistors or MOSFETs before so combining the two in one circuit should be fun.

my understanding of transistors is that they amplify the voltage applied to the base, so if 555 Vout is roughly Vcc-1.7v then it will be (roughly) 12.3v, the transistor will try to amplify that as much as it can but the highest it will be able to go is Vcc. so when there is 12.3v applied to transistor base, emitter = Vcc = MOSFET source

output from 555 -> transistor base
transistor Emitter -> MOSFET Gate
MOSFET Drain -> LED VCC
Transistor collector and MOSFET Source both connected to V+

am i close or way off the mark?


That's the basic idea. It doesn't have to be terribly precise. Targeting 200Hz would give you a pretty large degree of leeway for faster or slower.
Ok so it doesn't really make much difference from 100-200 when it comes to heat that is produced...


Hardly any at all, if a decently sized MOSFET (or pair of them) is selected.

First, you'll need to total up how much current all of the LEDs will draw if they were all ON and at maximum brightness. Then, you look for a MOSFET that is capable of a continuous drain current (Id) of twice or more that amount of current.
so going from my previous calculations a mosfet that can handle 8-10A should be exactly what I need for both circuits...

I'm a hand's on person so will understand fully how a MOSFET works when I can get some to play with... my plan is to drop into the local shop after christmas but before the new year and get some to play with...
 

SgtWookie

Joined Jul 17, 2007
22,230
OK, here's a PWM circuit for you. Refer to the attached. If you'd like, you can go to Linear Technology's site and download/install their free LTSpice/SwitcherCad software that is available for free, and then download my attached .asc file to fiddle with.
http://www.linear.com

V1 on the far left represents your vehicle's 14v (nominal) power supply when running.

U1 is your standard bjt 555 timer/oscillator.
C1 is an electrolytic capacitor (25v rating minimum); it's necessary to surpress the large glitch that happens when the 555 toggles states.
C2 is the timing capacitor, 47nF = 0.047uF, ceramic or tantalum.
C3 is recommended to help keep the control input stable; you can omit it if you wish.
R1 limits the minimum and maximum duty cycle to about 5% and 95%. This is to prevent high currents in D1 or D2 if you're at the far limits of pot R2A/R2B, which will help keep the rise/fall times on the MOSFET gate nice and low.

R2A/R2B is actually a single 200K Ohm potentiometer. LTSpice doesn't have potentiometers in it's default libraries, so I just divided 200k/2, and each side wound up with 100k. You can change the values if you'd like to see what happens to the duty cycle of the output when you change the "pot" - just make sure they total up to 200k, otherwise you'll thrown the timing off.

D1 and D2 control how C2 gets charged/discharged through the pot.

R2 limits the current through the base of Q1. If R2 is too small of a value, the 555 will get "stuck".

When conducting, Q1 pulls the MOSFET gate low (Vds >= -10v) via R4 and D3.
When Q1 gets turned off, R3 pulls the base of Q2 high so that the MOSFET gate gets charged to nearly Vds = 0v rapidly.

D99 and R99 are just simplified representations the LEDs and current limiting circuts you'll have; in other words your load.

This isn't quite the entire circuit; there are a couple of protection items that have been deliberately left out to try to keep things simple. (I know, too late... ;))

Note that if you change the three diodes to Schottky-type (like 1N5817) your driver waveform will improve considerably (because the Schottky diodes switch quickly and have a lower Vf, or forward voltage) but that will also increase the speed of the 555 timer circuit. To slow the timer back down to within the 100Hz-200Hz range, you would need to change C2 to around 100nF (0.1uF)
 

Attachments

Thread Starter

Bear_2759

Joined May 23, 2008
120
I've been playing around with LTSpice quite a bit... love it. I've been playing arround with different values for resistors & caps etc so now I have a much better understanding of what is going on.

when you say a few protection items have been left out, do you just mean a few diodes? if so I have plenty of spare diodes (bought a bulk lot cheap a while ago)

through the christmas break I attempted to go to my local parts shop to get what I needed. however, with allot of what I didn't have they either didn't have any stock and weren't expecting any for a month or two:confused: or they only had an "equivelant" that is usually overpriced anyway...

so... I've just ordered what I need for the PWM on the net and it should arrive in a week or two. looking forward to it.:)

with the temp circut, I may have overlooked something... the example that they have in the datasheet is roughly 0-30°C display, 100mV/°C
so at 30°C output from the LM35 is 3.075V (if the circuit is tuned correctly)
I need to have a display of 0-125°C, the full range that the LM35DZ is capable of. with their standard circuit 125°C would be 12.575V or pretty close to. but, I've only got a 7V source (would like to keep it that way:rolleyes:).

I would like your input on what I have thought are the three options I have.

1. remove the 3 resistors and cap connected to LM35 Vout and GND. this will give a 10mV/°C increase so will range from 0-1.25V. then mess around with the resistors between pin 4 and 6 on both IC's aswell as the ones that go from pin 4 (IC1) to GND so that the Ref(lo) on IC1 is 0v and the Ref(hi) on IC2 is 1.25v.

2. change circuit source to 12v (13.4) and take Ref(hi) of IC2 straight from source, then adjust resistors between that and Ref(lo) of IC1 to suit.

3. increase 200Ω resistor between LM35 Vout and GND so output is 50mV/°C (0.075v=0°C - 6.197v=125°C). the extra .075 is just what they have on the datasheet for this example, I'm not sure if it would change if the circuit was modified in the way I am thinking. I would then need to increase the Ref(hi) of IC2 to 6.2v. but not 100% sure how to go about this...

My guess is option 3 would be best, but most complicated. I attempted to re-create the circuit in LTSpice but couldn't find a model for the LM3914 on the net:(, however did find the LM35. if I had this I could very easily work out what I need to change.
 

SgtWookie

Joined Jul 17, 2007
22,230
I've been playing around with LTSpice quite a bit... love it. I've been playing arround with different values for resistors & caps etc so now I have a much better understanding of what is going on.
Fun stuff, eh? :)

when you say a few protection items have been left out, do you just mean a few diodes? if so I have plenty of spare diodes (bought a bulk lot cheap a while ago)
Well, currently there is no protection for overvoltage from your electrical system. A Zener and resistor needs to be added to protect the 555 timer, and another Zener/resistor should be added to the gate driver circuit so that Vgs will be limited. It's really late here and I haven't looked at this for awhile.

through the christmas break I attempted to go to my local parts shop to get what I needed. however, with allot of what I didn't have they either didn't have any stock and weren't expecting any for a month or two:confused: or they only had an "equivalent" that is usually overpriced anyway...
If they try to sell you NTE stuff, you'd likely be better off ordering it from the UK.
with the temp circut, I may have overlooked something... the example that they have in the datasheet is roughly 0-30°C display, 100mV/°C
so at 30°C output from the LM35 is 3.075V (if the circuit is tuned correctly)
I need to have a display of 0-125°C, the full range that the LM35DZ is capable of. with their standard circuit 125°C would be 12.575V or pretty close to. but, I've only got a 7V source (would like to keep it that way:rolleyes:).
I don't see which example you're looking at, in which datasheet?

I'm looking at National Semiconductor's datasheet for the LM35. On the very first page, the Basic Centigrade Temperature Sensor (2°C-150°C) gives an output of 10mV/°C. At 125°C, the output would be 1250mV, or 1.25v.

I would like your input on what I have thought are the three options I have.

1. remove the 3 resistors and cap connected to LM35 Vout and GND. this will give a 10mV/°C increase so will range from 0-1.25V. then mess around with the resistors between pin 4 and 6 on both IC's aswell as the ones that go from pin 4 (IC1) to GND so that the Ref(lo) on IC1 is 0v and the Ref(hi) on IC2 is 1.25v.

2. change circuit source to 12v (13.4) and take Ref(hi) of IC2 straight from source, then adjust resistors between that and Ref(lo) of IC1 to suit.

3. increase 200Ω resistor between LM35 Vout and GND so output is 50mV/°C (0.075v=0°C - 6.197v=125°C). the extra .075 is just what they have on the datasheet for this example, I'm not sure if it would change if the circuit was modified in the way I am thinking. I would then need to increase the Ref(hi) of IC2 to 6.2v. but not 100% sure how to go about this...

My guess is option 3 would be best, but most complicated. I attempted to re-create the circuit in LTSpice but couldn't find a model for the LM3914 on the net:(, however did find the LM35. if I had this I could very easily work out what I need to change.
Well, it's really late now, and my head is starting to hurt. :rolleyes: I'm going to have to look at this later on.
 

Thread Starter

Bear_2759

Joined May 23, 2008
120
I don't see which example you're looking at, in which datasheet?
sorry, I've been using the example on the top of page 9, but now am thinking of scrapping that and going with just the basic 7V in, 10mV/°C out. part of my problem was not fully understanding how the 3914 ref out and ref adj worked... but after reading another post you were also involved in (below) I'm starting to get it, just reading a LM317 datasheet to understand them:D...

http://forum.allaboutcircuits.com/showthread.php?t=17338

Well, it's really late now, and my head is starting to hurt. :rolleyes: I'm going to have to look at this later on.
No Rush, it's only 7pm here at the moment so as soon as bubs goes to bed I'll have a few hours of reading time and should fully understand how it works... my main problem is getting my head around maths again... while I did do advanced maths at school with ease, it has been 5 years since I actually applied it to anything:rolleyes:... so even some of the basics like algebra (which is needed with just about anything) were a little confusing to begin with, just had to slow myself down and it all came back though:p...

so far I've managed to stumble through the electronics I have done with as little maths as possible. but I've been reading through Vol 1-DC on this site and am realising I'm only making it more difficult for myself not refreshing my memory... I'll post a circuit that I think will work later tonight and see what you think...
 

Thread Starter

Bear_2759

Joined May 23, 2008
120
ok so attached are two documents, after attempting to do the maths I realised I wasn't sure what the current would be out of the ADJ pin on LM3914... so after attempting that I remembered I had a LTSpice model for the LM317, can't remember if that one came with or if I downloaded it... playing around with 2 resistor values 1 between Vout and Adj, the other from ADJ to GND I got it close to 1.25V on Vout (1.28). Then that little light globe above my head switched on. I need 1.25V, and the diff between REF Adj and REF out is 1.25V so (a small assumption on my part) if I connect REF Adj to GND then REF out will be 1.25V.

at the moment R1-R3 are all the same, decided to split the gauge into equal parts for now, may even stick with that but now I know all I need to do is adjust those 3 resistors accordingly.

Im not sure what to do with the REF out of the first to IC's (U2 and U3 in diagram)

in the second diagram I've added a small section from and example on the LM3914 datasheet (top of page 13). this is R4, R5 and C1. apparently this will make the whole gauge flash when the LED connected to the junction between R4 and C1 lights. I'm not sure what value to set R5 at and I have excluded the 1.2K resistor from REF out to GND on the example... not really sure why:rolleyes:..

is there anything you think I should add, remove, change?
 

Attachments

Thread Starter

Bear_2759

Joined May 23, 2008
120
if it would make things a bit easier for now we can leave out the flashing part of the diagram I mentioned in my earlier post.
 

SgtWookie

Joined Jul 17, 2007
22,230
Hi Bear,
Sorry I'm so slow in responding; there have been lots of requests for help and I'm a bit inundated at the moment.

But to let you in on my train of thought...

The output of the LM35 will be approximately 10mV/°C from 2°C to 125°C, which gives a range of about 2mV to 1.25v.

One of the problems here is that the internal regulator in the LM3914 IC does not have an exact 1.25 voltage difference in the reference circuit. It's a nominal value. It might be 1.22v, or it might be 1.28v, or anywhere in between.

So, what needs to be done is to offset the LM35's voltage to be higher than what the maximum Vref might be.

The easiest way to do this might be to use a switching diode, like a 1N4148 - but there is a big problem with that idea, because the diode's Vf will change over temperature, and make your gauge non-linear.

A fixed resistor from the LM35 to ground might be the best solution, but I'm not certain what the quiescent sink current of the LM35 is at the moment. It looks like it's 40uA @ 0°C, but it may vary up to perhaps 0.12mA

If the quiescent current is indeed 40uA, then a resistance of 25k from the ground terminal to GND will result in a 1v increase in the output voltage, 50k will result in a 2v increase.

I'm going to have to do some breadboarding on this.
 

Thread Starter

Bear_2759

Joined May 23, 2008
120
hmmm... interesting...

well to save a bit of time, I have a LM35 model in LTSpice at home, (I'm at work for another 30min). as soon as I get home I will test it out and see what happens.

also to make life a bit easier for myself because I use them so much at the moment I'm attempting to create a LTSpice model, or more a sub-circuit of the LM3914... getting there but it's difficult...

It might be 1.22v, or it might be 1.28v, or anywhere in between.
is that on the datasheet? I'm guessing 1.25V ±2.5%? I've read over the datasheet for the LM3914 probably 20 times but still there are things I've missed...:D

with increasing the Vout of the LM35, and increasing the LM3914 REF(hi) and REF(lo) to suit, wouldn't we just be increasing the voltage range that the problem occurs on?

it may make it a much more complicated circuit but might it be better to create an additional part of the circuit that works out the difference between the 1.22-1.28 and a referance voltage (1.25) and add that back to the 1.22-1.28?

I appologise if that doesn't make sense :p, it does in my head but it's been a long day, I'll attempt to put a cct togeather tonight that will better explain it.
 

Thread Starter

Bear_2759

Joined May 23, 2008
120
ok so the LTSpice model I have for the LM35 was not designed to test what we want... it merely does the 10mv/°C output... however Datasheets can be very usefull, 40uA is the typical Quiescent Current at 0°C..
 

Thread Starter

Bear_2759

Joined May 23, 2008
120
it may make it a much more complicated circuit but might it be better to create an additional part of the circuit that works out the difference between the 1.22-1.28 and a referance voltage (1.25) and add that back to the 1.22-1.28?
forget this idea... after thinking about it and starting to put it together in LTSpice it ends up making it way more complicated than it needs to be... :rolleyes: unless you can think of a very simple way of doing it.:p. what I was thinking of would have ended up making the whole circuit at least double it's original size...
 

SgtWookie

Joined Jul 17, 2007
22,230
OK, I think this'll take care of the problem.
See the attached schematic.

The LM2904 is a dual opamp that is designed for automotive use. It is a single-supply opamp, and the common input mode extends to ground, which is what we need. It's a very old and slow opamp, but it should work just fine for this application.

Basically, it multiplies the amplitude of the LM35 signal by 4, and adds a slight offset voltage that will amount to 8mV after amplification, or just slightly less than 1°C. The output of the opamp will range from roughly 88mV to 5.08mV.

The 2nd half of the dual opamp isn't used, so for simplicity it's connected as a voltage follower (you don't want to leave opamp inputs flapping in the breeze, or you'll have problems).

Not shown is a 0.1uF (100nF) cap across the opamp's supply pins.
 

Attachments

Thread Starter

Bear_2759

Joined May 23, 2008
120
looks good... I'll see if I can get my hand's on a LM2904 this weekend and add it to what I already have on my breadboard.
 

Thread Starter

Bear_2759

Joined May 23, 2008
120
quick question, will I be able to substitue the IRF7207 with a IRF7204? I couldn't find the 7207 at any of my usual's but the 7204 was available. I did check and most of the specs are pretty close so from what I can see I should be able to do a straight swap without any noticeable changes.
 

SgtWookie

Joined Jul 17, 2007
22,230
Sure, you could use an IRF7204. The 7204 has a higher gate charge than the 7207, but you'll be running it at such a low frequency that shouldn't matter.
 

Thread Starter

Bear_2759

Joined May 23, 2008
120
well... some of my toys arrived today... a whole lot of resistors, 2-300... and 20 of the BC547B Transistors... I figured they'd be usefull to have a few on hand.:)... apparently half of it is on backorder so I might need to wait another week or two, that's a shame...:( and there is also some others that I ordered from my other supplier that usually takes 2-3 weeks to send to me... they're allot cheaper, but take allot longer to get things to me... oh well, it kind of adds up in the end... sadly I dont have enough parts to start working on one of the 3 that I ordered parts for... still missing a few for each
 

Thread Starter

Bear_2759

Joined May 23, 2008
120
ok, so some more toys have arrived today from supplier #2... I should have everything I need to complete the Temp ckt, so I'll start breadboarding that tonight... still waiting for the things on backorder which are for the PWM circuits... :(... I'll let you know what happens with the temp ckt...
 

Thread Starter

Bear_2759

Joined May 23, 2008
120
so the temp sensor is working... :D ...I didn't get to it yesterday but have spent around 6 hours on it today... 5 of which were trying to work out why I had a graph in dot mode when I clearly had 12V on pin 9 of the LM3914... I wasn't even looking at the current on different pins untill the end of the 5 hours and realised, I had the following on the low end 3914 IC...
ref Out -> GND
ref Adj -> 3.3k -> GND

it should have been the other way around... working now...

I'm still waiting for 1 or 2 things for the PWM circuits, hopefully that'll show up tomorrow.

I also need to create a oil pressure ckt, I should be able to use the same ckt as the fuel guage with a few mods (it's another one that just changes resistance to GND) however I think the stock sensor is just a simple open/closed type for the itiot light on the dash... not a variable sensor... but I can work that out now I think.;)

I think now with what I have learnt from doing all this for the fuel/temp/pwm ckts I'm going to take a step back and re-do the Tach circuit... I can now see it can be a bit simpler with a few changes...

thanks for all your help Wook, you've been great... I'll let you know what happens with the PWM and I'll post pics of the finished dash.

it's time to start doing some CAD work for the dash panel...
 

Gibson99

Joined Jul 12, 2009
9
Found this thread and read through it almost entirely... my green will probably show here, as i know a lot less than the original poster; i only have a basic grasp on the VERY basics of DC electronics. I can install simple car alarms, stereos, dvd players, etc all day long, but when it comes to actually DESIGNING this stuff, well... let's just say i'm still learning.

I am already part way into completely redoing the gauge cluster in my car as well, and have found some great resources here and here and here, among other places.. i'm fairly confident that i can build the circuit just fine. the fabrication will be the hardest part - making it look good.

i found a guy who used a single lm3914 to make a VERY basic tach for his car, and it looks like dimming the LEDs at night will be a pretty simple affair based on his schematic located about 1/2-way down the page. my question is - will i need a copy of his "section for headlight auto-dimmer" for each individual 3914, or can i just feed all of them from just one circuit? I plan to have a total of 10 lm3914's in my new gauge cluster: 3 for tach, 3 for speedo, 2 for vacuum/boost, and 1 each for fuel level and coolant temp.

One other question - when using the 3914 in bar mode, apparently you can wire it up so that the whole display will flash when a specific led comes on. This would be ideal as a shift light in the tach, or as posted earlier, a warning light for over-temp. or maybe even a warning for when you're speeding. ;) my question is, do you simply reduce the size of the capacitor in the flash circuit to make it flash faster, and if so, how much should you reduce it by to get something like a 4-6hz flash?

An alternative to the flashing "shift light" would be to operate the tachometer in dot mode, and rather than using a single led to trigger flash mode, use that led to trigger a solid state relay that puts the tach into bar mode - suddenly lighting up the entire tach rather than a single led. or maybe a combination of the two - switch from dot to bar AND flash it rapidly, creating even more of a sense of urgency.

one last comment... my factory fuel gauge is fluid-damped, so it simply can't move quickly - most cars seem to be this way, causing it to take 2-3 minutes to move from E to F when you refuel. is there any way to "damp" or average the signal coming from the float in the tank so that when fuel is sloshing around in there, the fuel gauge isn't wildly oscillating? for anyone else who's already done this, is this even an issue?
 
Last edited:
Top