I want to lie to cars.
September 2, 2010 7:01 PM   Subscribe

I need a little advice on an electronics project that I'm working on.

It's really simple. I just want to make a basic device that takes the 12v DC from a car battery, reduce it to 5v and be able to adjust the voltage between 0 and 5v. My goal is to make a cheap tool that allows me to fake sensor inputs for automotive diagnostics. I'm thinking that I can do this with one variable resistor or potentiometer, but I need an electronics hobbyist to tell me exactly what I need. Thanks!
posted by Jon-o to Travel & Transportation (16 answers total) 1 user marked this as a favorite
 
You'll need to know what amperage range you're looking for on the 5v line.
posted by muddgirl at 7:19 PM on September 2, 2010


You are correct that you can do this just with a resistor or potentiometer. It's called a voltage divider.

However, before you break out the soldering iron and start melting lead, you should decide if that's really the best way to go about things. Voltage dividers are pretty wasteful; a lot of current ends up going through the shunt resistor (Z2 in the Wiki diagram). Also your current source needs to be much greater than your current drawn at the output. Really, they are bad choices unless you need a very small reference voltage at minimal current.

I would suggest that you look into DC-DC converters. They are not very expensive anymore, and there are even adjustable ones. If that unit meets your needs, you might not even need to build anything.
posted by Kadin2048 at 7:31 PM on September 2, 2010 [1 favorite]


Best answer: It is in theory possible to do this with a pot (look up the voltage divider - the wiper is the middle terminal of the divider) but in reality there are reasons why you might not want to do that. The main reason is that the source impedance of a voltage divider is relatively large which means if it's loaded at all the voltage will sag. Loading is not an issue if it's always connected to something with a high input impedance like a DMM or the ADC pin of an ECU, but you can't guarantee that everything you might ever want to connect it to has an input impedance of several megaohms. To reduce this problem means lowering the source impedance of the divider, which means using smaller R values, which means you waste more current flowing through it (and generate more heat) and requires larger wattage resistors.

I would advise that you instead use a voltage regulator like the LM317. You can still have a pot that lets you adjust voltage, but the regulator uses feedback to make sure that the output voltage is extremely stable no matter the loading -- in essence this means almost zero source impedance.
posted by Rhomboid at 7:41 PM on September 2, 2010 [1 favorite]


This should work: connect the anode (no stripe) terminal of a 5.6V 400mW Zener diode to ground. Connect a 1k 0.5W resistor from the cathode (stripe) terminal of the Zener diode to +12V. Connect the outer terminals of a 1k linear taper potentiometer across the Zener. Connect the collector terminal of a BD139 transistor to +12V, and the base terminal to the wiper terminal of the potentiometer. You now have a crude but effective (i.e. automotive-grade) variable linear voltage regulator, good for about 1.5 amps output if you bolt the transistor to a decent lump of metal (be aware that if you do this without using an insulating pad between the transistor and the heatsink, the heatsink will be at +12V).

The output voltage appears between the emitter terminal of the transistor and ground. You might want to put a 3 amp fuse between the transistor's collector terminal and +12V, depending whether or not you can get fuses cheaper than BD139 transistors.
posted by flabdablet at 7:44 PM on September 2, 2010 [1 favorite]


Seconding Rhomboid's suggestion of using an adjustable three-terminal regulator like the LM317. It won't let you go all the way down to 0 volts, though. Another possibility is some sort of voltage-follower to buffer the output of your pot (a.k.a. adjustable voltage divider) — a sturdy opamp or something maybe.

To extend on what muddgirl said, what you need to know in order to build this is:
  • How much current does it need to be able to supply?
  • How close to 0v does it need to be able to go?
  • What source impedance does it need to present: in other words, how "stiff" does the output voltage need to be when the thing it's connected to draws more or less current?
  • Does it need to be able to handle short-circuits to ground, +12, etc., without damage? If it's just going into a typical high-impedance ADC input, the answers will be (almost none, 0v, really doesn't matter, probably a good idea) and a potentiometer followed by a resistor (for short-circuit protection) will do the job. Otherwise you'll want some silicon in there somewhere but you'll need more details before you know what.

posted by hattifattener at 7:50 PM on September 2, 2010 [1 favorite]


(or, yeah, you could use an emitter-follower as a buffer like flabdablet says)
posted by hattifattener at 7:52 PM on September 2, 2010


