Offline
Jr. Member
Karma: 3
Posts: 64
|
 |
« on: October 25, 2012, 10:43:24 am » |
Reference manual says processor has temperature sensor on ADC channel 15, what is the API for reading temperature?
|
|
|
|
|
Logged
|
|
|
|
|
Manchester (England England)
Offline
Brattain Member
Karma: 299
Posts: 26030
Solder is electric glue
|
 |
« Reply #1 on: October 25, 2012, 10:52:07 am » |
I don't know for sure as I haven't got a Due yet but what happens when you try and read analogue channel 15. Maybe there isn't one, it wouldn't surprise me because there wasn't one on the old arduino and that had a temperature sensor in it as well.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Jr. Member
Karma: 3
Posts: 64
|
 |
« Reply #2 on: October 25, 2012, 11:14:09 am » |
Yes, I don't have a board yet either (wrong side of the pond) -- looking at the underlying source, me thinks an analogRead(15) might work ...
|
|
|
|
|
Logged
|
|
|
|
|
nr Bundaberg, Australia
Offline
Tesla Member
Karma: 75
Posts: 6975
Scattered showers my arse -- Noah, 2348BC.
|
 |
« Reply #3 on: October 25, 2012, 11:43:39 am » |
From the data sheet AD15 is not an actual pin but is connected to a temperature sensor. and The temperature sensor is connected to Channel 15 of the ADC. The temperature sensor provides an output voltage VT that is proportional to absolute temperature (PTAT). To activate the temperature sensor, TSON bit (ADC_ACR) needs to be set. So analogRead(15) will only work if the TSON bit in ADC_ACR is set by the looks of it. So it's up to the Arduino guys to do that or I guess you can do it yourself. _____ Rob
|
|
|
|
« Last Edit: October 25, 2012, 11:46:12 am by Graynomad »
|
Logged
|
|
|
|
|
Manchester (England England)
Offline
Brattain Member
Karma: 299
Posts: 26030
Solder is electric glue
|
 |
« Reply #4 on: October 25, 2012, 12:22:07 pm » |
Yes but on the normal arduino they masked out the upper part of the channel select byte so you could not access the things like the sensor, zero volts 5V and internal Vref. It would have been so much more flexible if they had not done this. You need to look at the C code for the analogue read on a Due to see what they have done this time.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 27
|
 |
« Reply #5 on: October 25, 2012, 01:15:50 pm » |
I put in a request to enable the ADC15/temperature sensor. However - it is the temperature on the die - which does warm up. To make it be close to the ambient temperature is going to require implementing a power down mode - no power no die warmup - and then on wakeup reading the temperature straight away.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Jr. Member
Karma: 3
Posts: 64
|
 |
« Reply #6 on: October 25, 2012, 03:15:10 pm » |
So analogRead(15) will only work if the TSON bit in ADC_ACR is set by the looks of it. So it's up to the Arduino guys to do that or I guess you can do it yourself. _____ Rob
in hardware/arduino/sam/system/libsam/source/adc.c there is an adc_enable_ts() that sets ADC_ACR_TSON, and the temperature calculation is described in Chapter 46.8 of reference pdf, 2.65mv/deg and 0.8v at 27C
|
|
|
|
|
Logged
|
|
|
|
|
nr Bundaberg, Australia
Offline
Tesla Member
Karma: 75
Posts: 6975
Scattered showers my arse -- Noah, 2348BC.
|
 |
« Reply #7 on: October 25, 2012, 06:50:49 pm » |
Chapter 46.8 of reference pdf What reference PDF? ______ Rob
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Jr. Member
Karma: 3
Posts: 64
|
 |
« Reply #8 on: October 25, 2012, 07:05:16 pm » |
|
|
|
|
|
Logged
|
|
|
|
|
nr Bundaberg, Australia
Offline
Tesla Member
Karma: 75
Posts: 6975
Scattered showers my arse -- Noah, 2348BC.
|
 |
