Forum Rule: Always post complete source code & details to reproduce any issue!
Page 3 of 3 FirstFirst 1 2 3
Results 51 to 67 of 67

Thread: Teensy 4.0 Internal Temperature measurement

  1. #51
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    15,120
    Wonder if some odd number use might explain the Zero temp @mjs513 showed in a CrashReport w/final beta and one here showed a version of NAN on restart.

  2. #52
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,874
    wasnt the temperature registers changed recently?


    https://github.com/PaulStoffregen/co...ef836d4fa49b40

  3. #53
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    7,558
    Quote Originally Posted by tonton81 View Post
    wasnt the temperature registers changed recently?


    https://github.com/PaulStoffregen/co...ef836d4fa49b40
    Hi @tonton81
    Yes they were - just double checked the changes and looks like the changes are correct.

    Quote Originally Posted by defragster
    Wonder if some odd number use might explain the Zero temp @mjs513 showed in a CrashReport w/final beta and one here showed a version of NAN on restart.
    Not sure that would be the cause for that issue since the temps for testing should have been in the normal range within the scope of unsigned. But always the chance. Yes I am up early - couldn't sleep again.

    Quote Originally Posted by LAtimes
    It looks like this is caused by using unsigned integers in tempmon.c. As temperature goes up, nmeas goes down. When it gets below s_hotCount (i.e. above 95 degrees), the value goes negative, which is a large positive number due to unsigned int.

    Fix is probably to change nmeas and s_hotCount to signed integers
    Actually pretty close to the fix I just tested. Using the fault test sketch (High_Temp_ISR_test) wound up converting to float 2 things:
    Code:
        s_hot_ROOM = (float) (s_hotTemp) - 25.0f;
        s_roomC_hotC = roomCount - s_hotCount;
    One of things that kept getting put off because of other distractions was to test against the temp against your InternalTemperature library to try and figure out why the temps were always running higher than what I thought they should be. So as long as I was working on the issue I added the output of your temp library as a comparison and seeing no differences between the 2 now. The following graph shows this. Blue is tempMon and red it InternalTemperature library with the T4.1 running at 1Ghz:
    Click image for larger version. 

