Can I use one ground as a reference for multiple inputs?

I am about to build a simple datalogger for my car, which is pre-OBD.

The aftermarket gauges I have use a resistance measurement against ground for the gauges. 10-180ohm for some, others are a different range for example.

Would I be able to use one ground as a reference, and several sensors comparing against that, or would I need separate resistance references for each?

Ground is usually the voltage level all other parts of the circuit are measured or referenced from.

That stated it is possible to have different circuit paths connected to the same GND pin. However, the maximum current for a single pin is 200 mA (or 0.2 A) and you shouldn't try routing more than 400 mA total through the ground return on most Arduino boards. Within these limits you can connect any combination of gagues and resistors to the on-board ground you want.

Of course if you wire the resistors directly to the ground of the power supply (in this case the wire that goes to the negative on your car battery) you don't have to worry about the current going through the gauge. You'd just have to use opto-isolators to get the signals from the gauges instead of connecting them directly to the Arduino.

Would I be able to use one ground as a reference, and several sensors comparing against that, or would I need separate resistance references for each?

You talk of resistance at the end so I assume you are using the pull down method of connecting a switch in the tutorial. Then the answer is you need a resistor for each input otherwise you are shorting all the inputs together.

I'm not sure if I am describing my question properly; this is my first attempt at using an arduino (and microcontrollers in general).

I'd like to tap into the existing single signal wire that goes to my gauges, and have the arduino save the values to an sd card. Later on, I'd like to move to displaying the values on an LCD and removing my analog gauges. I hope this crude picture can help. If I have multiple sources to read, and some are the same ohm range, what is a "best practice" for reading the values? Comparing each against a separate known value resistor, or all against one known value resistor?

I am mainly a welder/fabricator, so this is all pretty new to me.

Where do the other ends of the resistors go? Is it ground?

What voltage is the other end of your sensors? I assume it is 12V. If so that arrangement will fry your arduino as you can't put more than a 5V signal into it.
You have to use a resistive potential divider to stop the inputs from being driven too high.

It is a good idea to put some protection on the inputs as well, something like the circuit with the zener diode in this link.
http://www.thebox.myzen.co.uk/Tutorial/Protection.html

This is not the easiest of projects for a beginner. A car is a hostile environment when t comes to power, there are lots of sources of noise that could cause interference. Do some simple projects first and get some confidence before embarking on this.

Thanks for the input.

