Design: Temperature sensor -> Interrupt

Thread Starter

Grin Salt

Joined Jan 10, 2024
11
This is a design question, but let's start with a real SoC: Amlogic A311D. According to its datasheet, it has two on SoC temperature sensors. Each allows setting of thresholds which are used to generate interrupt. I would assume there is a low threshold, and a high one. But it had 4 pairs for each sensors. Each threshold can be individually controlled: enabled, disabled, set threshold. So my first question is, why do we need more than one pair to detect if the temperature crosses a threshold? Wouldn't one enough? If the temperature reading is high and generates interrupt, the service should disable interrupt, set the system thermal state to another value, and then may set to a new threshold. I couldn't understand why the SoC has four pairs of thresholds. The thing is, with 4 high thresholds, if the first one is crossed, the service has to disable it, and then keep waiting for the rest. It's not like the one that is crossed can be used any more.

2nd question: say I need to design a system which has a remote temperature sensor, so I connect the signal to ADC, and then I also need to generate interrupt with thresholds. Do I need to follow the Amlogic's example and put multiple comparators? Or do I just need to put one pair there?

So in general, this is a system level question, from temperature sensors, to ADC, to comparator, to interrupt generation, and to driver handling the interrupt. I hope I could learn some insights.

Check the last few pages from https://datasheetspdf.com/pdf-file/1410888/AMLOGIC/A311D/1 for the diagram
 

Jerry-Hat-Trick

Joined Aug 31, 2022
552
I need to design a system which has a remote temperature sensor, so I connect the signal to ADC, and then I also need to generate interrupt with thresholds.
As an engineer, I question whether a device which needs a 1,438 page datasheet to explain it is worth anybody's time.

For your requirement, it sounds like you need to select a suitable sensor for the range of temperature you want to measure, to power, offset and amplify the analogue output, ADC into a processor and set interrupt thresholds in code?
 

Ya’akov

Joined Jan 27, 2019
9,170
Welcome to AAC.

The four sets of thresholds can be used to provide hysteresis so that the temperature that is needed to reset something is different than to set it.

They can also be used to provide incremental changes based on state. That is, if the temperature is within threshold pair 1, certain things are true different to threshold pair 2, and so on.

Is your confusion arising from having a particular application in mind that doesn’t need this functionality? Or maybe because you didn’t consider the idea that you might use the four ranges to signal different states?
 

Thread Starter

Grin Salt

Joined Jan 10, 2024
11
Welcome to AAC.

The four sets of thresholds can be used to provide hysteresis so that the temperature that is needed to reset something is different than to set it.

They can also be used to provide incremental changes based on state. That is, if the temperature is within threshold pair 1, certain things are true different to threshold pair 2, and so on.

Is your confusion arising from having a particular application in mind that doesn’t need this functionality? Or maybe because you didn’t consider the idea that you might use the four ranges to signal different states?
Thanks for replying. I do have an application in mind, which is to determine the thermal state, so CPU work load can be adjusted to counter the heat generation. But, I believe this is still a general application. So let me analyze this a little bit:

The client will only be able to enable one pair of threshold, I think. Due to hysteresis, when we set a range, say, [39, 40], and if T exceeds 40, we move the window to [39.4, 41] (if 40 has a hysteresis of 0.6 degree, which means we need T go down below 39.4 to go back one level). The second range is now enabled, but we have to disable the first range. Otherwise, when T goes to 39.8, and then 40.1, it will false trigger at 40. So I feel like only one range is needed since all other ranges are to be disabled. Then the software will keep changing the only pair as long as T is out of the range.

Also, my application has 7 levels, so 4 hardware pairs are not enough for me to use them. I need 6 pairs. But even if the system provides 6, with the false trigger problem, I have to disable the rest. So I am not clear how much we need 4 pairs of thresholds or more.
 

Thread Starter

Grin Salt

Joined Jan 10, 2024
11
As an engineer, I question whether a device which needs a 1,438 page datasheet to explain it is worth anybody's time.

For your requirement, it sounds like you need to select a suitable sensor for the range of temperature you want to measure, to power, offset and amplify the analogue output, ADC into a processor and set interrupt thresholds in code?
It's ok. I am on the thermal side so I only need to read the last few pages for the thermal thresholds. For now, I guess we can learn from this on how to handle the thermal side for a device.

My focus now is the interrupt or the hardware thresholds mechanism that generates interrupt. I am trying to learn more so I can summarize their commonalities to form a better software api. For example, if one pair is enough, I could design an api to ignore the rest of the thresholds, and only use one pair. But if every SoC provides more than one pair, then I may need to learn why. If the purpose of multiple thresholds is for different processes to use different pair, I may follow that pattern and may come up with a way to allow different processes to use different pairs, but for each process they only see one pair. If some case there is not even an interrupt, I may have to use polling and need to consider that.
 

WBahn

Joined Mar 31, 2012
30,082
My guess is that each temperature sensor is placed near a particular part of the die that is most likely to run at high temperatures.
 

Jerry-Hat-Trick

Joined Aug 31, 2022
552
It's ok. I am on the thermal side so I only need to read the last few pages for the thermal thresholds. For now, I guess we can learn from this on how to handle the thermal side for a device.

My focus now is the interrupt or the hardware thresholds mechanism that generates interrupt. I am trying to learn more so I can summarize their commonalities to form a better software api. For example, if one pair is enough, I could design an api to ignore the rest of the thresholds, and only use one pair. But if every SoC provides more than one pair, then I may need to learn why. If the purpose of multiple thresholds is for different processes to use different pair, I may follow that pattern and may come up with a way to allow different processes to use different pairs, but for each process they only see one pair. If some case there is not even an interrupt, I may have to use polling and need to consider that.
Thanks for taking the time to reply to my post. Maybe I would understand better if I studied the datasheet in detail, but I'm still wondering why a simple temperature sensor (or sensors), ADC and processor code can't do what you need - any chance you could share more detail about your application?
 

Thread Starter

Grin Salt

Joined Jan 10, 2024
11
Thanks for taking the time to reply to my post. Maybe I would understand better if I studied the datasheet in detail, but I'm still wondering why a simple temperature sensor (or sensors), ADC and processor code can't do what you need - any chance you could share more detail about your application?
The challenge is for me to understand why there are 4 rise thresholds and 4 fall thresholds. I am not clear why a client would need more then one rise threshold. For example, say for an application, the client needs to get notification when temperature changes from one range to another, and we have many ranges: [-, 40], [39.5, 60], [59, 80], [79, 90], [89, 110], [109, 120], [119,-]. So at first, as the client, I would just set Fall(0) = -, and Rise(0) to be 40. When T > 40, I would get notified, and then I can set Fall(0) to be 59, and Rise(0) to be 60. And if T goes below 59, good, I will move the window back. If T goes above 60, I will then set the range to be the next. I will never need another pair of threshold. Because T can't simultaneously cross two threshold. It can only cross one threshold at a time. Therefore, why are there four rise thresholds?

And then since I need to connect external sensors to the SoC, I may need to connect to the ADC's input of the SoC. Usually there is no post ADC thresholds - interrupt mechanism I think. Or do you know any SoC that has thresholds associated with each ADC channel so it can generate interrupt, just like the A311D's internal integrated sensors? For my to design my own SoC in the future, is it common to add thresholds - interrupt generation for ADC channels?
 

MisterBill2

Joined Jan 23, 2018
18,600
In proportional feedback systems there is feedback based on the amount of error. In ON/OFF systems the feedback is based only on above/below some target value. Those systems can thus never be stable. So the normal scheme is to have a small area of "acceptably close" and that requires a minimum of two ON/OFF sensors. An alternative is a feedback and control scheme where the correction is proportional to the error magnitude. It is that area where "the book" grows to a of of pages.
"Feedback Systems" is a whole area of engineering if you want to be really accurate and stable.
 

MrChips

Joined Oct 2, 2009
30,824
You have two separate design issues lumped into one question.

1) Use ADC to measure temperature.

2) Interrupts are used for high priority exception processing. This can be triggered by either hardware or software.
 

MisterBill2

Joined Jan 23, 2018
18,600
Referencing post #1, and again, post #9, as to why more than one threshold crossing might be required, I have to ask what the purpose of the temperature sensing would be. In most cases temperature sensing is done to allow temperature control, and that requires control of a heat source or removal capability, which must be on, off, or rate controlled.
 

Thread Starter

Grin Salt

Joined Jan 10, 2024
11
Referencing post #1, and again, post #9, as to why more than one threshold crossing might be required, I have to ask what the purpose of the temperature sensing would be. In most cases temperature sensing is done to allow temperature control, and that requires control of a heat source or removal capability, which must be on, off, or rate controlled.
One use case would be to detect if the temperature is out of a range, and then react to it, by removing processes, or turning on fans. In this case, I would say there need to be one pair, since once the interrupt is raised, the driver can set new range for next step.