Name:	Capture.jpg 
Views:	14 
Size:	35.6 KB 
ID:	25483

    For reference here is the test sketch:
    Code:
    // MyFault - collection of examples to trigger fault exceptions
    // This may take a while to trip
    #include <InternalTemperature.h>
    
    extern "C" uint32_t set_arm_clock(uint32_t frequency); // clockspeed.c
    
    static uint16_t frequency = 0x03U;
    static uint32_t highAlarmTemp   = 85U;
    static uint32_t lowAlarmTemp    = 25U;
    static uint32_t panicAlarmTemp  = 95U;
    volatile bool TempAlarm = false;
    
    void setup() {
      Serial.begin(9600);
      Serial.print(CrashReport);
      tempmon_setup();
      //set_arm_clock(912000000);
      delay(500);
      //Attach window for high/low window
      attachInterruptVector(IRQ_TEMPERATURE, &High_Low_Temp_isr);
      NVIC_ENABLE_IRQ(IRQ_TEMPERATURE);
    }
    
    elapsedMillis tempPrint;
    void loop() {
      float temperature = tempmonGetTemp();
    
      if(tempPrint > 1000) {
        //Serial.printf("Temp(degC) = , %f", temperature);
        Serial.print(temperature, 2); Serial.print(",");
        Serial.println(InternalTemperature.readTemperatureC(),2);
        tempPrint = 0;
      }
    
      //comment this test out if you want to test panic alarm!!!!!
      if (TempAlarm && ((temperature - highAlarmTemp > 0)) && (temperature - panicAlarmTemp < 0) )
      {
          set_arm_clock(24000000);
          delay(500);
          TempAlarm = false;
          Serial.println();
          Serial.println("Danger Will Robinson");
          Serial.printf("HIGH Temperature Alarm %.1f. \r\n", temperature);
          Serial.println("System Clock set to 24Mhz");
          Serial.println();
      }
    }
    
    static uint32_t s_hotTemp, s_hotCount ;
    static float s_hot_ROOM, s_roomC_hotC;
    
    void tempmon_setup(void)
    {
      uint32_t calibrationData;
      uint32_t roomCount;
      uint32_t tempCodeVal;
    
      //first power on the temperature sensor - no register change 
      //power is already on so uncomment for example
      TEMPMON_TEMPSENSE0 &= ~0x1U;
    
      //set monitoring frequency - no register change
      TEMPMON_TEMPSENSE1 = (((uint32_t)(((uint32_t)(frequency)) << 0U)) & 0xFFFFU);
      
      //read calibration data - this works
      calibrationData = HW_OCOTP_ANA1;
        s_hotTemp = (uint32_t)(calibrationData & 0xFFU) >> 0x00U;
        s_hotCount = (uint32_t)(calibrationData & 0xFFF00U) >> 0X08U;
        roomCount = (uint32_t)(calibrationData & 0xFFF00000U) >> 0x14U;
        s_hot_ROOM = (float) (s_hotTemp) - 25.0f;
        s_roomC_hotC = (float) roomCount - (float) s_hotCount;
        Serial.println("Calibration values from fuse values:");
        Serial.printf(" HOT_TEMP:  %d\n HOT_COUNT: %d\n ROOM_COUNT: %d\n", s_hotTemp, s_hotCount, roomCount);  
        Serial.println("Cal equation: Tmeas = HOT_TEMP - (Nmeas - HOT_COUNT) * ((HOT_TEMP - 25.0) / (ROOM_COUNT – HOT_COUNT))");
        Serial.printf("(HOT_TEMP - 25.0) = %f\n", s_hot_ROOM);
        Serial.printf("(ROOM_COUNT – HOT_COUNT) = %f\n", s_roomC_hotC);
        Serial.println();
        
        //time to set alarm temperatures
      //Set High Alarm Temp
      tempCodeVal = (uint32_t)(s_hotCount + (s_hotTemp - highAlarmTemp) * s_roomC_hotC / s_hot_ROOM);
        TEMPMON_TEMPSENSE0 |= (((uint32_t)(((uint32_t)(tempCodeVal)) << 20U)) & 0xFFF00000U);
      
      //Set Panic Alarm Temp
      tempCodeVal = (uint32_t)(s_hotCount + (s_hotTemp - panicAlarmTemp) * s_roomC_hotC / s_hot_ROOM);
        TEMPMON_TEMPSENSE2 |= (((uint32_t)(((uint32_t)(tempCodeVal)) << 16U)) & 0xFFF0000U);
      
      // Set Low Temp Alarm Temp
      tempCodeVal = (uint32_t)(s_hotCount + (s_hotTemp - lowAlarmTemp) * s_roomC_hotC / s_hot_ROOM);
        TEMPMON_TEMPSENSE2 |= (((uint32_t)(((uint32_t)(tempCodeVal)) << 0U)) & 0xFFFU);
    
      //Start temp monitoring
      TEMPMON_TEMPSENSE0 |= 0x2U;   //starts temp monitoring
    
    }
    
    void High_Low_Temp_isr(void)
    {
        TempAlarm = true;
    }

  4. #54
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    7,558
    Alcon

    Just created a PR: https://github.com/PaulStoffregen/cores/pull/590 with the fixes mentioned in the previous post that should resolve the temperature readings from tempmon.

  5. #55
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    7,558
    Quote Originally Posted by HanJ View Post
    I modified the panic temp to 100 but then the processor immediately stops after reboot. The max I can use for the panic mode is 95. The problem seems in the read value for the chip value.
    If read above 95 the value gets negative. I also dis-abled the shutdown function to be able to see this. I really don't like the behavior it shuts down and does not recover at all. Could this be fixed somehow?
    Thanks all.
    94.33C
    94.33C
    95.00C
    -2890843392.00C
    95.00C
    -2890843392.00C
    91.63C
    With the latest set of changes two issues are now fixed:
    1. Setting panic temp above 95C
    and
    2. Correct readings for temperature.

    A PR has been issued but I am attaching a copy of the tempmon.c file if you want to give it a try.
    Attached Files Attached Files

  6. #56
    Junior Member
    Join Date
    Aug 2021
    Posts
    11
    Quote Originally Posted by mjs513 View Post
    With the latest set of changes two issues are now fixed:
    1. Setting panic temp above 95C
    and
    2. Correct readings for temperature.

    A PR has been issued but I am attaching a copy of the tempmon.c file if you want to give it a try.
    I gave the attached file a try but the behavior is the same. All changes I did are also in tempmon.c. When using the crash report sketch It says no data to report.

    It is easy to verify. Just change the line
    static uint32_t panicAlarmTemp = 95U;
    to
    static uint32_t panicAlarmTemp = 99U;
    The result is a direct crash after reboot when tempmon is called. There is no need to increase the temperature of the IC. Ofcourse I tried that also and when reaching the panic temp the processor restarts until the actual measured temp is below the panic temp.
    So that is ok...

  7. #57
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    7,558
    Quote Originally Posted by HanJ View Post
    I gave the attached file a try but the behavior is the same. All changes I did are also in tempmon.c. When using the crash report sketch It says no data to report.

    It is easy to verify. Just change the line
    static uint32_t panicAlarmTemp = 95U;
    to
    static uint32_t panicAlarmTemp = 99U;
    The result is a direct crash after reboot when tempmon is called. There is no need to increase the temperature of the IC. Ofcourse I tried that also and when reaching the panic temp the processor restarts until the actual measured temp is below the panic temp.
    So that is ok...
    Actually, its fixed, the sketch in #53 is outdated after I made the additional changes to fix in the PR and tempmon.c that I posted. This is the latest version of the sketch that matches whats in tempmon.c and in the pr:

    Code:
    // MyFault - collection of examples to trigger fault exceptions
    // This may take a while to trip
    
    extern "C" uint32_t set_arm_clock(uint32_t frequency); // clockspeed.c
    
    static int16_t frequency = 0x03U;
    static int32_t highAlarmTemp   = 50U;
    static int32_t lowAlarmTemp    = 25U;
    static int32_t panicAlarmTemp  = 90U;
    volatile bool TempAlarm = false;
    
    void setup() {
      Serial.begin(9600);
      Serial.print(CrashReport);
      tempmon_setup();
      set_arm_clock(912000000);
      delay(500);
      //Attach window for high/low window
      attachInterruptVector(IRQ_TEMPERATURE, &High_Low_Temp_isr);
      NVIC_ENABLE_IRQ(IRQ_TEMPERATURE);
    }
    
    elapsedMillis tempPrint;
    void loop() {
      float temperature = tempmonGetTemp();
    
      if(tempPrint > 1000) {
        Serial.printf("Temp(degC) = , %f\n", temperature);
        tempPrint = 0;
      }
    
      //comment this test out if you want to test panic alarm!!!!!
      if (TempAlarm && ((temperature - highAlarmTemp > 0)) && (temperature - panicAlarmTemp < 0) )
      {
          set_arm_clock(24000000);
          delay(500);
          TempAlarm = false;
          Serial.println();
          Serial.println("Danger Will Robinson");
          Serial.printf("HIGH Temperature Alarm %.1f. \r\n", temperature);
          Serial.println("System Clock set to 24Mhz");
          Serial.println();
      }
    }
    
    static uint32_t s_hotTemp, s_hotCount ;
    static float s_hot_ROOM, s_roomC_hotC;
    
    void tempmon_setup(void)
    {
      uint32_t calibrationData;
      uint32_t roomCount;
      uint32_t tempCodeVal;
    
      //first power on the temperature sensor - no register change 
      //power is already on so uncomment for example
      TEMPMON_TEMPSENSE0 &= ~0x1U;
    
      //set monitoring frequency - no register change
      TEMPMON_TEMPSENSE1 = (((uint32_t)(((uint32_t)(frequency)) << 0U)) & 0xFFFFU);
      
      //read calibration data - this works
      calibrationData = HW_OCOTP_ANA1;
        s_hotTemp = (uint32_t)(calibrationData & 0xFFU) >> 0x00U;
        s_hotCount = (uint32_t)(calibrationData & 0xFFF00U) >> 0X08U;
        roomCount = (uint32_t)(calibrationData & 0xFFF00000U) >> 0x14U;
        s_hot_ROOM = (float) (s_hotTemp) - 25.0f;
        s_roomC_hotC = (float) roomCount - (float) s_hotCount;
      
        //time to set alarm temperatures
      //Set High Alarm Temp
      tempCodeVal = ((float)s_hotCount + ((float)s_hotTemp - highAlarmTemp) * s_roomC_hotC / s_hot_ROOM);
        TEMPMON_TEMPSENSE0 |= (((uint32_t)(((uint32_t)(tempCodeVal)) << 20U)) & 0xFFF00000U);
      
      //Set Panic Alarm Temp
      tempCodeVal = ((float)s_hotCount + ((float)s_hotTemp - panicAlarmTemp) * s_roomC_hotC / s_hot_ROOM);
      TEMPMON_TEMPSENSE2 |= (((uint32_t)(((uint32_t)(tempCodeVal)) << 16U)) & 0xFFF0000U);
      
      // Set Low Temp Alarm Temp
      tempCodeVal = ((float)s_hotCount + ((float)s_hotTemp - lowAlarmTemp) * s_roomC_hotC / s_hot_ROOM);
        TEMPMON_TEMPSENSE2 |= (((uint32_t)(((uint32_t)(tempCodeVal)) << 0U)) & 0xFFFU);
    
      //Start temp monitoring
      TEMPMON_TEMPSENSE0 |= 0x2U;   //starts temp monitoring
    
    }
    
    void High_Low_Temp_isr(void)
    {
        TempAlarm = true;
    }
    cheers

    EDIT: Here is the results of running the updated test sketch - no hangs on setting Panic alarm to 110:
    Click image for larger version. 

