# LM7002M Temperature Calculation

**URL:** <https://discourse.myriadrf.org/t/lm7002m-temperature-calculation/3507>\
**Category:** Lime Suite\
**Created:** [19 October 2018 23:02 UTC](https://discourse.myriadrf.org/t/lm7002m-temperature-calculation/3507 "2018-10-19T23:02:27Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![btashton](https://yyz2.discourse-cdn.com/flex034/user_avatar/discourse.myriadrf.org/btashton/32/1796_2.png) [@btashton](https://discourse.myriadrf.org/u/btashton)\
**Post date:** [19 October 2018 23:02 UTC](https://discourse.myriadrf.org/t/lm7002m-temperature-calculation/3507/1 "2018-10-19T23:02:27Z")

</div>

I am trying to understand what is going on in this code, since the returned values do not seem accurate, and the logic here does not match what I understand from the Programming and Calibration Guide.

`Modify_SPI_Reg_bits(LMS7_MUX_BIAS_OUT, 2);`  
This should route `Vptat_600mV` and `vr_cal_ref=600mV` to `bias_top_adcin`, but then the datasheet says `The ratio between the two will be proportional to absolute temp.` In the `Measurement block Control Diagram` we can see the loop that generates:  
MEASR\_TREF\_VAL\<7:0\> (0x0606[15:8])  
MEASR\_TPTAT\_VAL\<7:0\> (0x0606[7:0])

Why are these values scaled and then subtracted instead of generating the ratio. I also see nothing that documents this offset of 50.7C.

I feel like I must be missing something critical to how this works.

````auto
{
    CalibrateInternalADC(32);
    Modify_SPI_Reg_bits(LMS7_RSSI_PD, 0);
    Modify_SPI_Reg_bits(LMS7_RSSI_RSSIMODE, 0);
    uint16_t biasMux = Get_SPI_Reg_bits(LMS7_MUX_BIAS_OUT);
    Modify_SPI_Reg_bits(LMS7_MUX_BIAS_OUT, 2);

    this_thread::sleep_for(chrono::microseconds(250));
    const uint16_t reg606 = SPI_read(0x0606, true);
    float Vtemp = (reg606 >> 8) & 0xFF;
    Vtemp *= 1.84;
    float Vptat = reg606 & 0xFF;
    Vptat *= 1.84;
    float Vdiff = Vptat-Vtemp;
    Vdiff /= 3.9;
    float temperature = 50.7+Vdiff;
    Modify_SPI_Reg_bits(LMS7_MUX_BIAS_OUT, biasMux);
    lime::debug("Vtemp 0x%04X, Vptat 0x%04X, Vdiff = %.2f, temp= %.3f", (reg606 >> 8) & 0xFF, reg606 & 0xFF, Vdiff, temperature);
    return temperature;
}```
````

---

<div class="post-metadata">

**Author:** ![ccsh](https://avatars.discourse-cdn.com/v4/letter/c/3be4f8/32.png) [@ccsh](https://discourse.myriadrf.org/u/ccsh)\
**Post date:** [19 October 2018 23:17 UTC](https://discourse.myriadrf.org/t/lm7002m-temperature-calculation/3507/2 "2018-10-19T23:17:59Z")

</div>

Looks like temperature related issue has [already been reported](https://github.com/myriadrf/LimeSuite/issues/212) on Github, but has not been fixed yet.

---

<div class="post-metadata">

**Author:** ![btashton](https://yyz2.discourse-cdn.com/flex034/user_avatar/discourse.myriadrf.org/btashton/32/1796_2.png) [@btashton](https://discourse.myriadrf.org/u/btashton)\
**Post date:** [19 October 2018 23:20 UTC](https://discourse.myriadrf.org/t/lm7002m-temperature-calculation/3507/3 "2018-10-19T23:20:32Z")

</div>

Yes, I was asking here for more information about this part of the hardware so that I can throw a patch together since I think the documentation does not have all the needed information.

---

<div class="post-metadata">

**Author:** ![btashton](https://yyz2.discourse-cdn.com/flex034/user_avatar/discourse.myriadrf.org/btashton/32/1796_2.png) [@btashton](https://discourse.myriadrf.org/u/btashton)\
**Post date:** [22 October 2018 19:34 UTC](https://discourse.myriadrf.org/t/lm7002m-temperature-calculation/3507/4 "2018-10-22T19:34:34Z")

</div>

@andrewback is there anyone from the Lime team that could answer how this hardware block works?

---

<div class="post-metadata">

**Author:** ![andrewback](https://avatars.discourse-cdn.com/v4/letter/a/22d042/32.png) [@andrewback](https://discourse.myriadrf.org/u/andrewback)\
**Post date:** [23 October 2018 14:24 UTC](https://discourse.myriadrf.org/t/lm7002m-temperature-calculation/3507/5 "2018-10-23T14:24:53Z")

</div>

@Zack would be the best person to ask.

---

<div class="post-metadata">

**Author:** ![DD1US](https://yyz2.discourse-cdn.com/flex034/user_avatar/discourse.myriadrf.org/dd1us/32/2494_2.png) [@DD1US](https://discourse.myriadrf.org/u/DD1US)\
**Post date:** [29 November 2018 15:34 UTC](https://discourse.myriadrf.org/t/lm7002m-temperature-calculation/3507/6 "2018-11-29T15:34:43Z")

</div>

Hello,  
same problem here: the temperature sensor shows readings between 48 and 51 degree, irrespective of the real temperature.  
Please, someone from the Lime team step in and get this resolved.  
Many thanks in advance.  
Kind regards  
Matthias

---

<div class="post-metadata">

**Author:** ![AA7QQ](https://avatars.discourse-cdn.com/v4/letter/a/13edae/32.png) [@AA7QQ](https://discourse.myriadrf.org/u/AA7QQ)\
**Post date:** [29 November 2018 17:56 UTC](https://discourse.myriadrf.org/t/lm7002m-temperature-calculation/3507/7 "2018-11-29T17:56:55Z")

</div>

Temperature is derived from a separate device, places on the board, between the FPGA & LMS chip. a reading from any of the working chips.  
It is NOT readinginternal working temps of either main chip onboard.  
IC 16  
LM75  
This is the temp sensor. It is on page 12 of the V1.4 schematics in .pdf.  
“PCB note: Place between FPGA and LMS”.

Whatever it’s circuitry, it does NOT return any usable temperature.  
47\*-53\* is the max I have seen. 47\* was only because I had it in the refridgerator for 1/2 hour & plugged it right in & checked with LimeSuite.  
Also, if powering a fan from the board, it is designed to turn on at 55\*, of which I have never seen as a reading.  
Maybe I shouls throw it in the oven for a bit?

Ed

---

<div class="post-metadata">

**Author:** ![AA7QQ](https://avatars.discourse-cdn.com/v4/letter/a/13edae/32.png) [@AA7QQ](https://discourse.myriadrf.org/u/AA7QQ)\
**Post date:** [29 November 2018 17:58 UTC](https://discourse.myriadrf.org/t/lm7002m-temperature-calculation/3507/8 "2018-11-29T17:58:08Z")

</div>

Temperature needs to be read from the LMS & FPGA for safety.

Ed

---

<div class="post-metadata">

**Author:** ![IgnasJ](https://avatars.discourse-cdn.com/v4/letter/i/278dde/32.png) [@IgnasJ](https://discourse.myriadrf.org/u/IgnasJ)\
**Post date:** [30 November 2018 10:07 UTC](https://discourse.myriadrf.org/t/lm7002m-temperature-calculation/3507/9 "2018-11-30T10:07:26Z")

</div>

The value of board temperature sensor that is located between FPGA and LMS7 on LimeSDR-USB can be checked form LimeSuiteGUI “modules-\>board controls-\>Board Temperature”. From my experience it returns correct values.

---

<div class="post-metadata">

**Author:** ![AA7QQ](https://avatars.discourse-cdn.com/v4/letter/a/13edae/32.png) [@AA7QQ](https://discourse.myriadrf.org/u/AA7QQ)\
**Post date:** [30 November 2018 13:20 UTC](https://discourse.myriadrf.org/t/lm7002m-temperature-calculation/3507/10 "2018-11-30T13:20:27Z")

</div>

This weekend, I will use a temp probe & refridgerate the board. I think you will see that with a range of 47\*-54\* must be wrong.

Ed

---

<div class="post-metadata">

**Author:** ![mzs](https://yyz2.discourse-cdn.com/flex034/user_avatar/discourse.myriadrf.org/mzs/32/2678_2.png) [@mzs](https://discourse.myriadrf.org/u/mzs)\
**Post date:** [30 November 2018 20:56 UTC](https://discourse.myriadrf.org/t/lm7002m-temperature-calculation/3507/11 "2018-11-30T20:56:30Z")

</div>

My understanding is that there are two temperature sensors on each board.

**LimeSDR-USB**

- IC1 LMS7002M internal temperature sensor ([see page 45 for minimalistic info on LMS7002M register 0x0084(MUX\_BIAS\_OUT) but there is absolutely no information on register 0x0600(RSSI\_PD/RSSI\_RSSIMODE) and register 0x0606(RSSI\_TREF\_VAL/RSSI\_TVPTAT\_VAL)](https://github.com/myriadrf/LMS7002M-docs/raw/master/LMS7002Mr2-SPIRegs-2-2r0.pdf))
- IC16 (LM75) temperature sensor on PCB near FPGA, between LMS7002 and FPGA ([see page 6 for formula](https://datasheets.maximintegrated.com/en/ds/LM75.pdf)).
- IC8 EP4CE40F23C8N Cyclone IV FPGA has no internal temperature sensor

**LimeSDR-Mini**

- IC1 LMS7002M internal temperature sensor ([see page 45 for minimal info, same link as above for LimeSDR-USB](https://github.com/myriadrf/LMS7002M-docs/raw/master/LMS7002Mr2-SPIRegs-2-2r0.pdf))
- IC8 (LM75) by default temperature sensor is unpopulated, empty pads near U-FL Clock synchronization connectors.
- IC5 10M16SAU169C8G Intel MAX 10 FPGA has an internal TSD(Temperature Sensing Diode) accessed via ADC1 ([see page 18 for conversion table](https://www.intel.com/content/dam/www/programmable/us/en/pdfs/literature/hb/max-10/ug_m10_adc.pdf))

**I do not think that this thread would exist if there was some public information on the LMS7002M registers:**  
**0x0600(RSSI\_PD/RSSI\_RSSIMODE) and register**  
**0x0606(RSSI\_TREF\_VAL/RSSI\_TVPTAT\_VAL)**

The little information I could find was in [LimeSuite/src/lime/LMS7002M\_parameters.](https://github.com/myriadrf/LimeSuite/blob/master/src/lime/LMS7002M_parameters.h)h and it is just their address, MSB, LSB, default value, name and tooltip. Not the details required to use the registers, which should be in some public documentation.

```
LMS7_DAC_CLKDIV = { 0x0600, 15, 8, 15, "DAC_CLKDIV", "Clock division ratio for measurement loop" };
LMS7_RSSI_RSSIMODE = { 0x0600, 1, 1, 0, "RSSI_RSSIMODE", ""};
LMS7_RSSI_PD = { 0x0600, 0, 0, 0, "RSSI_PD", ""};
LMS7_RSSI_TREF_VAL = { 0x0606, 15, 8, 0, "RSSI_TREF_VAL", "Stores the temperature reference value"};
LMS7_RSSI_TVPTAT_VAL = { 0x0606, 7, 0, 0, "RSSI_TVPTAT_VAL", "Stores the voltage proportional to absolute temperature value"};
```

---

<div class="post-metadata">

**Author:** ![SimonG4ELI](https://avatars.discourse-cdn.com/v4/letter/s/71e660/32.png) [@SimonG4ELI](https://discourse.myriadrf.org/u/SimonG4ELI)\
**Post date:** [1 December 2018 13:59 UTC](https://discourse.myriadrf.org/t/lm7002m-temperature-calculation/3507/12 "2018-12-01T13:59:17Z")

</div>

Ed,

I agree with you. The reading makes little sense, your feedback will be very interesting.

---

<div class="post-metadata">

**Author:** ![AA7QQ](https://avatars.discourse-cdn.com/v4/letter/a/13edae/32.png) [@AA7QQ](https://discourse.myriadrf.org/u/AA7QQ)\
**Post date:** [2 December 2018 00:01 UTC](https://discourse.myriadrf.org/t/lm7002m-temperature-calculation/3507/13 "2018-12-02T00:01:45Z")

</div>

The Lime is in the freezer, now. Can’t find the temp probe for the meter, but, assume below 0_C.  
Should take about 30 seconds to get it hooked up & test temp with LimeSuite.  
Also, figuring out RF Explorer Spectrum analyzer & sig gen, hooked to the laptop, while the Udoo X86 Ultra is running the LimeSRD USB.  
Oh, Simon, 4 instances of BFM at the 3.072 setting, with just a hair of popping. I would say that’s pretty darn good !!!  
So, after 45 minutes in the freezer, I got a reading of 43.5_C from LimeSuite & 44_C from SDR-Console.  
Something is obviously wrong with the temp. system.  
Now, the fan is controlled by this faulty system (Turns fan on at 55_C from documentation) With the readings skewed this far, Lime Microsystems should send out notice to NOT use the 3VDC FAN header from the LimeSDR USB !!!

This needs to be fixed.

Ed  
AA7QQ

---

<div class="post-metadata">

**Author:** ![btashton](https://yyz2.discourse-cdn.com/flex034/user_avatar/discourse.myriadrf.org/btashton/32/1796_2.png) [@btashton](https://discourse.myriadrf.org/u/btashton)\
**Post date:** [2 December 2018 00:57 UTC](https://discourse.myriadrf.org/t/lm7002m-temperature-calculation/3507/14 "2018-12-02T00:57:36Z")

</div>

@Zack could you respond to my question in the original post on this thread? It would be great to just get some clarification on the hardware block, specifically around the TREF and TPTAT values. The document seems to not be complete about how they are proportional to the absolute temperature

---

<div class="post-metadata">

**Author:** ![mzs](https://yyz2.discourse-cdn.com/flex034/user_avatar/discourse.myriadrf.org/mzs/32/2678_2.png) [@mzs](https://discourse.myriadrf.org/u/mzs)\
**Post date:** [2 December 2018 03:26 UTC](https://discourse.myriadrf.org/t/lm7002m-temperature-calculation/3507/15 "2018-12-02T03:26:52Z")

</div>

The line that applies from the LMS7002M register map document on page 45 is “2 - Vptat\_600 mV and vr\_cal\_ref=600 mV is passed to the ADC input MUX. The ratio between the two will be proportional to the absolute temp.”

That test is selected by this line of code: Modify\_SPI\_Reg\_bits(LMS7\_MUX\_BIAS\_OUT, **2** );

So the setup sounds like it could be something very similar to this: [https://en.wikipedia.org/wiki/Silicon\_bandgap\_temperature\_sensor](https://en.wikipedia.org/wiki/Silicon_bandgap_temperature_sensor)

There is a temperature-independent bandgap reference (vr\_cal\_ref=600 mV) where the the circuit maintains an internal voltage source that has a positive temperature coefficient and another internal voltage source that has a negative temperature coefficient. The two are summed together, and the temperature dependence is cancelled thus providing a fixed voltage reference that is independent of temperature (In this particular case 600 mV).  
By comparing that constant reference voltage to the internal voltage source with a positive temperature coefficient (Vptat\_600 mV) the temperature inside the device can be calculated.

- vr\_cal\_ref (AKA “RSSI\_TREF\_VAL” - bits 15 to 8 of register 0x0606 ) is a temperature- **independent** bandgap reference voltage of exactly 0.6 volts.
- Vptat\_600 (AKA “RSSI\_TVPTAT\_VAL” - bits 7 to 0 of register 0x0606 ) is a temperature- **dependent** bandgap voltage of around ~0.6 volts.

If the above is the case then the current code could possibly be replaced by something much simpler like the below:  
(if you assume that 300K (26.85°C) is room temperature (25°C) and that at exactly 300K the negative temperature coefficient is zero, which may be not be perfectly true, but it probably should be close enough):

```
....
    const uint16_t reg606 = SPI_read(0x0606, true);
    float Vref = (reg606 >> 8) & 0xFF;
    float Vptat = reg606 & 0xFF;
    temperature=(Vptat/Vref)*300 - 273.15 // temperature in degrees centigrade converted from kelvin
...

```

P.S. vptat stands for Voltage Proportional to Absolute Temperature, the second value the reference voltage “should” be a static number at all temperatures (unless the voltage sits between two levels of the ADC and random noise toggles it between two numbers).

And if this gives dire results, there is always the other test on the register map document on page 45(\*). Using the External 10k referance resistor on the PCB (“R11” on both the LimeSDR-USB and LimeSDR-mini) that could be used. But it is a 1% tolerance resistor which has an extremely low TCR (Temperature Coefficient of Resistance) of ±100ppm℃. So over it’s entire operating temperature range (-55℃ to 155℃) its resistance changes by less than 3%, and over the operating temperature range of the LMS7002M (-40℃ to 85℃) less than 1.25%.

Maybe a higher temperature range could be possible with that external 10 kOhm reference resistor. Or maybe a much lower temperature range with a higher resolution, there is not really enough information to tell.

(\*) “1 - vr\_ext\_bak and vr\_cal\_ref=600mV is passed to the ADC input MUX. Vr\_ext\_bak is the voltage read on the off-chip 10 kohm reference resistor. Ip60f is connected to r\_ext=10 kohm and RP\_CALIB\_BIAS is changed until vr\_ext becomes 600 mV.”  
RP\_CALIB\_BIAS is only 5-bits and has a default value of 16, so it is in the middle of the range but only has a total of 32 discrete states or 32 possible temperatures steps. I’m not sure if the really low TCR of the external resistor is a good thing or bad thing, without knowing what Ip60f is in the circuitry inside the chip, it is difficult to know. There really needs to be more documentation available publicly.

---

<div class="post-metadata">

**Author:** ![AA7QQ](https://avatars.discourse-cdn.com/v4/letter/a/13edae/32.png) [@AA7QQ](https://discourse.myriadrf.org/u/AA7QQ)\
**Post date:** [2 December 2018 14:00 UTC](https://discourse.myriadrf.org/t/lm7002m-temperature-calculation/3507/16 "2018-12-02T14:00:58Z")

</div>

What I am seeing on the schematic is that the temp. sensor chip LM75 is connected to the FX3 via SPI. Another lead is LM75 OS, which leads to “NF” R65 (Not Filled)., which if filled, would control the fan directly.  
Then, the “Fan Control” signal is coming from the FPGA Bank 1 pin E4.  
All that code stuff is for the more knowledgable. Same with the math…  
So, the temp sensor sends to the FX3 SPI bus, gets to the FPGA & controls the fan.  
That is my understanding of the system.  
Now, the FX3 could have a temp sense in it, but I have not looked into it.  
Whatever is happening to the conversion is definitely wrong, somewhere.  
I hope this makes it a bit easier for the Techies to correct.

Ed  
AA7QQ

---

<div class="post-metadata">

**Author:** ![IgnasJ](https://avatars.discourse-cdn.com/v4/letter/i/278dde/32.png) [@IgnasJ](https://discourse.myriadrf.org/u/IgnasJ)\
**Post date:** [3 December 2018 07:38 UTC](https://discourse.myriadrf.org/t/lm7002m-temperature-calculation/3507/17 "2018-12-03T07:38:53Z")

</div>

Hi AA7QQ,

You keep bringing up on-board temperature sensor (LM75) but this topic is about incorrect LMS7002M temperature sensor values. So just to clarify, are you also getting wrong values from LMS75 ( LimeSuiteGUI “modules-\>board controls-\>Board Temperature")? If that is correct, then it is a different issue. Personally, I have never noticed issue with LMS75 values.

---

<div class="post-metadata">

**Author:** ![AA7QQ](https://avatars.discourse-cdn.com/v4/letter/a/13edae/32.png) [@AA7QQ](https://discourse.myriadrf.org/u/AA7QQ)\
**Post date:** [3 December 2018 12:36 UTC](https://discourse.myriadrf.org/t/lm7002m-temperature-calculation/3507/18 "2018-12-03T12:36:19Z")

</div>

This is with the temperature reading from LimeSuite (Board connected to LimeSuite & reading the temp on the main page) & SDR-Console. I see no way that 45 minutes in the freezer can give a 43.5 & 44 degrees, respectively. First reading was within 30 seconds. second reading was about 45 seconds.

I mention the LM75, because it is on the schematic as a “Temp Sensor”.

I am not one who understands code & the such. I am just going by what I see on the schematics & thought giving the paths between it & fan control may help.

If the temp is derived from the LMS chip, it surely should not heat up that fast.

I also see that the fan control looks like it was to be controlled by the LM75, but R65(?) was not populated, as per schematics to allow fan control from it.

How I see it, is that the Temp sensor feeds into the FX3 chip. Then, the Fan Control comes from the FPGA.

Ed

---

<div class="post-metadata">

**Author:** ![SimonG4ELI](https://avatars.discourse-cdn.com/v4/letter/s/71e660/32.png) [@SimonG4ELI](https://discourse.myriadrf.org/u/SimonG4ELI)\
**Post date:** [20 December 2018 11:44 UTC](https://discourse.myriadrf.org/t/lm7002m-temperature-calculation/3507/19 "2018-12-20T11:44:08Z")

</div>

Please, please, please look at this issue and either explain why we see the values we do or maybe fix the problem? There is no way the temperature is unchanged with/without a heat sink, fans, cooling.

It must be wrong!

---

<div class="post-metadata">

**Author:** ![andrewback](https://avatars.discourse-cdn.com/v4/letter/a/22d042/32.png) [@andrewback](https://discourse.myriadrf.org/u/andrewback)\
**Post date:** [21 December 2018 13:23 UTC](https://discourse.myriadrf.org/t/lm7002m-temperature-calculation/3507/20 "2018-12-21T13:23:42Z")

</div>

Tagging @IgnasJ.
