Pages: [1] 2   Go Down
Author Topic: 12 volt input?  (Read 2358 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 1
Posts: 42
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi all, this more than likely been asked before but I have not been able to find anything in the history, so excuse me if it’s a repeat.

I am using an Arduino Uno to make a low tech data acc for a race car, the customer has a GOPRO camera that looks out the front of the car and I can mount the Ardino on the dash.
The cars TPS is a 5 volt reference to the stock ECU, found a sketch on Fritzing for that light array.
Now I need to tap into the stop lamp switch and here is my question…
Can the Uno handle a 12 volt input and what pin do I use.
Thanks All in advance

 8)Linc
Logged

Scotland
Offline Offline
Edison Member
*
Karma: 26
Posts: 1353
Have you had your Arduino fix today?
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

None of the pins are 12v tolerant, Use a resister divider or transistor to convert 12V to 5V.
Logged

Drew.
http://www.uk-pcb.co.uk - My UK Based PCB Fab & Assembly Company
Design work undertaken
SMD & Thru-Hole assembly

Offline Offline
Newbie
*
Karma: 1
Posts: 42
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thats what i thought smiley-mad

You would not know off hand what resistor would bring the voltage down to 5v?
And then would it go into an anolog input pin?

 8)Linc
Logged

Scotland
Offline Offline
Edison Member
*
Karma: 26
Posts: 1353
Have you had your Arduino fix today?
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Connect input like this :         12v -WW-o-WW- GND
                                                          |
                                                        PIN

Where PIN is DIGITAL in OR ANALOG in (Digital is better)
1st -WW- is a 5K Resistor, and second is 7K (so 12 - o is 5V and o - Ground is 7V)
If you need a betted diagram, ask and I'll post one.
Logged

Drew.
http://www.uk-pcb.co.uk - My UK Based PCB Fab & Assembly Company
Design work undertaken
SMD & Thru-Hole assembly

Scotland
Offline Offline
Edison Member
*
Karma: 26
Posts: 1353
Have you had your Arduino fix today?
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Here's the diagram :


* VoltDev.jpg (26.92 KB, 961x680 - viewed 206 times.)
Logged

Drew.
http://www.uk-pcb.co.uk - My UK Based PCB Fab & Assembly Company
Design work undertaken
SMD & Thru-Hole assembly

Offline Offline
Newbie
*
Karma: 1
Posts: 42
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks Drew!
And thanks even more for the diagram, was not sure what you were talking about but I can follow wires.
Not going to be able to use a digital input I have them all tie up for the led outputs.
I see where you can change the analog input to a digital in, I'll have to do some reading on how this is accomplished and try to write in the sketch.

 8)Linc
Logged

Scotland
Offline Offline
Edison Member
*
Karma: 26
Posts: 1353
Have you had your Arduino fix today?
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi - If you lookup voltage dividers on the web, there are loads of examples. but its easy in this case - total resistance across 12v to gnd is 12K - splitting it with 7K/5K splits the voltage across the resistors 7v/5v.

Digital input is just an on/off reading, rather than analog (0-1024)
Logged

Drew.
http://www.uk-pcb.co.uk - My UK Based PCB Fab & Assembly Company
Design work undertaken
SMD & Thru-Hole assembly

Monterrey, N.L. México
Offline Offline
Full Member
***
Karma: 1
Posts: 154
Model Railroading & Arduino are Fun
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I see where you can change the analog input to a digital in, I'll have to do some reading on how this is accomplished and try to write in the sketch.

Linc,

I use my analog inputs as digital inputs, it is valid. Try the following:
Code:
pinMode(A0,INPUT);
digitalRead(A0);

BTW: Analog pins A0-A5 on the UNO can also be referred as pins 14-19. Specially useful if you set or read or write the pins using a program loop. ie: for i=1,... and the same works with the MEGA2570's A0-A15 which also are 54-69.

Quote
- splitting it with 7K/5K splits the voltage across the resistors 7v/5v.

spycatcher2k,
Thanks for the easy explanation on voltage dividers and the 'wise' values chosen for the resistors since it is very easy to see how it works. But why did you use those specific values and not 3.5K and 2.5K? Is it also because of the current draw?

Thank you!
Logged

Billy     http://www.z-world.com/operations/gbremer/

When you've eliminated the impossible,
whatever remains, however improbable, must be

Scotland
Offline Offline
Edison Member
*
Karma: 26
Posts: 1353
Have you had your Arduino fix today?
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

@bibre - You got it, the higher the resistance the lower the current load, but 3.5K and 2.5K would work fine.
Logged

Drew.
http://www.uk-pcb.co.uk - My UK Based PCB Fab & Assembly Company
Design work undertaken
SMD & Thru-Hole assembly

0
Offline Offline
Shannon Member
****
Karma: 223
Posts: 12745
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

12V in a car is actually about 13.8V if the engine is running, since the battery is being charged.  Use a 10k and 5k6 divider perhaps?
Logged

[ I won't respond to messages, use the forum please ]

Offline Offline
Newbie
*
Karma: 1
Posts: 42
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This all makes sense to me, thanks all for making it easy for me to understand!
I can tell you how to fix a car and why but when it comes to this type of manufacturing things, I have learned long time ago...ASK SOMEONE who knows what he is doing! smiley

So for the divider 10K to 5K6 resistor.

Program analog pin A1 as
 pinMode(A1,INPUT);
digitalRead(A1);

So I now have A0 set for the cars TPS that runs a 5 volt reference to the ECU and running a 10 led array
Brake input through the resistor divider
Then the clutch pedal input with a simple momentary closed switch.
Just now have to wait for the box, circuit board and other pieces to put it all together …
What do you guys think, an accelerometer to show fore and aft G’S and lateral, or am I getting into to deep? LOL


Linc
Logged

Monterrey, N.L. México
Offline Offline
Full Member
***
Karma: 1
Posts: 154
Model Railroading & Arduino are Fun
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

spycatcher2k,

Thank you. I had an idea of how a voltage divider worked and I knew the equations. I also knew that in the particular case when R1=R2, you get half the input voltage. Ok, but should R1=R2 equal 1k or 10k or 100k??? That, I didn't know. It seems to me that the right choices are in the range of 5k to 10k in order to keep a modest current flowing. Besides I guess that you also chose 7k and 5k because, for example, 500 and 700 ohm resistors are not standard values, maybe 470 and 7??. Thanks again, Drew! smiley

Linc,

Quote
This all makes sense to me, thanks all for making it easy for me to understand!
I can tell you how to fix a car and why but when it comes to this type of manufacturing things, I have learned long time ago...ASK SOMEONE who knows what he is doing!

Wise decision. I'm very glad we learned something new to keep us going, and now that we've "ASKED", from now on, others will soon ask us for the same things and how we developed our projects. That's why I like this Forum.  smiley-cool

Quote
What do you guys think, an accelerometer to show fore and aft G’S and lateral, or am I getting into to deep?

Whaaaat???  smiley-eek
Yes, YOU ARE, at least for me!!! I do know how to drive my car, but that's enough for me, and I don't really like it. ROFLOL  smiley-lol
Logged

Billy     http://www.z-world.com/operations/gbremer/

When you've eliminated the impossible,
whatever remains, however improbable, must be

Offline Offline
Newbie
*
Karma: 1
Posts: 42
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


Whaaaat???  smiley-eek
Yes, YOU ARE, at least for me!!! I do know how to drive my car, but that's enough for me, and I don't really like it. ROFLOL  smiley-lol
[/quote]
Billy,
Come on you never had the thought of going full throttle through a turn or just put your foot to the floor to see how fast your car can go. LOL
I can understand, my wife road with me in one autocross and that was enough for her, but when we go to work the races...she loves it.

But as far as the acclorometer? A second board 19 led's and the acclorometer its self. But what would be the programming/sketch?
« Last Edit: March 04, 2012, 11:34:46 am by Linc » Logged

Monterrey, N.L. México
Offline Offline
Full Member
***
Karma: 1
Posts: 154
Model Railroading & Arduino are Fun
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey Linc!

Quote
Come on you never had the thought of going full throttle through a turn or just put your foot to the floor to see how fast your car can go. LOL

Touché !!!   smiley-lol

Not only had the thought, ... I did it many times, he, he!   smiley-twist
Logged

Billy     http://www.z-world.com/operations/gbremer/

When you've eliminated the impossible,
whatever remains, however improbable, must be

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 549
Posts: 27434
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Many cars have nasty voltage spikes & stuff. I would put a transzorb across that pin as well.
You can expect 14.5V when the battery is charging.
Vout = Vin R2/(R1+R2)
You know you want Vout <=5V,  Vin up to  14.5V, pick an R2 of say 6.8K and Solve for R1
Vout(R1 + R2) = Vin R2
VoutR1 + Vout R2 = VinR2
VoutR1 = (VinR2 - VoutR2) or (Vin-Vout)*R2
R1 = (Vin - Vout)*R2/Vout
so (14.5 - 5)*6800/5 = 12920
using a standard 15K:
14.5*6800/(6800+15000) = 4.55V
and if Vin was lower
12*6800/(6800+15000) = 3.74V  so you get a good high over the expected Vin range.

Current draw, V=IR, so V/R = I
14.5/(6800+15000) = 0.66mA
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Pages: [1] 2   Go Up
Jump to: