Arduino for modifying resistance values

Hello everyone!
My intentions are to use arduino as an element between sensor and sensor gauges for input and output resistance. The problem is that aftermarket fuel gauge and coolant temp. gauge should be wired to original fuel and collant temp sensors (sensor and gauge resistance ranges are not equal).
Both fuel level and temp. sensors are simple rhesistors (one pin to ground, one pin to gauge) with resistance ranges as seen in the picture below (also there you can see my wiring plan):

Electronics is not my profession, therefore the first question should be about how to wire sensor rheostats to Arduino for measuring real life measurements (ohms)?

I started coding with this simple code example of Analog potentiometer input and output to serial monitor:

void setup() {
Serial.begin(9600);
}

void loop() {
int sensorValue = analogRead(A0); //this will translate input resistance to values with a range of 0-1023:
Serial.println(sensorValue);
}

Step 2: Translate range of 0-1023 to let's say 50 to 500.
Step 3: Make this modified range values linear and dependant to received resistance measurements from analog in
Step 4: Translate range 50-500 to real resistance values and output them to assigned analog output.

Will be glad for a helpful hand from users on coding steps 2 to 4.
Thanks in advance!
Krists

#2 and 3 are easy using the map() function:

e.g. map(analogRead(A0), 0, 1023, 50, 500);

The only way I know to do #4 is with a digital potentiometer:

but I'm sure others on the forum will have better ideas.

Good luck!

Got the wrong aftermarket gauges? Best answer is replace the sensors with ones that match the new gauges, there is less to go wrong in some expensive ways that way. Just so you later on don't say no one told you so.

You're not reading ohms through analog in and you're not outputting ohms through analog out. You can read volts if you wire the circuit up right and you can output pulsed power.

Have you look at the analogRead() example to see how it's wired? Sensor to analog pin through resistor, yes, same sensor to ground through a much bigger resistor (10x or more) is what I see works.

Step 4. I have a value from analogRead(), I've scaled it and now I need a value to feed analogWrite()... what should I do? BTW, analogWrite() uses 0-255.

Start out with simple things like hey, read the sensor and see if the data meets your expectations. Check every step before you try to put them together and expect every step to take 3x or more time than you thought it would. If you do enough simple things then you will learn some electronics along the way but be sure to do extra reading and start off with Ohm's Law.

Are these gauges ammeters (milliammeters)?
Do you know their full scale rating (F.S. = ___ )?
Given some analogRead on a pin you could effect an analogWrite on another, which could control a MOSFET, which would control a gauge.
Reading 50-110? / 35-210? may require additional circuitry.

I pulled out a milliammeter, it's 1mA full scale.
With a 5k? resistor in series, I hit it with some PWM...
http://s270.photobucket.com/albums/jj118/new_clear_days/circuits/?action=view&current=feedthemeter.mp4

Arduino output is 5V, 5V/5k? = 1mA
If I had to run it from 12V (via a transistor), same thing: 12V/1mA = 12k?

You can see that I don't quite make it to "10" with 255. That's because my calculations, lazily, didn't figure in the meter's own resistance. fullscale = V / (Rmeter + R) Use a pot and tweak it just right!

feed_the_meter.pde (1.81 KB)

Thanks for sharing ideas and giving suggestions!

This is embarrassing. Almost two programmable ECU's soldered and wired by myself with 2 engines running and I feel myself lost in basic physics. The problem is that cars are just a passion, I am legal consultant by profession.

I found a simple oil pressure gauge that will be used for bench testing purposes. It's designed for 0-10BAR oil pressure readings (0 bar - 3ohms, 10bar - 160ohms).
Thanks for making me open school books on the subject of ohms law, now I am starting to remember something :slight_smile:

As I understand - voltage readings (5V through resistor/rheostat connected to analog input) in it's first place is what should make Arduino to read sender values (analog read). Then these values will mapped to digital values.
After that, analog write as PWM should let me control gauge readings (digital signal will be modified to virtual analog modifying rheostat I can say so).

The thing I don't understad is how these PWM voltage fluctuations can manipulate gauge readings if there is 12V+ wired to the gauge from the other side all ready? Does it mean that PWM output of arduino should be connected to MOSFET that will continuously switch gauge sender input wire to ground?

As I understand - voltage readings (5V through resistor/rheostat connected to analog input) in it's first place is what should make Arduino to read sender values (analog read). Then these values will mapped to digital values.
After that, analog write as PWM should let me control gauge readings (digital signal will be modified to virtual analog modifying rheostat I can say so).

Yes!

Does it mean that PWM output of arduino should be connected to MOSFET that will continuously switch gauge sender input wire to ground?

If the gauge has two wires, then I think so: with an appropriate resistor between the gauge/meter and the transistor -- assuming that they are ammeters.
A voltmeter is an ammeter with a resistor in series.
I'm not clear if the gauge requires/indicates a varying voltage or a varying current.

I have included (see attachment to this post) a drawing of the meter circuit used in the demo (meterpwm.jpg).
For 12V, use the transistor ckt (meterckt.jpg example). It shows what I would have done using 12V and the same 1mA fullscale meter movement.

meterpwm.JPG

meterckt.JPG

OK, this is for the output stage, but for the input stage, this diagram as found with google:

will not work in my situation as rheostat found in fuel tank sender is grounded in the tank and there is no way to put 5V+ on that side or wire fixed resistor and ground it after that. The same applies to coolant temp.sender where physical dimensions doesn't allow to do such modifications:

Is it possible to swap 5V and ground signals? I mean - does it affect voltage readings if current flows in different direction? Like this:

What about mod like this? :

I'm new to the Arduino but do some electronics background. The fuel level sending unit is a variable resistor that regulates voltage; only way i see around that is a pulse width modulator that is varying duty cycle at full voltage at set frequency.

The water temp sensor is similar.

I would also recomend getting original parts for simplicity; however if you want to use a microcontroller.
I would put a resistor in series with the sensors and hook that to 5 volts as the sensors are grounded.
and use the voltages across the fixed resistances to obtain your reference signals.

kristsm,
The second circuit you presented is fine.
You have posted that these sensors/senders effect pretty low resistances.
I don't know how much current you can stuff down those guys.

The last circuit is showing a constant current source. So, the voltage across the sender/sensor will vary with its resistance. It can do as much as 10mA, and V = 10mA * (35 to 210?) = 0.35 to 2.1V and with 5mA (so as not to push the envelope) the range would be 0.18 to 1V. Is that range enough? 5V__*__ / 1024 = 4mV 5mV per count, so your analogReads would be, approx, 87-525 36 - 200 or so.

( * Another, external, reference can be used; it's more to do.)

Here is a current source (sink?), circuit attached.
It uses a bugbear: a PNP transistor.
So long as the 5V is regulated the current will keep.
If you need values for 12V, let me know.