Welcome! Log In Create A New Profile

Advanced

Teacup Firmware: Thermistor not reading? Maybe pin definition? <solved>

Posted by jgilmore 
Teacup Firmware: Thermistor not reading? Maybe pin definition? <solved>
February 10, 2011 05:15PM
I'm having problems reading my thermistor.
I've defined 2 thermistors, and they both always report a temperature of zero. Well, after I updated the thermistor table. Before that they where always reporting 3C.

I modifed temp.c to use 14.2 fixed point in the temp table (because it obviously needed to be done) and to report the ADC readings every time it reads the thermistors. The ADC reading for one is zero, for the other 1023, so obviously there's a problem somewhere.

But the real problem is that I can't get those values to change! Even when I put a jumper between them, the ADC readings remain the same.

So I'm thinking that maybe I'm not reading the pins I think I am? Or maybe analog pins 0 and 1 are both blown in different ways? What does '0' mean in this context anyway?

I'm using an arduino deicimilla. Analog pins 0 and 1 are my thermistors.

The correct voltage (4.99V) is getting out to the thermistor, and a voltage is getting back (4.68V). 4.68V != 5V, I'd think the ADC should report 4.68*1024/5=958 ≈ 34C? That nut must be sitting in the sun, I know the room is colder than that!

So I'm thinking that I've got a wiring or pin definition problem somewhere, but I've traced it as far as I can think how to. Help?

Edit: Corrected ANALOG_MASK (#define ANALOG_MASK 3) and now both ADC readings are 1023. I took the second one and connected it to GND and +5V, no difference?

[Edit: Changed name to "Teacup Firmware" for the purposes of not confusing folk, after irc discussion. --Sebastien]

Edited 3 time(s). Last edit at 02/22/2011 02:12AM by SebastienBailard.


--
I'm building it with Baling Wire
Re: 5DoA: Thermistor not reading? Maybe pin definition?
February 10, 2011 08:04PM
not sure if this helps but I switch the REFERENCE to this in the config when I was working through my temp reading on the Analog pins

#define REFERENCE REFERENCE_AVCC
Re: 5DoA: Thermistor not reading? Maybe pin definition?
February 10, 2011 08:10PM
One way to test whether this is firmware or hardware is to grab a simple analog test app from arduino.cc and see if it gives the same behaviour, or write a simple test app yourself.

Another possibility is to see if it works with older firmware versions, and if so do a git bisect to find where the problem was introduced.

My electronics are all packed away, and others have reported thermistors working with recent versions so I'd like to isolate the fault to firmware (or not!) before diving smiling smiley


-----------------------------------------------
Wooden Mendel
Teacup Firmware
Re: 5DoA: Thermistor not reading? Maybe pin definition?
February 10, 2011 08:44PM
Worth a try.

That changed something. Now I'm reading 998 (13.15C, sun went down) on 0, and 1022/1023 on 1. Let me go mess with that.

Well, looks like that pin is fried. It reads 998 always regardless. If I hook the wire from analog pin 1 into analog pin 0, thus connecting it to the thermistor's output, then I get correct (and changing with temperature) readings on pin 1. But pin 0 stays the same.

So, a combination of incorrectly set REFERANCE, and a dead pin. Thank you.

Edit: Recent version of config.h.dist have the default REFERANCE set to VCC, so others should not encounter this problem.

Edited 1 time(s). Last edit at 02/10/2011 08:45PM by jgilmore.


--
I'm building it with Baling Wire
Re: 5DoA: Thermistor not reading? Maybe pin definition? <solved>
February 10, 2011 09:51PM
I've seen lots of posts about dead analog pins from inadvertent shorts between thermistor and heater wires- be careful! smiling smiley


-----------------------------------------------
Wooden Mendel
Teacup Firmware
Re: 5DoA: Thermistor not reading? Maybe pin definition? <solved>
February 10, 2011 11:25PM
I've done a lot with this chip. It's the only one I've gotten to work at all. If I get one more dead pin, I'll have to spend some time getting a bootloader on one of the other chips I have. Actually, IIRC I had no problem getting the bootloader burned, but getting the fuses set correctly so it would actually run proved to be beyond me. I know what they should be set at, but nothing I tried actually set the fuse bits.

Fortunately, that's a problem for another day. Right now my problem is now that I have the ADC readings coming in right, the temp isn't getting calculated correctly. Check out this response:
pin:2 Raw ADC:994 table entry: 19 temp:526.25 Sensor:0
pin:1 Raw ADC:995 table entry: 19 temp:523.0 Sensor:1

The two pins are wired together for now, so they're both connected to the same thermistor.

And here's the end of the thermistor table:
   {881, 221}, // 55.490742511 C
   {981, 96}, // 24.0432854283 C
   {1010, 3} // 0.975765549111 C
};

So I figure it should be giving a value between 3 and 96, but it's not. So I replaced it with a formula I found on wikipedia (it'll overflow 65535 at ADC <31, but whatever) and that didn't work either.

Tried the same calculation in python, came out perfect. Tried the sub-expressions, and no overflow problems or negative numbers.

// Linear interpolating temperature value
// y =  ((x - x₀)y₁ + (x₁-x)y₀ ) / (x₁ - x₀)
// y = temp
// x = ADC reading      =995
// x₀= temptable[j-1][0]=981
// x₁= temptable[j][0]    =1010
// y₀= temptable[j-1][1]=96
// y₁= temptable[j][1]   =3
In python, that yeilds 51, but when the firmware does it, it comes up with 554.25 (2217) No idea why. And ((x - x₀)y₁ + (x₁-x)y₀ ) = 1482, no sub-expression is negative. That should all fit in a 16-bit unsigned number, right? But something is off somewhere.

Figure it out tomorrow, I guess. G'night.


--
I'm building it with Baling Wire
Re: 5DoA: Thermistor not reading? Maybe pin definition? <solved>
February 11, 2011 11:13PM
jgilmore Wrote:
-------------------------------------------------------


> Right now my problem is now that I have the ADC
> readings coming in right, the temp isn't getting
> calculated correctly. Check out this response:
>
> pin:2 Raw ADC:994 table entry: 19 temp:526.25
> Sensor:0
> pin:1 Raw ADC:995 table entry: 19 temp:523.0
> Sensor:1
>

I am having the same issue. An ADC value of 982 is interpreted as 297. I asked about it on the main thread here and here. Unfortunately I don't have a solution for you, if you find one please post it in the main thread.
Re: 5DoA: Thermistor not reading? Maybe pin definition? <solved>
February 12, 2011 12:13AM
Solved. See pull request on github here

Long story short, I have no idea what was wrong. I pulled out the previous linear interpolation code and replaced it with something that works for 14.2 fixed point. And it still fits on my atmega168.


--
I'm building it with Baling Wire
Re: 5DoA: Thermistor not reading? Maybe pin definition? <solved>
February 13, 2011 03:12PM
Thanks, that worked.
Re: 5DoA: Thermistor not reading? Maybe pin definition? <solved>
February 14, 2011 07:47PM
How are your sensors wired? mine are 0V -> 4.7k resistor ->sig->100k thermistor->5V this causes the resistance to increase as it gets hotter, not decrease as it seems the case in the temp look up charts. If anyone else has this set up, I put together a spreadsheet based on the Steinhart-Hart equation that you can plug in you resistor values and get a list. I should script that.

-Trout
Re: 5DoA: Thermistor not reading? Maybe pin definition? <solved>
February 14, 2011 07:52PM
has anyone tried writing a macro that encompasses this math, then filling in the temp table using this macro?


-----------------------------------------------
Wooden Mendel
Teacup Firmware
Re: 5DoA: Thermistor not reading? Maybe pin definition? <solved>
February 14, 2011 08:24PM
Architect Wrote:
-------------------------------------------------------
> How are your sensors wired? mine are 0V -> 4.7k
> resistor ->sig->100k thermistor->5V this causes
> the resistance to increase as it gets hotter, not
> decrease as it seems the case in the temp look up
> charts. If anyone else has this set up, I put
> together a spreadsheet based on the Steinhart-Hart
> equation that you can plug in you resistor values
> and get a list. I should script that.
>
> -Trout

My wiring is almost the same, but with gnd and 5V reversed. I.E. my thermistor is in between GND and SIG. I have the rrrf thermistor board, version 1.1. See this wiki page I thought after your comment that maybe I'd swapped the GND and 5V leads, but a glance at the schematic indicates that it's correct.

However, the linear interpolation code will work either. It will effect only the magnitude of the dividend, not the sign of any term. Have to modify the python to generate the table in reverse though. Just make sure the resulting table is still sorted by ADC value, or it won't work.


Triffid: I don't like the idea of a macro, even if calculations that complex could be done in a macro. Which they can't, I think, can a log() and exp() function w/ floats be done in a constant expression? I like being able to customize the intervals. More samples in interesting temperature regions is a good idea, which would be even more difficult if not impossible. Also having a constant table makes debugging much easier.

I.E. I don't think the complexity is worth saving people the work of generating a custom thermistor table. Particularly since the standard table will work fine for most people. I probably should have called it ThermistorTable.h, instead of ThermistorTable.h.dist, since the average guy shouldn't touch it.


--
I'm building it with Baling Wire
Sorry, only registered users may post in this forum.

Click here to login