« Reply #9 on: October 25, 2012, 07:53:56 pm » |
Got it, I had an older version of the data sheet with less info.
______ Rob
|
|
|
|
|
Logged
|
|
|
|
|
Nice, France
Offline
Full Member
Karma: 10
Posts: 232
|
 |
« Reply #10 on: October 27, 2012, 11:16:39 am » |
I put in a request to enable the ADC15/temperature sensor. However - it is the temperature on the die - which does warm up. To make it be close to the ambient temperature is going to require implementing a power down mode - no power no die warmup - and then on wakeup reading the temperature straight away.
That seems like a very longwinded way to get a rather inaccurate measurement of the ambient temperature. If you want to measure air temperature, use a temperature sensor that is in the air, not embedded inside a heat-generating device and thermally insulated from the air. On the other hand, if you need to monitor the on-chip temperature for some reason (like, to raise an alarm if it gets too hot) then that would be a good use of this sensor.
|
|
|
|
|
Logged
|
|
|
|
|
Peoples Republic of Cantabrigia
Offline
God Member
Karma: 6
Posts: 640
Arduino happiness
|
 |
« Reply #11 on: October 27, 2012, 11:38:45 am » |
Or, you want to compensate for heat/cold induced changes in adc behavior.
|
|
|
|
|
Logged
|
|
|
|
|
Copenhagen, Denmark
Offline
God Member
Karma: 21
Posts: 886
Have you testrun your INO file today?
|
 |
« Reply #12 on: November 08, 2012, 11:08:01 am » |
There is the same in the god ol' AtmEga328 (ie all Arduino boards). I fixed a little bit mask in the core libraries and now I can read the corechip temperature as analog 8. It is not very accurate, but has a large range -40 C .. +80 C. Mine returns value 340 for -15C (fresh out of the freezer), 375 for 20C
So, without having a Due at hand, I cant see how to enable it there.
|
|
|
|
|
Logged
|
|
|
|
|
Germany
Offline
Full Member
Karma: 10
Posts: 190
|
 |
« Reply #13 on: November 08, 2012, 11:42:04 am » |
I put in a request to enable the ADC15/temperature sensor. However - it is the temperature on the die - which does warm up. To make it be close to the ambient temperature is going to require implementing a power down mode - no power no die warmup - and then on wakeup reading the temperature straight away.
That seems like a very longwinded way to get a rather inaccurate measurement of the ambient temperature. If you want to measure air temperature, use a temperature sensor that is in the air, not embedded inside a heat-generating device and thermally insulated from the air. On the other hand, if you need to monitor the on-chip temperature for some reason (like, to raise an alarm if it gets too hot) then that would be a good use of this sensor. In my opinion it's an good exercise to get "warm" with the new Controller/Board it was similar my first move with the Leonardo figure out how warm is the Controller, for fun not for use...
|
|
|
|
|
Logged
|
|
|
|
|
Germany
Offline
Full Member
Karma: 10
Posts: 190
|
 |
« Reply #14 on: November 28, 2012, 10:50:05 am » |
So I make an shot for the Temp-Sensor on the SAM float trans = 3.3/4096; float offset = 0.8; float factor = 0.00256; int fixtemp = 27;
void setup() { Serial.begin(9600); }
void loop() { float treal = fixtemp + (( trans * temperatur() ) - offset ) / factor; Serial.println(treal); delay(10); }
uint32_t temperatur() { uint32_t ulValue = 0; uint32_t ulChannel; // Enable the corresponding channel adc_enable_channel(ADC, ADC_TEMPERATURE_SENSOR);
// Enable the temperature sensor adc_enable_ts(ADC);
// Start the ADC adc_start(ADC);
// Wait for end of conversion while ((adc_get_status(ADC) & ADC_ISR_DRDY) != ADC_ISR_DRDY);
// Read the value ulValue = adc_get_latest_value(ADC);
// Disable the corresponding channel adc_disable_channel(ADC, ADC_TEMPERATURE_SENSOR);
return ulValue; } Everybody may, use and criticize.
|
|
|
|
|
Logged
|
|
|
|
|
|