# help creating analogue temp and fuel guage

#### Bear_2759

Joined May 23, 2008
120
My new toys finally arrived yesterday, I'm a bout to start playing around with some circuits now...

#### SgtWookie

Joined Jul 17, 2007
22,219
Oh, good

Let us know how things are progressing. Breadboard first, of course.

#### Bear_2759

Joined May 23, 2008
120
of course of course... I am an amature but have discovered the wonders of a breadboard...... part way through setting it up as per the example in the LM35 datasheet.. I was only able to get my hands on the LM35DZ but they should do...

#### Bear_2759

Joined May 23, 2008
120
I have a working circuit... pretty close to what the example was in the datasheet, just some resistors not quite what they had... but it was just to see how it works... all I can really see that I need to do now is a bit of maths to work out what the ref lo and ref hi should be on each 3914 IC. I was thinking of setting it up so that the first 10 LED's are 0-65°C and the second is 66-100°C. so I will have a higher resolution for the end of the scale where I need to know what the temp is... I'll just have to have some kind of indication/marking on the dash to show the different temps and where the res changes... your thoughts?

#### SgtWookie

Joined Jul 17, 2007
22,219
You could do that by adding a pot across the voltage divider network on the high-side LM3914 to obtain the fixed value you'll need.

The ends of the network are accessible on pins 4 (low) and 6 (high). The nominal sum of the resistance is 10k. Your mileage may vary.

Whatever resistance value you measure from pin 4 to pin 6 (everything else disconnected), multiply the result by 1.07, and use a resistor (or combinations of resistors) connected between pins 4 and pin 6. That will result in the output display you want.

#### Bear_2759

Joined May 23, 2008
120
While I'm playing around with the Temp circuit, could we take a step back and quickly work out the PWM controller? what kind of current can a basic PWM handle, preferably just using 555 timers as this is what I have... I'm working on a small project on the side for a mate of mine. he has a server rack and want's it lit up, Blue when the door is closed and White when the door is open so he can see everything easily... I can work out everything myself quite easily except the PWM as I've never done that before, though after doing 30min of research looks quite easy... the only prob is the LED's he is wanting to use to light up the cabinet could draw up to 5-6A all up, very high, 700-1500mA each... I was hoping the PWM for my dash could be very easily transferable as I'll be using in the area of 200 of my small LED's roughly 4A (20mA ea.)

#### Bear_2759

Joined May 23, 2008
120
quick question for the temp circuit, most of the examples in the datasheet indicate that the output increases by 10mA per °C. is the example temp circuit the same or is it 100mA/°C? I think I'm just reading it wrong but wanted to check... i've attached the datasheet for easy reference.

#### Attachments

• 303.7 KB Views: 10

#### SgtWookie

Joined Jul 17, 2007
22,219
Hi Bear,
It's not 10mA/°C, it's 10mV/°C. Big difference!
So, 100mV = 10°C.

Just remembered something; upper left side of page 8 on the datasheet.
Dot mode is useable if there are >=50mV per step (>=500mV from Vlow to Vhi)
Otherwise, you can use bar mode down to 20mV per step (>=200mV from Vlow to Vhi)
Dot mode will allow you a maximum resolution of 5°/step, bar mode 2°/step.

As far as the LED thing, probably the best way to do that would be to use an inductive boost driven by a timer. It's really not much harder than using typical PWM, but your wiring will be simplified.

Give me the specifications for your friend's LEDs.

Also give me the specs for the LEDs you plan on using.

Attaching the datasheets and giving me the exact part numbers would be the best way to do this.

#### Bear_2759

Joined May 23, 2008
120
ha, I should have picked up on that, I was reading mV but wrote mA...

I actually prefer bar mode to dot mode so had already made the simple mod to bar mode. good to know it actually gives me a better res if I want.

the first of my mates LED's that he will be using 3-4 of are
LXK2-PB14-N00. see first datasheet.

he will also be using quite a few "noname" LED's on a 2 seperate circuits (20 on each). a few white on one circuit and blue on another. I know it's not much help but there's no datasheet available for these. all I can tell you is they're 10mm and I'd be willing to sacrifice a few to test their limits...

the LED's I'll be using for mine are are Kingbright KPTD-3216SURC.
(datasheet 466-3970)

I think I've decided that because of the size of mine, I will end up expanding the circuits to the following.

Tacho = 50 LED's
Speedo = 50 LED's
Fuel = 30 LED's
Temp = 30 LED's
Oil = 30 LED's
Battery = 20 LED's.

all up, 210 LED's...

let me know if you need more info.

cheers.

#### Attachments

• 964.9 KB Views: 13
• 72.7 KB Views: 14

#### SgtWookie

Joined Jul 17, 2007
22,219
Tacho = 50 LED's
Speedo = 50 LED's
Fuel = 30 LED's
Temp = 30 LED's
Oil = 30 LED's
Battery = 20 LED's.
Ahhh, wait a sec - those are all LM3914-driven instruments, not just the dash lighting, correct? If so, they're going to have to be driven in parallel.

With the LM3914, there are basically two ways to control the brightness of the LEDs; one is to PWM the current path to ground from pin 7 (I suggest using an N-ch MOSFET), the other is to PWM the positive supply to the LEDs themselves (I suggest using a P-ch MOSFET).

What LEDs are you going to be using for general dash lighting?

BTW, I highly suggest diffused red LEDs. Red will have minimal impact on your night vision; that's why red is used for lighting aircraft instruments. I think I've already mentioned the use of diffused LEDs; narrow focused LEDs will be too bright and likely leave you with blind spots burned in your retina.

#### Bear_2759

Joined May 23, 2008
120
firstly, yes, they will all be 3914 driven guages, no dash lighting... I was thinking of using PWM on positive supply and having a pot on pin 7 to set brightness of individual guages so they are all the same.

I'm glad you mentioned the general dash lighting otherwise I never would have thought of it.. in my head what I would like is when the headlights are turned on, the brightness of the dash lights is cut by 1/3 or a variable ammount. so it's bright enough to see through the day, and when you turn the lights on it cuts the brightness down so it's not blinding....

While those LED's are not diffuesed themselves they will be mounted behind the panel that will have a small diffuser for each LED, probably frosted perspex or something like that... I havent really decided on the layout, having a bit of difficulty with that... looking for inspiration... it has probably crossed your mind but no normal rectangular LED's or 10 LED blocks wont do, the design will have some kind of unusal lines/shapes in the pattern of the guages to make it look a bit different while still suited to the style of the car.

I will have the need later to build a digital odometer/speedo but I want that on a seperate brightness controll circuit as I don't want it on most of the time...

#### SgtWookie

Joined Jul 17, 2007
22,219
The trouble with putting a pot on pin 7 is that it will also adjust your Rhi voltage.

It is rather confusing, but if you are using the internal voltage regulator for controlling both the LED current AND the Rhi, then the resistance values chosen will affect both the LED intensity (current) and the Rhi voltage. It is a delicate balance.

#### Bear_2759

Joined May 23, 2008
120
Sorry SgtWookie, I completely forgot that you had already replied.

in that case I think it'll have to just be the pwm on the pos supply to the LED.

#### Bear_2759

Joined May 23, 2008
120
I've been looking around at a few PWM circuits using a P-ch MOSFET, i've been trying to get my head around how to use a MOSFET as I've never thought of them for anything before...

so I would use a normal old PWM circuit using 555 timer, then use the PWM to amplify that? is that how it works?

#### Bear_2759

Joined May 23, 2008
120
ah, after much searching I found a site that has it in words that I understood...

My understanding of it now is... output from 555 PWM conected to Base of PNP MOSFET, MOSFET Collector connected to power source +. and Emitter conected to LED VCC.

am I correct in what I've said?

it all seems so simple now...

#### SgtWookie

Joined Jul 17, 2007
22,219
Hi again Bear,

Yes, that's sort of it - except standard 555 timers don't get quite up to Vcc due to the way the output stage is constructed (a Darlington voltage follower arrangement) - so it either needs a transistor driver or the use of a CMOS 555 timer.

It's really late here, and I have a full day tomorrow.
[eta]
MOSFETs have different nomenclature than a transistor, because they're different from a transistor.
Transistors allow control of the collector current by controlling the base current.
MOSFETs are basically voltage-controlled switches.
If Vgs (voltage measured between the gate and the source terminals) is 0, then the MOSFET is off.
If Vgs is 10 (or -10 for a P-channel enhanced MOSFET) then the MOSFET is ON, and the resistance between the drain and source is very low.

In a very rough analogy:
Rich (BB code):
MOSFET   Transistor
Drain  = Collector
Gate   = Base
Source = Emitter
but not really, because they are different critters.

When you're using a standard transistor, current flows through the base/emitter junction.
When you're using a MOSFET, the gate acts quite a bit like a capacitor. You charge and discharge the gate, but once the gate is charged or discharged, there is no current flow.

Last edited:

#### Bear_2759

Joined May 23, 2008
120
sorry, it's a bit late here too, somehow ended up reading about transistors thinking I was reading about MOSFETS.

ok, so i've done a bit more reading, getting my head around MOSFETs. correct me if I'm wrong, I would use a enhancement mode P-Channel MOSFET, when there is 0v on the gate, there is no conductivity between source and drain, as the gate voltage increases so does the channel conductivity until Gate = Source then there is no conductivity?

so if the gate acts like a cap then if the frequency of the 555 is high enough, with a 50% duty cycle, it will be as though there is 50% VCC on the gate?

#### SgtWookie

Joined Jul 17, 2007
22,219
sorry, it's a bit late here too, somehow ended up reading about transistors thinking I was reading about MOSFETS.
Oops! Well, that happens

