Hi. I'm going to use my Arduino to read two sensors on a marine dieselengine.
The sensors is grounded(negative voltage) via the block. So when it is full preassure, it is almost no resistance trough the sensor. When it is no oil pressure it is max resistance.
So how do i connect and programmin everything? I can imagine to connect analogIn to read directly from the sensors?
So when it is full preassure, it is almost no resistance trough the sensor. When it is no oil pressure it is max resistance.
The Arduino can not read resistance. It can read voltage. The sensor gets an input voltage somewhere. The varying resistance results, in concert with a voltage divider, in a varying voltage output.
You'll need to either determine where the voltage comes from, and where the other resistor in the voltage divider is, or remove that voltage input, provide 5V from the Arduino to a resistor to the sensor, and tap the resistor/sensor junction, feeding that to an analog pin. Reading that analog pin will result in varying values as the oil pressure goes up and down.
Paul, I had some of the same ideas but since the engine is connected a 12 volts battery, it might kill the Arduino? Will a resistor between analogin and the battery work? Then the ground on the sensor is connected directly to the sensor?
KapteinFredrik:
The sensors is grounded(negative voltage) via the block. So when it is full preassure, it is almost no resistance trough the sensor. When it is no oil pressure it is max resistance.
So how do i connect and programmin everything? I can imagine to connect analogIn to read directly from the sensors?
I assume the Arduino will be the only thing connected to those sensors. (This is quite an important assumption; if you're sharing the sensor with something else you have a very different problem.)
Connect your sensor to 12V via a series resister so you have battery -> resister -> sensor -> ground. This arrangement is called a voltage divider. As the resistance of the sensor varies the voltage at the connection between the sensor and the resister will also change, so by reading this you can calculate the sensor resistance and hence the value being sensed.
Since the Arduino won't handle more than 5V, you need to choose your resister so that the voltage at this junction never exceeds 5V. Make sure you get this right or you risk blowing up your Arduino - if you aren't sure, get help.
The path through resistor 2 to the Arduino has current starting at the battery, going through the resistor and arriving at the Arduino. All that that resistor is doing is defining how much current arrives at the Arduino, at 12 V. You most definitely do NOT want to use that resistor.
The path to the Arduino through the other resistor has the current starting at the battery, going to the instrument, through the resistor, to the Arduino. Again, all that that resistor is doing is defining how much current arrives at the Arduino, at 12 V. You most definitely do NOT want to use that resistor.
The instrument may have a resistor in it, too. Between that resistor and the sensor, forming a voltage divider, the voltage on the wire between the instrument and the sensor may actually be changing, as the resistance of the sensor changes.
You need to confirm, using a multimeter, that this is actually the case. If it is, then, you can use two resistor between the wire between the instrument and sensor and ground, as a voltage divider, to drop the 0 to 12V voltage in the wire to 0 to 5V at the resistor junction. From that junction, you can run a wire to the Arduino, to an analog pin, so you can measure the voltage.
If the voltage in the wire between the instrument and the sensor does not vary as the pressure changes, then the instrument in measuring current, and you will need a current sensor to measure that current, too.
I hooked up my voltmeter to the temparaturesensor onboard, and started up. I used the temp sensor, because the oilpressure is 4 bar constant when the engine is running.
For the oil pressure sensor, not enough details were given. Does the oil pressure sensor in the vehicle show a constant pressure? A constant pressure from cold start to operating temperature would be very unusual.
For the oil pressure sensor, not enough details were given. Does the oil pressure sensor in the vehicle show a constant pressure? A constant pressure from cold start to operating temperature would be very unusual.
The principles are just the same for both of the sensors. The only thing is that the engine's oil pressure are mostly constant between 3 and 5 bars. So for my experiment, I need a sensors that senses something slow and varying. When he engine starts, it takes under one second for the pressure to become 5 bars. The temp uses 10 minutes to rise to normal operation temp.
I am going to try this out later on, after work today.
When he engine starts, it takes under one second for the pressure to become 5 bars.
That's a good thing.
The temp uses 10 minutes to rise to normal operation temp.
That, too, sounds about right.
The only thing is that the engine's oil pressure are mostly constant between 3 and 5 bars. So for my experiment, I need a sensors that senses something slow and varying.
I'm not sure what you mean by this. Please elaborate.
The only thing is that the engine's oil pressure are mostly constant between 3 and 5 bars. So for my experiment, I need a sensors that senses something slow and varying.
I'm not sure what you mean by this. Please elaborate.
[/quote]
The oil pressure will pop up to full in a matter of seconds, the sensor will give full effect immediately. I will then not be able to measure anything between 0-4 bar, since the pressure is consistently above 4 bar, unless something happens to the motor.
The oil pressure will pop up to full in a matter of seconds, the sensor will give full effect immediately. I will then not be able to measure anything between 0-4 bar, since the pressure is consistently above 4 bar, unless something happens to the motor.
I'm at a loss to understand what you think there will be to measure between 0 and 4 bar, when the pressure is already above 4 bar.
With regard to the oil pressure sensor, which is acting as a variable resistance between 10 and 184 ohms:
As PaulS says, you need a varying voltage, not a varying resistance as an input to an Arduino. The voltage input to the Arduino can be anything from 0V to 5V.
The engine's battery is 12V. As already mentioned, a voltage divider will work to give you this. The nearest handy resistor size is a 270 ohm. In this configuration, it'll give just under 5 volts.
To connect it up, take a +12 volt battery connection. Connect one side of the 270 ohm resistor to it, connect it's other side to the pressure sensor's terminal. The body of the sensor is already earthed, so it'll make a circuit. At most, 44mA will flow. The resistor will need to dissipate just over 1/2 watt, so pick any 1 or 2 watt resistor.
Take a wire from the connection between the 270 ohm resistor and the sensor as your signal input to the Arduino.
At 10 ohms / 0 bar, it'll give 0.42 volts
At 184 ohms / 5 bar, it'll give 4.86 volts
Search the Arduino website to find how to convert this signal into a readout - maybe on an LCD shield?
I tested it all today. I used a voltage divider between the sensor and arduino, and everything worked perfekt. I made a simple divider similar to this one Voltage Divider project – SwanRobotics
I discovered one certain problem, the values are not linear.
Actually I got to thinking about the non linearity and I remembered that those sensors are tailored for a "Hot Wire Ammeter"... Sort of like a bi-metallic strip moving a pointer across a meter Face. The "meter isn't very linear and the pot's value is "spread" to "un-spread" the meter, it has a sort of logarithmic behavior as I remember. It's basically the way gasoline is measured with a float/pot combination. It is also 5% of the price of a D'Arsonval movement and about 10 times more durable so for economic as well as reliability reasons the pot's are non linear.
At first sight it looks like an 1/x relation.
y = a / (x-x0) + y0
From 3 points you can get values for parameters x0 y0 a
A rough estimate is here:
Sure with more points you might consider other approximations with more coefficients, but as an arduino is not good at maths, a table lookup and linear interpolation might be easier ...
The table in your reply #2 about pressure does not look too bad ( about 34 Ohms per bar all over the range )
If that's non-linear too, you best show your voltage divider schematic.
Here is the table for the tempsensor. It is very similar to the pressure sensor.
I plotted in data from the table in GeoGebra and got this formula: 0x? + 0x? - 0x? + 0.00003x? - 0.00309x? + 0.16529x³ - 4.86834x² + 51.07725x + 630
That formula/polynomial was a bit overkill for this project I think?