Hey everyone. So, I've read a few posts on here (and other places around the Internet) from people who are essentially trying to do the same thing. But, I have extremely little understanding of building circuits like this, so in each one of those posts there has been some piece I don't understand.
Basically, I am trying to build a gauge using an Arduino (really I'm not set on using an Arduino, but rather whatever is going to be easiest that I will be able to plug ~15 sensors into ultimately, very long term goal haha). The first one I'll try and get working is this EGT (exhaust gas temperature) sensor.
What would the very minimal circuit for this look like? Ideally I'd like it to be as generic as possible (or to work with the most sensors possible, I guess) and be heavier on the software side than the hardware side (if that is possible, again I know almost nothing about this).
Also, I am a little bit unclear about the digital vs analog pins for this. I am pretty sure the analog pins would be what I want to use for all this, but don't know for 100%.
Now to show that I have put some thought into this and not just "asking the Internet to do my homework for me" lol. First I would wire up the arduino to the cars 12v & ground. Then for the sensor in question, 1 wire would go to ground (presumably it could go to chassis and not have to go to the arduino) and then the other wire would go one of the analog pins on arduino. Now everyone seems to add a resistor (or two) and a capacitor to the circuit, but A) I don't understand why, and B) how would you make that generic-ish so that you could plug any similar sensor into it and be able to compensate programmatically?
I hope this question makes sense, and I appreciate you taking the time to read it! Thanks!
Hi,
It depends on how accurately you want to measure the temperature...
Since the temperature range is so high and the sensor changes from 200ohm to 850ohm from 0 to 1000C, you could simply use the arduino ADC with internal reference to read the sensor in a simple resistor divider (sensor to ground, 3k3 pullup resistor).
That should be enough resolution for that sort of sensor. (approx 1.3degC per ADC step)
If you really wanted higher resolution you would need something like this: Adafruit PT100 RTD Temperature Sensor Amplifier - MAX31865
Not exactly that (because that's a PT100 amp, designed for a 100ohm sensor, the link you gave says the EGT sensor is platinum 200ohm), but you could copy the cct or even mod the board.
I am not sure what ADC means? I Googled it and got a gambit of results back so I'm not 100% sure what it is. But a resolution of +- 5C isn't really going to make that big of a difference in terms of practicality, since I'm dealing mostly in ranges of like 1000C is real hot, 850C is warm haha, but more accurate is always better
As for the pullup resistor, how did you calculate that value?
Oh, also, "read the sensor in a simple resistor divider" the resistor divider part is done via hardware (the 3k3 resistor bit) and then you would use like analogRead() to figure out the value?
ADC = Analog to Digital Converter, it's what is used when you do an analogRead() on an input pin.
Normally the reference for the ADC is the power supply rail (+5v) but you can select an internal analogReference() which is:
INTERNAL: an built-in reference, equal to 1.1 volts on the ATmega168 or ATmega328P and 2.56 volts on the ATmega8
The pullup resistor:
Diagram:
With 3k3 pullup and the sensor at 200 ohm, we get (5v / (3300+200)) * 200 = 0.28v
and, when hot, we get (5v / (3300 + 850) ) * 850 = 1.02v
When we have set the analog reference to 1.1v, then we read the voltages using analogRead() as:
the ones that output a voltage.
An example is an LM35/TMP36.
The produce a certain output voltage depending on what they sense, but not depending on their supply.
the ones that (also) output a ratio of their supply voltage.
An example is a voltage divider (thermistor/resistor), or a load cell.
A/D results depends on two things. Input voltage and reference voltage.
If input voltage goes up, A/D value goes up, and if Aref goes up, A/D value goes down.
It is obvious that you want a stable/fixed Aref for constant voltage sensors, so only sensor output voltage will change the A/D result.
1.1volt Aref or 2.56volt Aref or even the 3.3volt supply as Aref is great for those sensors.
For ratiometric sensors, you want their supply linked to Aref.
So the output of the sensor stays a ratio of the A/D.
A 10k:10k divider connected to 5volt, outputs 2.5volt, but read with an A/D with a reference of 5volt will read 512
A 10k:10k divider connected to 4volt, outputs 2volt, but read with an A/D with a reference of 4volt wil also read 512.
TonyWilks, thanks, I really appreciate it. That helped me understand a lot better. I want to use an Arduino Due for this project, and from what I understand from reading the analogReference() docs is that my only option is 3.3v. So in your example, the only thing that would change is:
But that seems like the resolution would go down a lot that way? I did the math with different resistor values, but it didn't seem quite right. I am still not exactly sure how you initially came up with the 3k3 resistor value, though.
Wawa:
There are two types of sensors.
the ones that output a voltage.
An example is an LM35/TMP36.
The produce a certain output voltage depending on what they sense, but not depending on their supply.
the ones that (also) output a ratio of their supply voltage.
An example is a voltage divider (thermistor/resistor), or a load cell.
A/D results depends on two things. Input voltage and reference voltage.
If input voltage goes up, A/D value goes up, and if Aref goes up, A/D value goes down.
It is obvious that you want a stable/fixed Aref for constant voltage sensors, so only sensor output voltage will change the A/D result.
1.1volt Aref or 2.56volt Aref or even the 3.3volt supply as Aref is great for those sensors.
For ratiometric sensors, you want their supply linked to Aref.
So the output of the sensor stays a ratio of the A/D.
A 10k:10k divider connected to 5volt, outputs 2.5volt, but read with an A/D with a reference of 5volt will read 512
A 10k:10k divider connected to 4volt, outputs 2volt, but read with an A/D with a reference of 4volt wil also read 512.
Hope you understand my weird explanation.
Leo.
So Leo, which one would be best for my use-case? I thought I understood, but then while writing my reply & trying to explain it back to confirm I understood, I realized I was still a little confused.
Again I really appreciate you both helping me out with this.
Ryuske:
I want to use an Arduino Due for this project, and from what I understand from reading the analogReference() docs is that my only option is 3.3v
Ah, ok.
(The previous calc. to get 3k3 was based on the sensor's resistance at 1000C being 850ohms and 3k3 is a reasonable value to get 1v across 850ohms)
Now you have 3v3 ref. for the ADC and for the resistor divider (which will keep Leo happy), we just have to decide on a value which gives us a reasonable range of voltages for our A to D without taking too much current.
e.g. using 470ohm for the top resistor will give you an ADC range of roughly 300 to 650 or 2.5decC per step.
It seems that the sensor is a PT200 (platinum RTD).
You should use a special amplifier+A/D breakout board for this sensor.
I only know of PT100 and PT1000 boards (Adafruit), but I think the only difference is a reference resistor.
Might have to change that to 860ohm for a PT200.
Leo..
Sorry, I just saw you already sugested that in post#1.
I hope you can find a good formula to calculate that crooked PT200 derived ratio into a reasonably accurate temp.
Most Arduino thermistor formulas are for NTCs, not PTCs (like the PT200).
Leo..
So, I think I understand this pretty well now. I really appreciate you taking the time to explain everything in a super simple way that actually made sense.
I just have two more questions (I feel bad for asking so many!). The first one, where did the 1024 come from in the 0.28/1.1 * 1024 equations?
Last question! It's about the pull up resistor part. It made perfect sense to me that you choose a resistor value to get reasonably close to the Vref at max resistance. I was Googling pull up resistors (what they're for, calculating it, etc) earlier tonight, and basically what I understood was that you should choose a resistor that will get you in the range of: Vref < V > 1/2 Vref and that would get you reasonably close. Is that the general way to look at it?
Also, I got bored and decided to graph all this out because I was getting kind of confused about the whole ADC step thing, and I also wanted to see how different resistance values would affect the ADC value (or, a guesstimate at least).
Ryuske:
where did the 1024 come from in the 0.28/1.1 * 1024 equations?
It's the total number of steps in the Arduino's ADC, it reads 0 to 1023
so on a 3.3v Due the ADC would give values of:
Voltage ADC value
0v 0
3.3v 1023
1.65v 511
2v 620 (that's 2 / 3.3 * 1024 )
about the pull up resistor part
Yes, we've looked at two cases...
the input voltage is higher than Vref (originally 5v and 1.1v) where you want a potential divider to make best use of the ADC range so, as you say "you choose a resistor value to get reasonably close to the Vref at max resistance".
the input voltage is the same as Vref (now we have 3.3v)
Now we have to use some 'pullup' resistor to supply our sensor resistor so we can't use the full 3.3v range
If the pullup is very large (e.g. 10,000ohm) to our 200 - 800ohm sensor, then the voltage will be low with a low range. (0.06 to 0.24v)
If the pullup is really low (e.g. 10ohm) then we may draw too much current and the voltage will be high with a low range (3.14 to 3.26v)
Somewhere in the middle we get a reasonable balance, having the pullup be equal to the sensor resistance at 1/2 it's range is a good bet.
So... 470ohm pullup gives us 0.98v to 2.07v
Not sure if it's an issue for these sensors, but the low total resistance gives a relative high current in the sensor: over 7 mA (470+200 Ohm / 5V = 7.4 mA). That's producing some 11 mW of heat by itself, and with the sensor being small, this may be enough to heat up the sensor a bit and throw off your measurement.
The solution to this: use a much higher pull-up resistor value and an amplifier circuit (using an OpAmp) to bring the read voltage back up.
Again I don't know whether this is actually an issue in this application but considering the currents you have you should at least make sure it's not.
wvmarle:
Not sure if it's an issue for these sensors, but the low total resistance gives a relative high current in the sensor: over 7 mA (470+200 Ohm / 5V = 7.4 mA). That's producing some 11 mW of heat by itself, and with the sensor being small, this may be enough to heat up the sensor a bit and throw off your measurement.
Yeh, that is a consideration.
We're on 3.3v so it's a bit less (4.8mW) and it's an Exhaust Gas Sensor so I'd expect self-heating to be a minor concern.
However, it would be interesting to see if any effect is measurable on the bench,
Depends on how accurate you want to be as well.
Going to be tricky to measure on the bench as the effect changes with temperature (low temperature = high resistance = low current).