# reducing voltage to useable level,

Hello I am building a set of gauge mounted indicator lights for my friend's motorcycle. I need to know how to convert the signal which comes from the bike's harness 10~12v to a usable 5.5 v that the Arduino can accept as an input. would I use a resistor or a small voltage regulator?
here are the inputs that I am trying to convert;
Turn signal which was measured as an intermittent 10.25v
High beam which when on was measured as a constant 11.45v
Neutral indicator which when on was measured as a constant 11.45v
Oil pressure light which when on was measured as a constant 11.45v

Use resistor voltage dividers on each Arduino I/P

voltage >>>> 18K >>>>> Arduino I/P and 10K >>>>> ground

You might want some protection diodes to save your inputs from spikes.

See here for ideas:

http://ruggedcircuits.com/html/ruggeduino.html#ProtectionDetails

I may be confused, but those voltages sound a bit low. for a 12 volt battery, the alternator would normally put out 13.5 - 14.8 volts.

If you are powering the arduino with 5 volts, you want the input voltage to be less than 5 volts. But basically, yes to a voltage divider that will take 14 volts down to about 3 volts would be good, and as Nick says, some protection diodes.

Another way might be to use an opamp or a voltage comparitor, what you're measuring is the voltage drop when a decent load takes place...

Optocouplers are good for this sort of thing ("signal transmission between systems of different potentials").
They're not just for "isolation" (that's optional.)

Definitely go with opto-couplers. There's too much "dirt" floating around on vehicle circuits and optos give you clean safe isolated inputs to your micro.

jackwp:
I may be confused, but those voltages sound a bit low. for a 12 volt battery, the alternator would normally put out 13.5 - 14.8 volts.

If you are powering the arduino with 5 volts, you want the input voltage to be less than 5 volts. But basically, yes to a voltage divider that will take 14 volts down to about 3 volts would be good, and as Nick says, some protection diodes.

I believe you are correct, those voltage levels were taken with the engine off. running I suspect the voltage would be 13.5-14.8 as you said.

jackrae:
Definitely go with opto-couplers. There's too much "dirt" floating around on vehicle circuits and optos give you clean safe isolated inputs to your micro.

how dose the optocoupler influence the voltage? given a continuous 14v will it generate excess heat and require a heat sink? are these soldered directly to my prototype shield? What is a recommended place to buy these, and what specifications do I look for when ordering?

On the 12V side, it is exactly like using an LED. Pick an appropriate resistor for the optocoupler's input side. So it should not get hot, as we're talking 10 or 20mA.

Then the output side is only connected to the Arduino's Vcc, and so the Arduino never sees more than it's own Vcc supply.

Using the normal calculations for a LED (for the optocoupler input), if you have (say) 15V from the battery, and the LED forward voltage is 1.2V (I'm looking at the spec for a 4N25), and it takes 10 mA to turn on, then you need to drop 13.8V at 10 mA, so you put:

``````(15 - 1.2) / 0.010 = 1380
``````

So perhaps a 1.2K or 1.5K resistor in series with the optocoupler input.

given a continuous 14v will it generate excess heat and require a heat sink?

No, the 10 mA calculated above will not generate excess heat.

See card 1 of Arduino Basic Connections for an example circuit:

http://www.pighixxx.com/abc-arduino-basic-connections/

My intention is not to split hairs, but I doubt that 10mA would be necessary.
Likely no more than half that, probably much less 1-2mA

Ashdricky:
are these soldered directly to my prototype shield?

Yes.

Ashdricky:
What is a recommended place to buy these, and what specifications do I look for when ordering?

Jameco.com , Digikey.com, the rest of the "usuals."
4N25
http://www.jameco.com/webapp/wcs/stores/servlet/Product_10001_10001_40985_-1

Your application is basic, this isn't a major design effort where you have to sweat a lot of details - just get the wires right.
You'll save yourself a lot of trouble getting it worked out on the bench before connecting it to the motorcycle.

You could be right, but you want the LED to turn on, right? Or the voltage on the Arduino input pin might not be enough to be HIGH.

You could be right, but you want the LED to turn on, right? [/quote]

Sure, which it would either way.
It’s OK to have more than is needed; no harm, no foul.
Certainly, 10mA is no big deal and definitely will get the point across.

I would configure the opto output common-emitter (emitter to Gnd, collector pulled up).
So, its output would be High till the optoInput turns on and takes it Low (the optoTransistor conducts).
The crux of the matter is CTR - the “brightness” of the optoLED “shining” on the optoTransistor with sufficient irradiance to allow (switch) a required current.

Test Results
I used a 4N28, pretty much the same (4N25), it’s from the same “family”, less-than-heavenly CTR.
These aren’t photoDarlingtons, they’re single transistor outputs (but the VCE is lower.)
With a 20K pull-up to 5V, I needed 2mA through the input.
With a 10K pull-up to 5V, I needed 4mA through the input.

Test sketch:

``````void setup()
{
Serial.begin(9600);
pinMode(2,INPUT);
}

void loop()
{
if (val == HIGH)
{
Serial.println("opto HI!");
delay(250);
}
else
{
Serial.println("opto LO!");
delay(250);
}
}
``````

So you calculate 10mA when the voltage is at the highest, and normally it runs lower than that. Don’t forget to take that into account.

polymorph:
On the 12V side, it is exactly like using an LED. Pick an appropriate resistor for the optocoupler's input side. So it should not get hot, as we're talking 10 or 20mA.

Then the output side is only connected to the Arduino's Vcc, and so the Arduino never sees more than it's own Vcc supply.

So my very crude understanding of how an optocoupler functions is that when the LED inside illuminates it triggers the optical resistor, which then allows current to flow through the 5v circuit which gets power from the arduino board itself.

And as Nick said I will use a 1.4k ohm resistor as I would with any Led?

Thanks again to everyone for your help.

You could be right, but you want the LED to turn on, right? [/quote]

Sure, which it would either way.
It’s OK to have more than is needed; no harm, no foul.
Certainly, 10mA is no big deal and definitely will get the point across.

I would configure the opto output common-emitter (emitter to Gnd, collector pulled up).
So, its output would be High till the optoInput turns on and takes it Low (the optoTransistor conducts).
The crux of the matter is CTR - the “brightness” of the optoLED “shining” on the optoTransistor with sufficient irradiance to allow (switch) a required current.

Test Results
I used a 4N28, pretty much the same (4N25), it’s from the same “family”, less-than-heavenly CTR.
These aren’t photoDarlingtons, they’re single transistor outputs (but the VCE is lower.)
With a 20K pull-up to 5V, I needed 2mA through the input.
With a 10K pull-up to 5V, I needed 4mA through the input.

Pancake when you refer to a 20k “pull-up to 5v” what dose this mean? I’m obviously very green in this field.

It is a phototransistor in that optocoupler, not a photocell (light dependent resistor), but otherwise, yes.

Ashdriky, your last response appears to have been typed within the "quote" tags. It makes it difficult to tell what you said.

Ashdricky:
Pancake when you refer to a 20k "pull-up to 5v" what dose this mean? I'm obviously very green in this field.

Take a look at Fig. 1 in this link --

It shows the output configured as I advocate. They have the collector (output) pulled-up with a "75?" resistor to Vcc. That's their "test circuit".
You will want to use a 10K resistor (to +5V instead of "Vcc"). You could do away with those pull-ups entirely by using the Arduino "weak internal pullup"
[refer "Pins Configured as INPUT_PULLUP" at constants - Arduino Reference ].
If that's too much to integrate at this time, just use the resistors.

Also, a 2.2K resistor on the input, with your 12V situation, should be good. (A 1K is plenty OK, too; gotta love that 10mA.)

When the LED is on, the transistor will be on; when the transistor is on, its output is taken to Gnd (Low).
Doing a digitalRead on that, the results will be:

• HIGH when the transistor is off
• LOW when the transistor is on

Got all that?