Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
de:examples:sensor:thermistor [2010/09/09 16:17] – angelegt Wemberde:examples:sensor:thermistor [2020/07/20 09:00] (current) – external edit 127.0.0.1
Line 1: Line 1:
 ====== Thermistor ====== ====== Thermistor ======
  
-//Necessary knowledge: [HW] [[en:hardware:homelab:sensor]], [HW] [[en:hardware:homelab:lcd]], [ELC] [[en:electronics:voltage_divider]], [AVR] [[en:avr:adc]], [LIB] [[en:software:homelab:library:adc]], [LIB] [[en:software:homelab:library:module:lcd_alphanumeric]], [LIB] [[en:software:homelab:library:module:sensor]]//+//Notwendiges Wissen: [HW] [[en:hardware:homelab:sensor]], [HW] [[en:hardware:homelab:lcd]], [ELC] [[en:electronics:voltage_divider]], [AVR] [[en:avr:adc]], [LIB] [[en:software:homelab:library:adc]], [LIB] [[en:software:homelab:library:module:lcd_alphanumeric]], [LIB] [[en:software:homelab:library:module:sensor]]//
  
 ===== Theorie ===== ===== Theorie =====
  
-[{{  :examples:sensor:thermistor:sensor_thermistor_ntc_picture.jpg?80|NTC thermistor}}]+[{{  :examples:sensor:thermistor:sensor_thermistor_ntc_picture.jpg?80|NTC Thermistor}}]
  
-Ein Thermistor ist ein Typ von Widerstand, dessen Widerstand sich mit der Temperatur verändert. Es gibt zwei Typen von Thermistoren: Welche mit positiven Temperaturkoeffizieten und welche mit negativen Temperaturkoeffizieten. Der Widerstand von Thermistoren mit positiven Koeffizienten steigt wenn die Temperatur steint und bei den Negativen steigt der Wiederstand wenn die Temperatur fällt. +Ein Thermistor ist temperaturabhängiger Widerstand. Es gibt Thermistoren mit positiven und mit negativen Temperaturkoeffizienten. Der Widerstand von Thermistoren mit positiven Koeffizienten nimmt mit steigender Temperatur zu, bei Thermistoren mit negativen Koeffizienten steigt er mit sinkender Temperatur. Die dazugehörigen Abkürzungen sind PTC(//positive temperature coefficient//) und NTC (//negative temperature coefficient//).
-Die dazugehörigen Abkürzungen sind PTC(//positive temperature coefficient//) und NTC (//negative temperature coefficient//). +
- +
- +
-The thermistors resistances' dependence of the temperature is not linear and this complicates the usage of it. For accurate temperature measurements in wider temperature flotation the Steinhart-Hart third-order exponential equation is used as the thermistors resistance is linear only in small temperature range. The following simplified Steinhart-Hart equation with B-parameter exists for NTC thermistors:+
  
 +Die Temperaturabhängigkeit des Widerstands verläuft nicht linear zu der Temperatur, was die Nutzung erschwert. Für genaue Temperaturmessungen bei größeren Temperaturschwankungen wird die exponentielle Steinhart-Hart Gleichung dritter Ordnung genutzt, da der Thermistorwiderstand nur innerhalb kleiner Temperaturbereiche linear ist. Für NTC Thermistoren gibts es folgende vereinfachte Steinhart-Hart-Gleichung mit dem Parameter B:
  
 {{:examples:sensor:thermistor:sensor_ntc_equation.png?130|The relation between temperature and resistance of a NTC thermistor.}} {{:examples:sensor:thermistor:sensor_ntc_equation.png?130|The relation between temperature and resistance of a NTC thermistor.}}
  
-where:\\ +mit:\\ 
-  * T<sub>0</sub> nominal temperatureusually 25 °C.\\ +  * T<sub>0</sub> nominale Temperaturnormalerweise 25 °C.\\ 
-  * R<sub>0</sub> resistance at nominal temperature.\\ +  * R<sub>0</sub> Widerstand bei nominaler Temperatur.\\ 
-  * B   parameter B.+  * B   Parameter B.
  
-Parameter B is a coefficientwhich is usually given in the datasheet of the thermistorBut it is stable enough constant only in a certain ranges of temperaturefor example at ranges 2550 °C or 2585 °C. If the temperature range measured is wider the data sheet should be used for retrieving the equation.+Der Parameter B ist ein Koeffizientwelcher normalerweise im Datenblatt des Thermistors vorgegeben istAber er ist nur in bestimmten Temperaturbereichen ausreichend konstantz.B. in Bereichen zwischen 25 und 50 °C oder zwischen 25 und 85 °C. Wenn der gemessene Temperaturbereich größer istsollte das Datenblatt des Thermistors zu Rate gezogen werden um die Gleichung zu erhalten.
  
-  +Normalerweise wird ein Spannungsteiler genutztum den Widerstand eines Thermistors zu messenDabei wird ein Widerstand durch einen Thermistor ausgetauscht wird und die Inputspannung ist konstant. Es wird die Outputspannung des Spannungsteilers gemessenwelche sich in Abhängigkeit der Widerstandsänderung des Thermistors verändertWenn Spannung anliegtfließt Strom durch den Thermistor, wodurch sich dieser bedingt durch den Thermistorwiderstand aufheizt und damit den Widerstand verändertDer durch das Aufheizen entstehende Fehler kann berechnet werden, jedoch ist es einfacher einen Thermistor zu nutzenwelcher einen hohen Widerstand hat und sich nicht so viel aufheizt.
-Usually a voltage-divider is used for measuring the resistance of a thermistorwhere one resistor is replaced with a thermistor and the input voltage is constantThe output voltage of the voltage-divider is measuredwhich changes according to the change of the resistance of the thermistorIf the voltage is appliedcurrent goes through the thermistor which heats up the thermistor due to thermistors resistance and therefore alters again the resistanceThe  fault caused by heating up of the thermistor can be compensated with calculationsbut it is easier to use a thermistor that has higher resistance and therefore heats up less.+
  
-With restricted resources and with less demands on accuracypreviously calculated charts and tables for temperatures are usedGenerally the tables have ranges of temperatures and respective values of resistancevoltage or analogue-digital convertersAll exponential calculations are already done and the user needs to only find the correct row and read the temperature given+Bei begrenzten Ressourcen und geringerem Anspruch auf Genauigkeitwerden zuvor errechnete Diagramme und Tabellen für die Temperaturen genutztNormalerweise enthalten die Tabellen Temperaturbereiche und die entsprechenden Werte für WiderstandSpannung und ADCAlle exponentiellen Berechnungen wurden bereits durchgeführt sodass der Nutzer nur noch die entsprechende Reihe finden und die Werte auslesen muss.
  
 +===== Übung =====
  
-===== Practice ===== +Das Sensormodul des HomeLab enthält einen NTC Thermistor mit nominellem Widerstand von 10 kΩ. Bei Temperaturen von 25 bis 50 °C ist der Parameter des Widerstands 3900.  
- +Ein Pin des Thermistors ist an die +5 V Betriebsspannung angeschlossen der andere an Kanal 2 (Pin PF2). Ein typischer 10 kΩ Widerstand ist auch am gleichen Pin des Mikrocontrollers und an die Masse angeschlossenSo entsteht zusammen mit dem Thermistor ein Spannungsteiler. Da hier ein NTC Thermistor genutzt wirdbei welchem der Widerstand sinkt wenn die Temperatur steigtwird die Outputspannung des Spannungsteilers bei steigender Temperatur höher.
-The Sensor module of the HomeLab is equipped with a NTC type thermistor which has 10 kΩ nominal resistanceAt temperatures 25-50 °C the parameter of the thermistor is 3900. One pin of the thermistor is connected to +5 V supply and the other one is connected to the channel 2 (pin number PF2) of the analogue-digital converterA typical 10 kΩ resistor is also connected with the same pin of the microcontroller and earth and together with the thermistor forms a voltage dividerSince we are dealing with a NTC thermistorwhich resistance decreases as the temperature grows; the output voltage of the voltage divider is increasing repectively with growing temperature. +
- +
-While using the AVR it is practical to use a conversion table of values of temperature and analogue-digital converter to find the correct temperature. It is wise to find corresponding value of analogue-digital converter for each temperature degree of desired range of temperature because reverse table will be too large due to the amount of 10 bit ADC values. It is recommended to use any kind of spreadsheet program (MS Excel, Openoffice Calc, etc.) to make the table. //Steinhart-Hart// formula which is customized for the mentioned NTC thermistors able's to find the resistance of the thermistor which corresponds to the temperature. Derived from the resistanceis possible to calculate the output voltage of the voltage divider and using this output voltage to calculate the value of the ADCCalculated values can be inserted to the program as follows:    +
  
 +Während der Nutzung des AVR ist es nützlich, eine Tabelle mit den Temperaturwerten und den Werten des ADC zu verwenden, um die korrekte Temperatur zu finden. Es ist sinnvoll, für jede Gradzahl der gewünschten Temperaturstufe des Messbereichs den korrespondierenden ADC Wert aus der Tabelle herauszusuchen, da die Tabelle aufgrund der 10 Bit ADC Werte sehr groß sein wird. Es wird empfohlen, ein Tabellenkalkulationsprogramm (MS Excel, Openoffice Calc, etc.) zur Erstellung der Tabelle zu nutzen. Die //Steinhart-Hart// Gleichung, welche für den NTC angepasst wurde, gibt den zur entsprechenden Temperatur korrespondierenden Widerstand aus. Abgeleitet aus dem Widerstand, ist es möglich die Outputspannung des Spannungsteilers zu berechnen und daraus den Wert des ADC. Berechnete Werte können wie folgt in das Programm eingefügt werden:
  
 <code c> <code c>
 // //
-// Table for converting temperature values to ADC values+// Tabelle zur Konvertierung von Temperaturwerten ind ADC Werte
-// Every element of the array marks one Celsius degree+// Jedes Element des Arrays kennzeichnet ein Grad Celsius. 
-// Elements begin from -20 degree and end at 100 degree+// Die Elemente beginnen bei -20 Grad und enden bei 100 Grad
-// There are 121 elements in the array.+// Ein Array enthält 121 Elemente.
 // //
 const signed short min_temp = -20; const signed short min_temp = -20;
Line 62: Line 57:
 </code> </code>
  
-Following algorithm may be used to find the temperature which corresponds to the parameters of the ADC:+Folgender Algorithmus kann genutzt werden um die mit den ADC Parametern korrespondierende Temperatur zu finden:
  
 <code c> <code c>
 // //
-// Converting the ADC values to Celsius degrees:+// Konvertierung der ACD Werte in Grad Celsius:
 // //
 signed short thermistor_calculate_celsius(unsigned short adc_value) signed short thermistor_calculate_celsius(unsigned short adc_value)
Line 72: Line 67:
  signed short celsius;  signed short celsius;
  
- // Covering the table backwards:+ // Tabelle von hinten beginnend durchgehen:
  for (celsius = max_temp - min_temp; celsius >= 0; celsius--)  for (celsius = max_temp - min_temp; celsius >= 0; celsius--)
  {  {
- // If the value in the table is the same or higher than measured  + // Ist der Wert aus der Tabelle gleich oder höher dem gemessenen  
- // valuethen the temperature is at least as high as the temperature + // Wertist die Temperatur mindestens so hoch wie die mit dem Element  
- // corresponding to the element.+ // korrespondierende Temperatur.
  if (adc_value >= conversion_table[celsius]))  if (adc_value >= conversion_table[celsius]))
  {  {
- // Since the table begins with but values of the elements from -20,        + // Da die Tabelle mit beginnt, die Werte der Elemente jedoch mit -20,        
- // the value must be shifted.+ // muss der Wert geshiftet werden.
  return celsius + min_temp;  return celsius + min_temp;
  }  }
  }  }
  
- // If the value was not found the minimal temperature is returned.+ // Wurde der Wert nicht gefunden, wird die minimale Temperaur ausgegeben.
  return min_temp;  return min_temp;
 } }
 </code> </code>
-The algorithm searches range from the table where the ADC value is and acquires the lower ranking number of this range. The ranking number marks degrees, adding the primary temperature to this a temperature with accuracy of 1 degree is reached. 
  
-This conversion table and function are already in the library of the HomeLab, therefore there is no need to write them for this exercise. In the library the conversion function is named //thermistor_calculate_celsius//Must be consideredthat the conversion is valid only when used on the thermistor on the Sensors module of the HomeLab. For using other thermistorsa conversion table needs to be created and more complex function described in the manual of the library must be usedExample program of this exercise is a thermometerwhich measures temperature in Celsius scale and displays it on an alphabetical LCD.  +Der Algorithmus sucht den Bereich aus der Tabelle in dem der ACD Wert liegt und wählt die niedrigere Nummer dieses Bereiches. Die Ranknummer markiert die Gradzahl und durch das Addieren der anfänglichen Temperatur wird eine Genauigkeit von 1°C erreicht. 
 + 
 +Umrechnungstabelle und Funktion sind schon in der HomeLab Bibliothek enthaltensie müssen somit nicht extra für diese Aufgabe erstellt werden. In der Bibliothek heißt die Umrechnungsfunktion //thermistor_calculate_celsius//Hierbei muss beachtet werdendass die Funktion nur korrekt ist, wenn sie mit dem Thermistor des Sensormoduls aus dem HomeLab verwendet wirdWerden andere Thermistoren genutztmuss eine entsprechende Umrechnungstabelle erstellt und eine komplexere Funktion verwendet werden, welche im Handbuch der Bibliothek beschrieben wirdDas Beispielprogramm dieser Übung ist ein Thermometerwelches Temperatur in °C mißt und sie auf dem alphabetischen LCD ausgibt.
    
  
 <code c> <code c>
 // //
-// Example program of the thermistor of Sensors module+// Beispielprogramm des Thermistors des Sensormoduls
-// The temperature is displayed on the LCD.+// Die Temperatur wird auf dem LCD angezeigt.
 // //
 #include <stdio.h> #include <stdio.h>
Line 106: Line 102:
  
 // //
-// Main program+// Hauptprogramm
 // //
 int main(void) int main(void)
Line 114: Line 110:
  char text[16];  char text[16];
    
- // Setting the LCD+ // Einrichten des LCD
  lcd_alpha_init(LCD_ALPHA_DISP_ON);  lcd_alpha_init(LCD_ALPHA_DISP_ON);
    
- // Cleaning the LCD+ // Löschen des LCD
  lcd_alpha_clear();  lcd_alpha_clear();
    
- // Name of the program+ // Name des Programms
  lcd_alpha_write_string("Termomeeter");  lcd_alpha_write_string("Termomeeter");
    
- // Setting the ADC+ // Einrichten des ADC
  adc_init(ADC_REF_AVCC, ADC_PRESCALE_8);  adc_init(ADC_REF_AVCC, ADC_PRESCALE_8);
    
- // Endless loop+ // Endlosschleife
  while (true)  while (true)
  {  {
- // Reading the times rounded values of the voltage of the thermistor+ // Auslesen der 4-fach gerundeten Spannungswerte aus dem Thermistor
  value = adc_get_average_value(2, 4);  value = adc_get_average_value(2, 4);
  
- // Converting the values of ADC into celsius scale+ // Konvertieren der ADC Werte in Grad Celsius
  temperature = thermistor_calculate_celsius(value);  temperature = thermistor_calculate_celsius(value);
  
- // Converting the temperature in to text.+ // Konvertieren der Temperatur in Text.
  // To display the degree sign, the octal variable is 337.  // To display the degree sign, the octal variable is 337.
  sprintf(text, "%d\337C   ", temperature);  sprintf(text, "%d\337C   ", temperature);
  
- // Displaying the text in the beginning of the second row of the LCD.+ // Anzeige des Textes am Anfang der zweiten Zeile des LCDs.
  lcd_alpha_goto_xy(0, 1);  lcd_alpha_goto_xy(0, 1);
  lcd_alpha_write_string(text);  lcd_alpha_write_string(text);
Line 148: Line 144:
 ===== Extra ===== ===== Extra =====
  
-  * {{:examples:sensor:thermistor:ntc.xls|The diagram of temperature of a 10 kΩ NTC thermistor}}+  * {{:examples:sensor:thermistor:ntc.xls|Das Temperaturdiagramm eines 10 kΩ NTC Thermistors}}
  
de/examples/sensor/thermistor.1284049050.txt.gz · Last modified: 2020/07/20 09:00 (external edit)
CC Attribution-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0