Name:	Capture.jpg 
Views:	16 
Size:	84.6 KB 
ID:	25494
    Last edited by mjs513; 08-03-2021 at 12:21 AM.

  8. #58
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    7,558
    Alcon

    Just issued PR: https://github.com/PaulStoffregen/MyFault/pull/16 to correct temp sketch examples to match changes in tempmon.c. This is just a heads up.


    EDIT: There seems to be another issue that I just discovered but not quite sure why its happening. If you set the PanicTemp down below 80 or so the fault handler shuts down the T4 even if the temp is at 45degC - have to find out why - its bothering me.

    EDIT2: NONE Issue with tempmon.c - issue is with the test sketch - here is the fixed sketch that I just updated:
    Code:
    // MyFault - collection of examples to trigger fault exceptions
    // This may take a while to trip
    
    extern "C" uint32_t set_arm_clock(uint32_t frequency); // clockspeed.c
    
    static int16_t frequency = 0x03U;
    static int32_t highAlarmTemp   = 50U;
    static int32_t lowAlarmTemp    = 25U;
    static int32_t panicAlarmTemp  = 55U;
    volatile bool TempAlarm = false;
    
    void setup() {
      Serial.begin(9600);
      Serial.print(CrashReport);
      tempmon_setup();
      set_arm_clock(912000000);
      delay(500);
      //Attach window for high/low window
      attachInterruptVector(IRQ_TEMPERATURE, &High_Low_Temp_isr);
      NVIC_ENABLE_IRQ(IRQ_TEMPERATURE);
    }
    
    elapsedMillis tempPrint;
    void loop() {
      float temperature = tempmonGetTemp();
    
      if(tempPrint > 1000) {
        Serial.printf("Temp(degC) = , %f\n", temperature);
        tempPrint = 0;
      }
    
      //comment this test out if you want to test panic alarm!!!!!
      if (TempAlarm && ((temperature - highAlarmTemp > 0)) && (temperature - panicAlarmTemp < 0) )
      {
          set_arm_clock(24000000);
          delay(500);
          TempAlarm = false;
          Serial.println();
          Serial.println("Danger Will Robinson");
          Serial.printf("HIGH Temperature Alarm %.1f. \r\n", temperature);
          Serial.println("System Clock set to 24Mhz");
          Serial.println();
      }
    }
    
    static uint32_t s_hotTemp, s_hotCount ;
    static float s_hot_ROOM, s_roomC_hotC;
    
    void tempmon_setup(void)
    {
      uint32_t calibrationData;
      uint32_t roomCount;
      uint32_t tempCodeVal;
    
      //first power on the temperature sensor - no register change 
      //power is already on so uncomment for example
      //TEMPMON_TEMPSENSE0 &= ~0x1U;
    
      //Stop current temp monitoring
      TEMPMON_TEMPSENSE0 &= ~0x2U;
      //set monitoring frequency - no register change
      TEMPMON_TEMPSENSE1 = (((uint32_t)(((uint32_t)(frequency)) << 0U)) & 0xFFFFU);
      
      //read calibration data - this works
      calibrationData = HW_OCOTP_ANA1;
        s_hotTemp = (uint32_t)(calibrationData & 0xFFU) >> 0x00U;
        s_hotCount = (uint32_t)(calibrationData & 0xFFF00U) >> 0X08U;
        roomCount = (uint32_t)(calibrationData & 0xFFF00000U) >> 0x14U;
        s_hot_ROOM = (float) (s_hotTemp) - 25.0f;
        s_roomC_hotC = (float) roomCount - (float) s_hotCount;
    
        //time to set alarm temperatures
      //Set High Alarm Temp
      tempCodeVal = ((float)s_hotCount + ((float)s_hotTemp - highAlarmTemp) * s_roomC_hotC / s_hot_ROOM);
        TEMPMON_TEMPSENSE0 |= (((uint32_t)(((uint32_t)(tempCodeVal)) << 20U)) & 0xFFF00000U);
      
      //Set Panic Alarm Temp
      tempCodeVal = ((float)s_hotCount + ((float)s_hotTemp - panicAlarmTemp) * s_roomC_hotC / s_hot_ROOM);
        TEMPMON_TEMPSENSE2 |= (((uint32_t)(((uint32_t)(tempCodeVal)) << 16U)) & 0xFFF0000U);
      
      // Set Low Temp Alarm Temp
      tempCodeVal = ((float)s_hotCount + ((float)s_hotTemp - lowAlarmTemp) * s_roomC_hotC / s_hot_ROOM);
        TEMPMON_TEMPSENSE2 |= (((uint32_t)(((uint32_t)(tempCodeVal)) << 0U)) & 0xFFFU);
      // Set Low Temp Alarm Temp
      tempCodeVal = ((float)s_hotCount + ((float)s_hotTemp - lowAlarmTemp) * s_roomC_hotC / s_hot_ROOM);
        TEMPMON_TEMPSENSE2 |= (((uint32_t)(((uint32_t)(tempCodeVal)) << 0U)) & 0xFFFU);
    
      //Start temp monitoring
      TEMPMON_TEMPSENSE0 |= 0x2U;   //starts temp monitoring
    
    }
    
    void High_Low_Temp_isr(void)
    {
        TempAlarm = true;
    }
    Last edited by mjs513; 08-03-2021 at 12:34 AM.

  9. #59
    Junior Member
    Join Date
    Aug 2021
    Posts
    11
    Quote Originally Posted by mjs513 View Post
    Actually, its fixed, the sketch in #53 is outdated after I made the additional changes to fix in the PR and tempmon.c that I posted. This is the latest version of the sketch that matches whats in tempmon.c and in the pr:

    Code:
    // MyFault - collection of examples to trigger fault exceptions
    // This may take a while to trip
    
    extern "C" uint32_t set_arm_clock(uint32_t frequency); // clockspeed.c
    
    static int16_t frequency = 0x03U;
    static int32_t highAlarmTemp   = 50U;
    static int32_t lowAlarmTemp    = 25U;
    static int32_t panicAlarmTemp  = 90U;
    volatile bool TempAlarm = false;
    
    void setup() {
      Serial.begin(9600);
      Serial.print(CrashReport);
      tempmon_setup();
      set_arm_clock(912000000);
      delay(500);
      //Attach window for high/low window
      attachInterruptVector(IRQ_TEMPERATURE, &High_Low_Temp_isr);
      NVIC_ENABLE_IRQ(IRQ_TEMPERATURE);
    }
    
    elapsedMillis tempPrint;
    void loop() {
      float temperature = tempmonGetTemp();
    
      if(tempPrint > 1000) {
        Serial.printf("Temp(degC) = , %f\n", temperature);
        tempPrint = 0;
      }
    
      //comment this test out if you want to test panic alarm!!!!!
      if (TempAlarm && ((temperature - highAlarmTemp > 0)) && (temperature - panicAlarmTemp < 0) )
      {
          set_arm_clock(24000000);
          delay(500);
          TempAlarm = false;
          Serial.println();
          Serial.println("Danger Will Robinson");
          Serial.printf("HIGH Temperature Alarm %.1f. \r\n", temperature);
          Serial.println("System Clock set to 24Mhz");
          Serial.println();
      }
    }
    
    static uint32_t s_hotTemp, s_hotCount ;
    static float s_hot_ROOM, s_roomC_hotC;
    
    void tempmon_setup(void)
    {
      uint32_t calibrationData;
      uint32_t roomCount;
      uint32_t tempCodeVal;
    
      //first power on the temperature sensor - no register change 
      //power is already on so uncomment for example
      TEMPMON_TEMPSENSE0 &= ~0x1U;
    
      //set monitoring frequency - no register change
      TEMPMON_TEMPSENSE1 = (((uint32_t)(((uint32_t)(frequency)) << 0U)) & 0xFFFFU);
      
      //read calibration data - this works
      calibrationData = HW_OCOTP_ANA1;
        s_hotTemp = (uint32_t)(calibrationData & 0xFFU) >> 0x00U;
        s_hotCount = (uint32_t)(calibrationData & 0xFFF00U) >> 0X08U;
        roomCount = (uint32_t)(calibrationData & 0xFFF00000U) >> 0x14U;
        s_hot_ROOM = (float) (s_hotTemp) - 25.0f;
        s_roomC_hotC = (float) roomCount - (float) s_hotCount;
      
        //time to set alarm temperatures
      //Set High Alarm Temp
      tempCodeVal = ((float)s_hotCount + ((float)s_hotTemp - highAlarmTemp) * s_roomC_hotC / s_hot_ROOM);
        TEMPMON_TEMPSENSE0 |= (((uint32_t)(((uint32_t)(tempCodeVal)) << 20U)) & 0xFFF00000U);
      
      //Set Panic Alarm Temp
      tempCodeVal = ((float)s_hotCount + ((float)s_hotTemp - panicAlarmTemp) * s_roomC_hotC / s_hot_ROOM);
      TEMPMON_TEMPSENSE2 |= (((uint32_t)(((uint32_t)(tempCodeVal)) << 16U)) & 0xFFF0000U);
      
      // Set Low Temp Alarm Temp
      tempCodeVal = ((float)s_hotCount + ((float)s_hotTemp - lowAlarmTemp) * s_roomC_hotC / s_hot_ROOM);
        TEMPMON_TEMPSENSE2 |= (((uint32_t)(((uint32_t)(tempCodeVal)) << 0U)) & 0xFFFU);
    
      //Start temp monitoring
      TEMPMON_TEMPSENSE0 |= 0x2U;   //starts temp monitoring
    
    }
    
    void High_Low_Temp_isr(void)
    {
        TempAlarm = true;
    }
    cheers

    EDIT: Here is the results of running the updated test sketch - no hangs on setting Panic alarm to 110:
    Click image for larger version. 