The thing is, I want to learn in which case do we need more than one pair of the thresholds?
 

MisterBill2

Joined Jan 23, 2018
18,600
There are two different sorts of feedback control of a variable condition. The one sort is analog control, where there is not any actual "off state" of the driving function. A good example of that is an audio amplifier with negative feedback, which is intended to keep the output as an exact amplified version of the input. Another even better example is a skilled driver, driving on a road and staying centered in one lane. As the vehicle may drift very slightly toward one side, the driver steers very slightly toward the other side, to correct the small error.
An example of an ON/OFF feedback control would be a very poor driver in traffic on the road: The driver accellerates strongly, then realizes that they are going to hit the car ahead, and so they slam on the brakes for maximum braking. The unskilled driver repeats the cycle as long as they are on the road. The unskilled driver knows no options between full on and full stop. ( Such poor drivers can be seen daily on "The Loop" in Chicago.)

More than one set of setpoints will be required whenever there is more than one level of correction available.
 

Thread Starter

Grin Salt

Joined Jan 10, 2024
11
There are two different sorts of feedback control of a variable condition. The one sort is analog control, where there is not any actual "off state" of the driving function. A good example of that is an audio amplifier with negative feedback, which is intended to keep the output as an exact amplified version of the input. Another even better example is a skilled driver, driving on a road and staying centered in one lane. As the vehicle may drift very slightly toward one side, the driver steers very slightly toward the other side, to correct the small error.
An example of an ON/OFF feedback control would be a very poor driver in traffic on the road: The driver accellerates strongly, then realizes that they are going to hit the car ahead, and so they slam on the brakes for maximum braking. The unskilled driver repeats the cycle as long as they are on the road. The unskilled driver knows no options between full on and full stop. ( Such poor drivers can be seen daily on "The Loop" in Chicago.)

More than one set of setpoints will be required whenever there is more than one level of correction available.
The thresholds are adjustable. Once an interrupt is raised, the driver can adjust the threshold to the next level. This is equivalent to disable the first threshold and then use another. The thing is, at any time, temperature can only cross one threshold. Say T is 40C, and Threshold1= 41C, Threshold2 = 43C, ... What's the point? How about once T is 41C, T1 is changed to 43C? What is the purpose of Threshold2 instead of just reusing Threshold1?

And what's more complicated is that, if T1 and T2 are both used, once T > T1, the driver has to disable T1 to use T2. If T1 is still enabled, the sensor will keep generating interrupt. But if T1 is disabled, and T2 is enabled, what's the point of having two instead of just one?
 

MisterBill2

Joined Jan 23, 2018
18,600
For a simple ON/OFF control there are normally two setpoints, one to switch on and a different setpoint to switch off. That is to avoid oscillation if the variable is exactly at the switching value.
 

MisterBill2

Joined Jan 23, 2018
18,600
If you have already read the temperature once, why do you need interrupts?
Indeed! Temperature control requires periodic checks, Temperature sensing is a polled operation. Only if there is an ON/OFF sensor would there be an interrupt, but really, with an ON/OFF sensor there is no need for a processor. The sensor IS the logic. (one bit math)
Otherwise, an analog sensor wold be used.
I really recommend a textbook: "Feedback systems, Discrete and Integrated" Although there are other good books around as well.
 

Thread Starter

Grin Salt

Joined Jan 10, 2024
11
If you have already read the temperature once, why do you need interrupts?
If you know how Android handles thermal. There are 7 levels that require different strategies to reduce heat generation. if T is say Severe, then you probably should warn users. And also start to reduce CPU frequency. But if it's Moderate, you don't really need ot do any thing. That's why we need interrupt to tell us when T crosses any of these thresholds. (instead of polling)
 

Thread Starter

Grin Salt

Joined Jan 10, 2024
11
Indeed! Temperature control requires periodic checks, Temperature sensing is a polled operation. Only if there is an ON/OFF sensor would there be an interrupt, but really, with an ON/OFF sensor there is no need for a processor. The sensor IS the logic. (one bit math)
Otherwise, an analog sensor wold be used.
I really recommend a textbook: "Feedback systems, Discrete and Integrated" Although there are other good books around as well.
I think any discussion related to analog circuit is irrelevant, since the topic is Amlogic A311D, a CPU that has two temperature sensors, with 4 pairs of temperature thresholds for interrupt.
 
Top