The sending units on the engine are shown as the boxes with the ohm readings. They are only one wire, and carry no power that I know of, the sensor grounds through the threads onto the engine block. They change resistance with temperature/pressure. This is a project I could really use, and I am hoping to give it a try. There aren't any projects I want to do that AREN'T automotive related in some way (I'm a car guy) so I guess dealing with the noisy electrical environment is something I might as well start dealing with now, haha.

This is a snapshot of the manual from Auto Meter.

OK it looks like you'll want to take the signal from between the gauge and this part called "the sender". However, as Grumpy_Mike stated, you need to make sure any input signal is going to be 5VDC or lower before it's connected to one of the Arduino's I/O pins. It will probably be 0 to 12 VDC, but if the gauge's documentation doesn't provide any information you should determine this experimentally with a multimeter (measuring the voltage between S to GND on the gauge when it displays the lower and upper limits on the gauge). The current will probably be low, but you do want to make sure will always be below 40 mA before feeding it into an Arduino (unless you use an opto-isolator like I mentioned earlier).

Once you know the voltage and current levels the gauge operates on, you can determine how best to reduce the signal's voltage down to a range suitable to feed into the Arduino. Because the signal is only going one-way, a series resistor of a specific value, TBD, with a high enough power rating should suffice. However that's not the only way to do it, just an easy but still normally effective way.

Good advice but this bit is wrong.

but you do want to make sure will always be below 40 mA before feeding it into an Arduino

That current is the current limits when the arduino pins are outputs.

They are only one wire, and carry no power that I know of,

Yes they do, one end is connected to 12V, the other end of your resistor must be connected to ground.
Split the resistor in two, have one going from ground to the arduino input, the other going from the arduino input to the sensor. Make sure thar you do not exceed 5V at the arduino by choosing the resistor values correctly.

Grumpy_Mike:
Good advice but this bit is wrong.

but you do want to make sure will always be below 40 mA before feeding it into an Arduino

That current is the current limits when the arduino pins are outputs.

They are only one wire, and carry no power that I know of,

Yes they do, one end is connected to 12V, the other end of your resistor must be connected to ground.
Split the resistor in two, have one going from ground to the arduino input, the other going from the arduino input to the sensor. Make sure thar you do not exceed 5V at the arduino by choosing the resistor values correctly.

Mike,

From my experience (see: Race cars), The gauges are simply voltage dividers. IE the fuel sender an be some wonky value like 180 to 110 ohms, with, say, a 110 in the gauge itself. It just performs math on how many volts are being divided where.

That said, I don't know if there is a safe way to tap the sender wires without upsetting the voltage divider and it's programming inside the gauge.

Instead of tapping into my existing wires, should I just cut them, run one side to input, and then output the value to the gauge? Again, for now I just want to datalog, but eventually I'll get rid of my gauges and switch to an LCD display.

crashbumper:
Instead of tapping into my existing wires, should I just cut them, run one side to input, and then output the value to the gauge? Again, for now I just want to datalog, but eventually I'll get rid of my gauges and switch to an LCD display.

There's been several discussions on the forums on that manner, going to a strictly digital display. I say grab some big LCD's from sparkfun, and go to town! Bonus points if somebody figures out HUD on an arduino.

I thought for a minute, you could play multimeter and use a high impedance to drive the arduino, so that the gauges kind-of [but not really] ignore it's presence. It would take some experimenting, but using your 0-90 water temp as a potential example,

Stock:

Sender @ 0 ohms

Sender @ 45 ohms

Sender @ 90 ohms

A bias resistor has to be used to keep the 0 ohm reading from be a dead short. For 12V operation, a 240 ohm resistor is a half-amp when shorted. Thus,

Sender Link @ 240 ohms

Sender Link @ 285 ohms

Sender Link @ 330 ohms

Now assume the gauge's side of the divider is a 150 ohm:

Vout = (240 / (240 + 150)) * 12 = 7.38 volts

Vout = (285 / 285 + 150)) * 12 = 7.86 volts

Vout = (330 / 330 + 150)) * 12 = 8.25 volts

And so on down the line.

Now for the arduino, you have 2 challenges: Keep the voltage under 5 volts, and not affect the gauges.

To keep the volts down (use 2.56 internal reference), say we use a 10k/50k voltage divider:

Vout = (10 / (50 + 10)) * 12 = 2 volts max

But now that voltage divider is sub-dividing the gauge's divider.

Vout = 240 / (240 + ||150 , 60K||) * 12 = 240 / (240 + 149.62) * 12 = (240 / 389.625) * 12 = 7.39 volts (+0.01 volt change)

Vout = 285 / (285 + ||150, 60K||) * 12 = 285 / (285 + 149.62) * 12 = (285 / 434.62) * 12 = 7.87 volts (+0.01 volt change)

Vout = 330 / (330 + ||150, 60K||) * 12 = 330 / (330 + 149.62) * 12 = (330 / 479.62) * 12 = 8.25 volts (no change)

Again, demonstration only. No idea what the values are in the gauges.

Grumpy_Mike:
Good advice but this bit is wrong.

but you do want to make sure will always be below 40 mA before feeding it into an Arduino

That current is the current limits when the arduino pins are outputs.

That's not true according to the ATmega datasheet, in section 28 under Electrical Characteristics the absolute maximum rating for "DC Current per I/O Pin" is 40 mA. There is no distinction made for whether the I/O pin is being used for input or output. If the I/O pins were capabable of withstand appreciably higher input current than output current, that would be listed because this is a potentially useful difference. Also if the limit was only for output current, than the situation illustrated here would most likely ruin only one pin, and not both when shorted together. This is because the output pin would fail before the input pin.

So you should always limit the current to 40 mA to the I/O pins regardless of how they are being used.

That's not true according to the ATmega datasheet, in section 28 under Electrical Characteristics .....

No you are totally misunderstanding that section of the data sheet.
When a pin is used as an input it has a very high impedance. You can connect it directly to the 5V supply and you will get a negligible current into the pin. The only way you could approach 40mA into the pin is to take the voltage up to several hundred volts by which time you will have over voltaged the pin.