ok, so i've done a bit more reading, getting my head around MOSFETs. correct me if I'm wrong, I would use a enhancement mode P-Channel MOSFET, when there is 0v on the gate, there is no conductivity between source and drain, as the gate voltage increases so does the channel conductivity until Gate = Source then there is no conductivity?
Well, you have that a bit confused.

Let's talk a little about N-ch enhanced MOSFETs first, because it's a bit less confusing, due to how they are commonly used. With an N-ch MOSFET, there is often little to no difference between the voltage of the source terminal and system ground. Since Vs = ground = 0v, the voltage on the gate is relatively easy to understand.

If Vgs = 0v (voltage between the gate and the source, with source as the reference point) then the MOSFET is turned off (not conducting). There is virtually no current flow between the source and the drain.

If Vgs = 10, then the MOSFET is turned fully ON, and it's Rds (resistance between the drain and the source terminals) is very low. Just how low it is depends upon the individual MOSFET model.

Now let's switch over to P-channel MOSFETs (pun intended.)
P-channel MOSFETs work similar to N-channel MOSFETs, except everything's backwards. Yeah, that's confusing, but let's give it a try.

With P-channel enhanced MOSFETs, the source terminal is usually connected directly to the +V supply, so our gate voltage is referenced in terms of +V (which is in this case, equal to Vs), which is counter-intuitive.

After you've been dabbling in electronics for a while, you get used to referencing everything from ground, so this goes rather against that learned behavior.

So, when Vgs of the P-channel MOSFET is zero (which means the same as V+) then the MOSFET is off (not conducting).

Here's the confusing part: when Vgs = -10v, the MOSFET is ON (Rds = minimal). Wait a minute - did he just say minus ten volts? But I'm going to be using this in a 14v auto system - where in the world do I get minus ten stinking volts from?

Hold on a second! All is not lost; it's the "reference point" thing. The -10 volts is measured using the source terminal as the reference.

Let's try to look at it relative to ground.
If your +V is 14v (relative to ground), then your Vs is also 14v.
If Vg (gate voltage) = 14v, then Vgs=0 and the MOSFET is OFF.
If Vg = 4 (or Vgs = -10) then the MOSFET is ON.
But trying to reference the gate voltage of a P-channel MOSFET to ground can get you confused and in trouble in a hurry. That's why you really want to reference the gate voltage from the source terminal.

Does this help you understand it a bit more?
so if the gate acts like a cap then if the frequency of the 555 is high enough, with a 50% duty cycle, it will be as though there is 50% VCC on the gate?
That's the rub; if Vgs was halfway between, the MOSFET would be in "linear mode", which means that it has resistance, and will dissipate power. This means heat, which you want to avoid.

The trick is to get the basic 555 frequency high enough so that you won't notice the LED's flickering, yet low enough so that you don't use a lot of current charging and discharging the gate(s) of the MOSFET(s).

Since your load will act like a resistor, the duty cycle of the PWM controller (in this case, a 555 timer) will determine what the average current through the load is.

For your purposes, a frequency of 100 or 200 Hz would be plenty fast enough.

Are you understanding all of this?

#### Bear_2759

Joined May 23, 2008
120
makes perfect sense, I think...

so with the -10v is that when it passes -10v or when it is at -10v. I understood the -10v from the reference from the word go, what I am wondering is

on a 14v+ supply

when gate = 14v then it is off
when gate = 4v then it is on
when gate = 0-4v it is??? eg 1v, 2v etc or does it need to be 4v.

so pretty much what I need to do is have the output from the 555 at 4v, 100-200hz, and play with the duty cycle to set the brightness...

so, I would try to keep the frequency as close to 100hz as posible to prevent the MOSFET from heating up too much due to charge/discarge of the gate while keeping the "flicker" of the led's at a rate that is not visible.

how much heat would the MOSFET need to handle? I'm sure a heatsink would solve any probs with heat?

#### SgtWookie

Joined Jul 17, 2007
22,219
makes perfect sense, I think...

so with the -10v is that when it passes -10v or when it is at -10v. I understood the -10v from the reference from the word go, what I am wondering is

on a 14v+ supply

when gate = 14v then it is off
when gate = 4v then it is on
when gate = 0-4v it is??? eg 1v, 2v etc or does it need to be 4v.
Let's stick with Vgs measurements so it doesn't get overly confusing.
Many standard MOSFETS have a maximum Vgs of +20v/-20v that they can withstand without damage. So, even if you pulled Vgs to -14v, it wouldn't kill the MOSFET.

so pretty much what I need to do is have the output from the 555 at 4v, 100-200hz, and play with the duty cycle to set the brightness...
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.

so, I would try to keep the frequency as close to 100hz as posible to prevent the MOSFET from heating up too much due to charge/discarge of the gate while keeping the "flicker" of the led's at a rate that is not visible.
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.

how much heat would the MOSFET need to handle? I'm sure a heatsink would solve any probs with heat?
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.