Help needed for interfacing a car with Arduino

Anyone that has tried to interface his car with Arduino? I know there are some, but cannot find their posts.

First of all, my program was supposed to work well (at least that was what I thought) at the desk, but when entering real car sensor signals, nothing seems to work.

I think it is corrupt somehow, because variables change their value all the time, even if I don´t input signals.

First, I want to test the program itself, to start with a strong basis.

Then, I will work with one sensor at a time, one by one.

Someone can give a hand with this?

Thank you in advance.

OldBeaver
:-?

Without some more information about the project, I can only offer generic advice.

There are several things you must keep in mind when interfacing with vehicular equipment...


That 12 volt power supply, IS NOT 12 VOLTS. In a healthy car, the voltage can range from 9 to 15 volts, and if there is a problem with battery, alternator, or voltage regulator you can just toss out any random number between 0 and 50. Protect your Arduino!

That 12 volt power supply IS NOISY! And that noise is all over the spectrum. You must filter the signals well.


The standard sensors are ratiometric... their output is a percentage of power supply voltage. You can't count on, for example, 8 volts out of the oil pressure sensor equalling 40 psi all the time.

And, since they are ratiometric, you can't connect them directly to your 5 or 3 volts Arduino. You need to scale the signal down.


The environmental conditions are terrible. Temperatures from way below freezing, to nearly boiling, are very common occurances. Humidity from bone dry to dripping wet. And vibration. Did I mention vibration? Vehicles move. Seal, secure, and ventilate!


To scale and filter, use a voltage divider along with a capacitor to ground.

For a 5 volt Arduino, a 240 ohm resistor in series with a 120 ohm resistor is a good choice, in most cases. This will scale a 15 volt signal down to 5 volts. Use the the best precision resistors, with the lowest temperature coefficient, that you can buy, beg, borrow or steal.

Include a capacitor in parallel with that 120 ohm resistor. The value depends on how often you must sample the signal, but as a point of reference start with .1 uF capacitors.

Dear Mike,

Thank you much for your response. In fact I had already realize that voltage is not 12 volts. In fact, in my car battery is 13.8 v and 12.9 when I run the engine.

The voltage divider: yes, I have to study that way to down voltage to a max of 5 volts.

Noise: well, I haven´t think of that, but as soon as I read your mail I phoned a friend who will purchase those for me in the big city, along with resistances.

Vibration: ok, that is a point too. I have to secure the contacts.

Temperature: to be taken in consideration too. Ventilate. ok.

Signals are ratiometric. Well, I am confirming this at least in tank level signal, throttle position sensor. But I am not sure in speed signal and in rpm signal.

In the programming I am having two courious results:

a) rpm is giving me numbers even when I am not entering any signal yet. And this is in my desk, not in the car. Tank level is behaving similarly.

c) Some values are supposed to be real numbers, with one decimal place. However, they are shown always as 4.0 , 5.0, 6.0, which is not normal.

Unfortunately I don´t know the wire language, just adapt routines I find in the net, or use some that good fellows like you give to me.

I made a new test of the program, and got this outcomes: If I assign tests values to rpm or throttle position, I get the assigned values.
So, it is not a printing problem on the lcd, but an input problem maybe.

I will continue testing until my resistances and condensers arrive.

Thank you much.

OldBeaver

Again, without more details about your sensors, I can only give generic pointers.

Speed and RPM will be in the form of a pulse train. But the amplitude of the pulses will be near 12 volts, so you will still need to limit these signals to 5 volts, even though you are only interested in the frequency and not the amplitude.
Damage to your Arduino could result if you do not do this.


If you have a sensor giving 'spurious' values (without any actual input), it is most often caused by leaving an input 'floating'.

A high impedance input (such as the Arduinos) can, and will, respond to stray signals, such as the AC power field and radio frequencies... or even the capacitance of your hand.

It is general practice to connect the input to ground through a rather high value resistor... much higher than the output impedance of the sensor, but well below the impedance of the input. This will help prevent these 'spurious' readings.

For example, suppose that your fuel level sensor is connected to the Arduino analog 0.
A typical fuel level sensor has an output impedance of much less than 500 ohms.
While the input impedance of the Ardunio analog input is specified to be around 100 million ohms.
So you might connect a resistor, from analog 0 of your Arduino to ground, of 68000 ohms resistance.
Then, in the case no sensor is present, this will ensure that the analog input is 'pulled down' to 0 volts, yet will not contribute any detectable error when the sensor is actually connected.

If you are 'bench testing', use a potentiometer, of the same impedance as your sensor, to simulate the 'real world' signal. In the case of the fuel level sensor, a 500 ohm or even 1000 ohm pot would probably work OK.


In the case where 'real' values are shown as whole numbers, this usually happens when an integer variable is used, where a float value should be used instead.


One more bit of friendly advice.

In your original post you stated that you wanted to test the program itself first, and then work with the sensors.

Might I suggest that you try it the other way around?

Write test programs for your sensors, one at a time until you are certain of your understanding of the sensor and code.

After you have confidence in the individual items, then integrate them into a whole program.

In this way you make your problem space smaller. 'Divide and Conquer!'.

Dear Mike,

Ok, thank you for the advice. In fact I was thinking just that: to test each sensor with a dedicated small program until I can manage its signal.

One thing I already did was to measure the voltages of the signals of four sensors (rpm, throttle position, fuel tank level and speed) and as you pointed, they are all ratios of the 12V of the battery.

As speed is a pulse as well as rpm, I need to write a small program that can handle these kind of signals.

Besides, I tried to wire a voltage divider in the car, to power all the sensors with 5V. This didn´t work until it got dark and I paused that work. The voltage fell to 0.5 volts (too much resistance). I am thinking about trying with a pot, adjust the voltage to 5V and measure the resistance.

However, I was wanting to ask you about the voltage divider:

Should I make one voltage divider for the sensor´s signals or for the power vltage of the sensors themselves?

Of course the best way to know is testing. I don´t know if all the sensors will work with 5V.

Ok to the treatment of spurious values, tks.

What I am missing is some source of pulsing signal to work at the desk with it, before connecting to the car.

There should be some circuits of this kind out there. Maybe a simple oscilator will make it...

In the previous email you talked about filtering noise from the car with a condenser. Didn´t you? What I missed was where to place the condenser: in parallel with the R1 or R2 resistor of the voltage divider?

When I make further progress, I will attach some picture of my work.

Thank you much for your valuable help.

Old Beaver

i DID make a car sensor sheild, but its not for sale cuz i dont have enough money to make more + im 11 >_>

can i see a picture kevin, I wish to build one for myself

to power all the sensors with 5V

You can't do that the sensors will not work. Don't use a pot that will not work also, it will not provide enough current for the sensors. If you feed 12V signals into the Arduino you will damage it, maybe this has happened already.

For removing noise from a system you need decoupling, please read:-
http://www.thebox.myzen.co.uk/Tutorial/De-coupling.html

To protect your inputs you need:-
http://www.thebox.myzen.co.uk/Tutorial/Protection.html

Note that this protection is for when you are not expecting 5V to be exceeded, if you know you exceed 5V then make the series resistor bigger about 470R.

I'm also creating an in-car-Arduino, but I am very much wondering whether the Arduino power regulator (when powered via ext) can cope with the irregular +12V power supply from the car battery.

Will it result in a stable enough +5V or do I need to supply my own / better voltage regulator?

Ok, Mike to the good advice.

However, I am now worried about the possible damage to my Arduino.
It drives the LCD Ok, it computes based on analog inputs ok, but it do not process digital inputs.

For having a secure digital input, I am constructing a pulse generator with a 555 microchip. Then I will be able to test things properly.

QuickSander is worried about the voltage regulator build-in Arduino.
It is a valid concern. I would say that car voltage is rather stable and easy to regulate. Am I wrong?

I am faced with the exact same problem on my current arduino project.
Making a simple shiftlight doohickey for a friend and I need to sort something out to power my duemilanova properly.

I got some cheap 5v USB chargers from DealExtreme that will support 1A of output current, but now I'm not sure how to link the 2 together.

There is no place where I can input 5V without it passing the regulator first, which is offcourse not a good idea. I also dont feel like cannibalising USB B type cables to make some sort of short link between the two types of supply's, and ideally I would like the USB plug to protrude from it's future enclosure so the guy can program his setpoints easily.

Any good ideas? Apologies for the hijack, but the subject seemed to match close enough.

Ivan141,

I decided to use a voltage divider.

Some signals are coming and some are not.

At this moment, I am working on other things nothing to do with Arduino. I will remain so for a while.

When I come back, I will post my results. Sorry for that.

OldBeaver