The 40mA applies ONLY to when the pin is an output. The reason the data sheet doesn't specifically say it only applies to the pin as an output is because it is designed for engineers who know there is no way to exceed 40mA when the pin is an input.

than the situation illustrated here

That is when the two pins are both outputs. If one pin was an input that would not damage the arduino.
Ask RuggedCircuits if you don't believe me.

That's not true according to the ATmega datasheet, in section 28 under Electrical Characteristics the absolute maximum rating for "DC Current per I/O Pin" is 40 mA. There is no distinction made for whether the I/O pin is being used for input or output. If the I/O pins were capabable of withstand appreciably higher input current than output current, that would be listed because this is a potentially useful difference.

You are failing to understand a basic tenent of Ohm's law. Only the load resistance determines the amount of current flow if assuming a fixed voltage (5vdc in this case). As an input pin has many meg ohms of input resistance (look up the value in the datasheet), how is it possible for any significant current to flow into or out of a input pin? It can't. Only if the external applied voltage exceeds +5.5vdc or under -.5vdc, where the input pin clamping protection diodes start to conduct, can any significant current flow.

Lefty

I understand Ohm's law quite well thank you.

I also understand that the multi-million ohm resistance is only for pins explictly configured as inputs in code (not an innate protection), headers for pins are clustered together so shorts between nearby can happen under the right (or really wrong), and that depending on the application pins can be defined in an Arduino sketch from INPUT to OUTPUT at any arbitrary point of time. With those three things in mind, in environment where there's vibrations and possible wire abbrasion I like to make sure when possible the signals both comming into and going out of an ATMega are all below 40 mA well before they get to the Arduino board. That way even if an input signal does somehow short to an output pin it doesn't do permanent damage.

However after reviewing my post, I will agree that I was being rather absolutest while making my case and not technically accurate. And since I also failed to mention any of the above mentioned paragraph my initial response also unfairly portrayed Grumpy_Mike as wrong when for defined inputs he was actually correct. The truth is there is no need to make sure an input is under 40 mA, even though I think it can avoid problems, especially within a car. I'll also admit that the for this application it's most likely that the sensors will need to use the analog inputs, and it's rare to use the any pins on port capable of analog input as outputs unless the others are unavailable.

I try to make helpful contributions, but in this case it appears that my reply wasn't helpful. I am sorry I went off half-cocked. :blush:

The truth is there is no need to make sure an input is under 40 mA, even though I think it can avoid problems,

Yes that is right, there is a trend for putting series resistors in line with input pins in case of accidental setting to an output and then exceeding the input current of the output.
Personally I don't do that and have never had anything go wrong yet and I have been doing this a far few years.
Thanks for clearing this up. :slight_smile:

I also understand that the multi-million ohm resistance is only for pins explictly configured as inputs in code (not an innate protection),

Also not exactly correct. The AVR chip using it's built in design, forces all I/O input pins to input mode upon a reset or power up action. So pins default as input pins and that is not dependent on a users code to set them as such. Only by user programming commands will an I/O pin be switched to output mode. So if you want to wire a series 200 ohm resistor to all I/O pins to protect from possible user software errors or external wiring errors or external hardware component failures, then you are free to do so, but it's not a requirement from the chip's point of view.

Lefty

retrolefty:
Also not exactly correct. The AVR chip using it's built in design, forces all I/O input pins to input mode upon a reset or power up action. So pins default as input pins and that is not dependent on a users code to set them as such. Only by user programming commands will an I/O pin be switched to output mode. So if you want to wire a series 200 ohm resistor to all I/O pins to protect from possible user software errors or external wiring errors or external hardware component failures, then you are free to do so, but it's not a requirement from the chip's point of view.

OK, I wasn't aware that the I/O pins defaulting to input was physically built-in to the IC, instead I thought the pins were initially defined as inputs automatically as part of the firmware download. Thank you for the information.

In any case, I was refering to accidental shorting between the input signal from the gauge and one of the output wires this type of project will require. Which is possible in the cramped, vibrating, and sometimes thermally extreme environment that exisits behind a car's dashboard. I just didn't do as good of a job explaining it as I should have in my initial reply.