Name:	Capture.jpg 
Views:	16 
Size:	84.6 KB 
ID:	25494

    I tested the sketch as attached and indeed no hangups. However the reading will not exceed the 95C even if I continue increasing the temperature far above the 95C.

  10. #60
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    7,558
    I have no way to go above 95deg C - well maybe a hair dryer would work but also don't feel like damaging a T4.1. Two suggestions
    1. Don't use the sketch. Replace the tempon.c file with the one in core and just use tempmonGetTemp() to display the temp. But change the panic alarm in the tempmon.c file to what you would like. Need to check maybe a problem with the sketch. The sketch was meant to be used to test faults.
    2. You could try the InternalTemperature library, https://forum.pjrc.com/threads/43297...rature+library, to see if there are any differences

  11. #61
    Junior Member
    Join Date
    Aug 2021
    Posts
    11
    Ok, I will first try if I can find maybe some problem also. The help here is great. I modified a tempmon.c from TD1.53 that for now helps me to continue. It simply disables the panic temp shutdown. I modified my SW in such a way that I read the temp every sec and write the max value to the EEprom. In this way I also get a good impression what to expect in the car. But running at 20C ambient I already see around 81C. So not that much margin left. I also don't want you to blow your Teensy ofcourse.

  12. #62
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    7,558
    Quote Originally Posted by HanJ View Post
    Ok, I will first try if I can find maybe some problem also. The help here is great. I modified a tempmon.c from TD1.53 that for now helps me to continue. It simply disables the panic temp shutdown. I modified my SW in such a way that I read the temp every sec and write the max value to the EEprom. In this way I also get a good impression what to expect in the car. But running at 20C ambient I already see around 81C. So not that much margin left. I also don't want you to blow your Teensy ofcourse.
    Well - I blew it off course. I took a T4 and ran blink doing the edits I suggested, i.e, panicTemp = 110 and printing temp using tempmonGetTemp every second. Used a hot air gun to heat up the T4. Plotted the data but at about over 90 and less than 95 (maybe 92) lost the temp readings - temp went to 0. Is that what you are seeing but also lost what was already there. Need to figure that one out now.

    EDIT: just redid it real fast
    Code:
    93.86
    95.00
    -2444290304.00
    -2444290304.00
    95.00
    93.86
    EDIT2:
    Tried it using @LAtimes InternalTemperature library and same thing happened:
    Code:
    94.43
    94.43
    -2444290304.00
    -2444290304.00
    -2444290304.00
    -2444290304.00
    -2444290304.00
    94.43
    93.86
    basically an overflow is occurring.

  13. #63
    Junior Member
    Join Date
    Aug 2021
    Posts
    11
    That is indeed what I see with unmodified tempmon.c. As I disabled the actual shutdown my reading continued and saw the negative numbers. Please be noted I did that with TD1.53 and not 1.54
    Please use the tempmon.c you posted as lib. If I use that one, or any other version, and increase the panic temp above 95, you will see that it crash at startup.
    If you make simple loop that reads every sec or so the temp you will see the same.
    This is the part of the code I use. It is in function that is called every sec by a timer.
    The max value I can use for panictemp is 95 and all works fine, if set 1 higher it crashes.
    In this way there is no need for you to heat up to check the first behavior.


    CoreTemperature = tempmonGetTemp();
    if (CoreTemperature > MaxCoreTemperature) MaxCoreTemperature = CoreTemperature;
    #ifdef DEBUG_TEMP
    Serial.print("Processor core temperature: ");
    Serial.print(CoreTemperature);
    Serial.println("C");
    #endif

  14. #64
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    7,558
    Ok found the problem and fixed it for temps over 95
    Code:
    Temp(degC) = , 95.000000
    1201, 1201
    Temp(degC) = , 95.000000
    1200, 1201
    Temp(degC) = , 95.569107
    1199, 1201
    Temp(degC) = , 96.138214
    1200, 1201
    Temp(degC) = , 95.569107
    1198, 1201
    Temp(degC) = , 96.707314
    1197, 1201
    Temp(degC) = , 97.276421
    1197, 1201
    Temp(degC) = , 97.276421
    1196, 1201
    Temp(degC) = , 97.845528
    1196, 1201
    Temp(degC) = , 97.845528
    1196, 1201
    Temp(degC) = , 97.845528
    1194, 1201
    Temp(degC) = , 98.983742
    1194, 1201
    Temp(degC) = , 98.983742
    1193, 1201
    Temp(degC) = , 99.552849
    1192, 1201
    Temp(degC) = , 100.121948
    1193, 1201
    Temp(degC) = , 99.552849
    1192, 1201
    Temp(degC) = , 100.121948
    1192, 1201
    Temp(degC) = , 100.121948
    1192, 1201
    Temp(degC) = , 100.121948
    1191, 1201
    Temp(degC) = , 100.691055
    1190, 1201
    Temp(degC) = , 101.260162
    1190, 1201
    Temp(degC) = , 101.260162
    1189, 1201
    Temp(degC) = , 101.829269
    1190, 1201
    Temp(degC) = , 101.260162
    1189, 1201
    Temp(degC) = , 101.829269
    Here is the copy of tempmon.c that I am using that has no crashes whatsoever when you set temp about 95.

    EDIT: Test run using blink with temps printed every second using the tempmon.c that I attached:
    Click image for larger version. 

Name:	Capture.PNG 
Views:	13 
Size:	18.8 KB 
ID:	25504
    Attached Files Attached Files
    Last edited by mjs513; 08-03-2021 at 06:28 PM.

  15. #65
    Junior Member
    Join Date
    Aug 2021
    Posts
    11
    Tested and indeed works perfect. Tested now at panic set to 99 and when temp is reached a reset occurs and starts when temp is below 99. Here the temps after restart
    Processor core temperature: 98.37C
    Processor core temperature: 97.69C
    Processor core temperature: 97.69C
    Processor core temperature: 97.02C

    Really great and thanks a lot...you made my day..

  16. #66
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    7,558
    Quote Originally Posted by HanJ View Post
    Tested and indeed works perfect. Tested now at panic set to 99 and when temp is reached a reset occurs and starts when temp is below 99. Here the temps after restart
    Processor core temperature: 98.37C
    Processor core temperature: 97.69C
    Processor core temperature: 97.69C
    Processor core temperature: 97.02C

    Really great and thanks a lot...you made my day..
    Actually thank you, finally dug deep enough into the innards on tempmon again to resolve a long standing issue with temp - the issue with setting temp above 95 and reading temp was new and definitely need to be fixed.

    PS> Glad I was able to make your day.

    @Paul - the PR is update with this last change.

  17. #67
    Junior Member
    Join Date
    Aug 2021
    Posts
    11
    thanks again...and as said, don't worry too much about core temperatures above 90C....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •