ESD electrostatic protection diode silk print query, SOD-323 packaging model

2023-03-16  

App_Temp.c

#include "App_Temp.h"

/// <NTC discrete data table -20 to 100, totaling 121 numbers
const uint32_t TempNtc_Tab[TempSize] = 
{
    
3817,3804,3790,3776,3761,3746,3730,3714,3698,3680,	//-20 ... -11
3663,3644,3626,3606,3586,3566,3545,3523,3501,3478,	//-10 ...  -1
3455,3431,3407,3382,3356,3330,3304,3277,3249,3221,	//  0 ...   9
3192,3163,3134,3104,3073,3042,3011,2979,2947,2914,	// 10 ...  19
2881,2848,2815,2781,2747,2713,2678,2643,2608,2573,	// 20 ...  29
2538,2503,2467,2432,2397,2361,2325,2290,2255,2219,	// 30 ...  39
2184,2149,2114,2079,2044,2010,1975,1941,1907,1874,	// 40 ...  49
1840,1807,1774,1742,1710,1678,1647,1615,1585,1554,	// 50 ...  59
1524,1495,1466,1437,1409,1381,1353,1326,1299,1273,	// 60 ...  69
1247,1222,1197,1172,1148,1124,1101,1078,1055,1033,	// 70 ...  79
1012, 990, 969, 949, 929, 909, 890, 871, 853, 835,	// 80 ...  89
 817, 799, 782, 766, 749, 734, 718, 703, 688, 673,	// 90 ...  99
 659												// 100... 
}; 

uint8_t func_get_ntc_temp(uint32_t value_adc, int16_t* value_temp)
{
    
	uint8_t index_l, index_r;
	uint8_t r10k_tab_size = TempSize;
	int32_t temp = 0;
	if(value_adc <= SHORT_CIRCUIT_THRESHOLD)
	{
    
		*value_temp = -9;
		return 1;
	}
	else if(value_adc >= OPEN_CIRCUIT_THRESHOLD)
	{
    
		*value_temp = -7;
		return 2;
	}
	else if(value_adc > TempNtc_Tab[0])
	{
    
		*value_temp = -9;
		return 3;
	}
	else if(value_adc < TempNtc_Tab[r10k_tab_size - 1])
	{
    
		*value_temp = -9;
		return 4;
	}
	index_l = 0;
	index_r = r10k_tab_size - 1;
	for(;index_r - index_l > 1;)
	{
    
		if((value_adc <= TempNtc_Tab[index_l]) && (value_adc > TempNtc_Tab[(index_r + index_l)%2 == 0 ? (index_r + index_l)/2 : (index_r + index_l)/2 + 1]))
		{
    
			index_r = (index_r + index_l) % 2 == 0 ? (index_r + index_l)/2 : (index_r + index_l)/2 + 1;
		}
		else
		{
    
			index_l = (index_r + index_l)/2;
		}
	}
	if(TempNtc_Tab[index_l] == value_adc)
	{
    
		temp = (((int16_t)index_l) - 20);//rate *10
	}
	else if(TempNtc_Tab[index_r] == value_adc)
	{
    
		temp = (((int16_t)index_r) - 20);//rate *10
	}
	else
	{
    
		if(TempNtc_Tab[index_l] - TempNtc_Tab[index_r] == 0)
		{
    
			temp = (((int16_t)index_l) - 20);//rate *10
		}
		else
		{
    
			temp = (((int16_t)index_l) - 20);// + ((TempNtc_Tab[index_l] - value_adc)*100 + 5)/10/(TempNtc_Tab[index_l] - TempNtc_Tab[index_r]);
		}		
	}
	if(temp>=99)
		temp = 99;
	if(temp<=-9)
		temp = -9;
	*value_temp = temp;
	return 0;
}

App_Temp.h

#ifndef	__APP_TEMP_H
#define	__APP_TEMP_H	


#include "stdint.h"

#define TempSize  121 // Define table length

#define SHORT_CIRCUIT_THRESHOLD 15
#define OPEN_CIRCUIT_THRESHOLD 4030

uint8_t func_get_ntc_temp(uint32_t value_adc, int16_t* value_temp);

//uint8_t FineTab(uint8_t TabLong,uint16_t data);
//uint8_t FineTab_t(uint8_t TabLong,uint16_t dat);

#endif

source

Related Posts

1 1 1 1 1 1 1 1 1 1 overall review

Extract HTML Title, Description, Keywords (Chilkat/Python 2) xiaoqiang

Black Horse Programmer -Foundation framework NSFileManager introduction and usage

httpcomponents 4.5.2 Simple use

ESD electrostatic protection diode silk print query, SOD-323 packaging model

Random Posts

China Adult Blood Liposuction Guide (2016 revised edition) -The learning notes

Caddy & GRPC (3) Add a reverse proxy plug -in to Caddy

Sixteen Week OJ Project D: Poinage leading odd number factor

LOGSTASH-Input-JDBC ORALCE plug-in configuration, version logstash-6.2.4

MySQL8.0.26 Installation Tutorial (Super Simple)