The transistor-based regulator design I just gave you will let you set the output voltage anywhere between 0V and 5V. There will be a small dead zone at the lower end of the potentiometer's range, anywhere inside of which the output voltage will be 0V.
posted by flabdablet at 7:53 PM on September 2, 2010


Oh, and I neglected to mention the problem with voltage regulators is that they tend to have a minimum output voltage -- 1.2V in the case of the LM317. To regulate below that you want a LDO (low drop-out) regulator. You can get down to around 0.25V dropout or so without too much hassle. If you need less than that you may have to go with the pot idea, or else a much more sophisticated circuit.
posted by Rhomboid at 7:55 PM on September 2, 2010


The output of my circuit is safe to short to +12V, but if you short it to ground you will let all the magic smoke out of the BD139.
posted by flabdablet at 7:58 PM on September 2, 2010


I think if a simple pot won't do the trick then flabdablet's circuit is the next reasonable step up in complexity. Since you have so much headroom you can probably protect against shorts to ground by putting a resistor in between the transistor's collector and +12v— this will limit the amount of current the thing is willing to supply.
posted by hattifattener at 8:17 PM on September 2, 2010


Uh, voltage regulators are usually at least as wasteful as a voltage divider, and those things get really hot, especially at 12V. The way to go is a DC-DC converter.
posted by wayland at 8:45 PM on September 2, 2010


A voltage divider is not what you want. If all you need to produce are signals (nothing that needs much power), you could just use a very simple op-amp circuit. Or flabdablet's thing. Or a voltage regulator. A DC-DC converter is overkill unless you need to output a significant amount of power.
posted by Xezlec at 9:29 PM on September 2, 2010


flabdablet: The output of my circuit is safe to short to +12V, but if you short it to ground you will let all the magic smoke out of the BD139.

Whereas if you put a diode backwards across an LM317, it's safe to short the output to both Vin & ground (maybe not at the same time ;-)

wayland: Uh, voltage regulators are usually at least as wasteful as a voltage divider, and those things get really hot, especially at 12V. The way to go is a DC-DC converter.

a) expensive (>5x the cost of an LM317 + bits), and b) in the interests of accuracy it's actually a function of current drawn and voltage drop across the device, as follows…
Watts(regulator, as heat) = I(source) * (V(source) - Vout))
But since the OP wants to fake 0v-5v sensor data it's likely that current drawn will be low anyway, so heat's unlikely to be a great problem. LM317's are internally self-temperature-regulating; stick a little heatsink on it if you're worried ;-)

Now, the low-voltage end probably doesn't matter (IIRC, vehicle 0-5v sensors are mostly actually 1.2-5v or 2.5-5v), but if it does you can use an LT3080 which goes down to 0v.

So…
  1. A voltage divider isn't really the go, as you need to be aware of both source and load impedances to design one decently,
  2. a DC-DC converter is overkill and adjustable ones are expensive (relatively),
  3. an LM317 wired as per the datasheet (with the reverse diode!) is better and simpler than a straight transistor shunt regulator, and
  4. you probably don't, but if you really need to go down to 0v an LT3080 or similar will do the trick.

posted by Pinback at 2:21 AM on September 3, 2010


Hattifattener's advice about putting a resistor between the BD139 collector and +12V is a good idea. The best resistor for the job is probably an ordinary automotive light bulb: a 10 watt bulb will limit maximum output current to a little under an amp, which should be plenty for sensors and keep the transistor quite comfortable as long as it's got a decent heatsink.
posted by flabdablet at 8:21 AM on September 3, 2010


Response by poster: I made a quick check today, and it looks like the operating amperage is about 1 amp, if that helps.
posted by Jon-o at 10:50 AM on September 3, 2010


Response by poster: So, today I went to the Shack and bought an LM317, a PCB, the capacitors, potentiometer, and some hook up wires and did one of the ugliest solder jobs I've ever perpetrated. It's all wired up, with the addition of a 2A fuse to prevent the accidental melting of important computer circuits. I've got a couple gator clips to hook up to the car's positive battery terminal and the chassis, and two more gator clips to hook up to the positive and ground sides my self-powered test light.
Unfortunately, I left my DVOM at work, so I can't really test this until Tuesday.

Thanks again everyone!
posted by Jon-o at 12:42 PM on September 5, 2010


« Older Big Product, Big Decision   |   Quitting a toxic work environment Newer »
This thread is closed to new comments.