Pages: [1]   Go Down
Author Topic: Arduino for modifying resistance values  (Read 1669 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Southern California
Offline Offline
God Member
*****
Karma: 5
Posts: 539
I like blinky lights
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

http://arduino.cc/en/Reference/map

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

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

http://arduino.cc/en/Tutorial/SPIDigitalPot

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

Good luck!


Logged

http://en.wiktionary.org/wiki/magagna <-- My last name.  Pretty apt.

Pittsburgh, PA, USA
Offline Offline
Faraday Member
**
Karma: 99
Posts: 4836
I learn a bit every time I visit the forum.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.


Logged

I find it harder to express logic in English than in Code.
Sometimes an example says more than many times as many words.

Offline Offline
Faraday Member
**
Karma: 66
Posts: 2588
Now, More Than Ever
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

"Hello, I must be going..."
"You gotta fight -- for your right -- to party!"
Don't react - Read.
"Who is like unto the beast? who is able to make war with him?"

Offline Offline
Faraday Member
**
Karma: 66
Posts: 2588
Now, More Than Ever
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 - downloaded 11 times.)
Logged

"Hello, I must be going..."
"You gotta fight -- for your right -- to party!"
Don't react - Read.
"Who is like unto the beast? who is able to make war with him?"

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley

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?
 

Logged

Offline Offline
Faraday Member
**
Karma: 66
Posts: 2588
Now, More Than Ever
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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!

Quote
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 (4.91 KB, 204x214 - viewed 14 times.)

* meterckt.JPG (7.74 KB, 326x274 - viewed 15 times.)
« Last Edit: February 20, 2012, 04:58:48 pm by runaway_pancake » Logged

"Hello, I must be going..."
"You gotta fight -- for your right -- to party!"
Don't react - Read.
"Who is like unto the beast? who is able to make war with him?"

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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? :
« Last Edit: February 21, 2012, 02:42:29 am by kristsm » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Faraday Member
**
Karma: 66
Posts: 2588
Now, More Than Ever
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.)

« Last Edit: February 21, 2012, 05:55:35 pm by runaway_pancake » Logged

"Hello, I must be going..."
"You gotta fight -- for your right -- to party!"
Don't react - Read.
"Who is like unto the beast? who is able to make war with him?"

Offline Offline
Faraday Member
**
Karma: 66
Posts: 2588
Now, More Than Ever
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.


* current PNP.jpg (104.67 KB, 480x640 - viewed 24 times.)
Logged

"Hello, I must be going..."
"You gotta fight -- for your right -- to party!"
Don't react - Read.
"Who is like unto the beast? who is able to make war with him?"

Pages: [1]   Go Up
Jump to: