source: trunk/firmware_v2/SES/src/chip_temperature.c @ 23

Last change on this file since 23 was 23, checked in by f.jahn, 6 days ago

Änderung neuer Controller mit mehr Speicher

File size: 2.5 KB
Line 
1/******************************************************************************
2*
3* @file    chipTemperature.c
4* @author  ECS, Joseph Zimmer
5* @version V1.0.0
6* @date    24-04-2019
7* @brief
8*
9******************************************************************************/
10
11//      --- INCLUDES -----------------------------------------------------------------
12#include <stdio.h>
13//#include <stdlib.h>
14#include "chip_temperature.h"
15
16//      --- EXTERNE VARIABLEN --------------------------------------------------------
17
18//      --- LOKALE DEFINES - bitte hier dokumentieren --------------------------------
19
20//      --- LOKALE TYPE DEFS - bitte hier dokumentieren-------------------------------
21
22//      --- DEFINITIONEN GLOBALER VARIABLEN - Bitte in Header dokumentieren ----------
23
24//      --- LOKALE VARIABLEN - bitte hier dokumentieren ------------------------------
25uint32_t calTemperatureSensor30Value;  // Kalibrierungswert für den Temperatursensor auf dem STM32G0 (Werksmäßig im SCB Bereich gespeichert wird beim Programmstart ausgelesen)
26                                                 // Daten Temperaturanzeige µProzessor
27
28//      --- LOKALE FUNKTIONS PROTOTYPEN ----------------------------------------------
29
30void calc_temp_compensation(void);
31
32
33//      --- LOKALE FUNKTIONEN - bitte hier dokumentieren -----------------------------
34
35/*
36* @brief
37* @param        kein
38* @retval       kein
39*/
40
41//      --- GLOBALE FUNKTIONEN - bitte in Header dokumentieren------------------------
42void CHIP_TEMPERATURE_Calibration(void)
43{
44  uint16_t * pCalibrationData;
45  float calibrationData30;
46  float calibrationData130;
47
48  // lade Temperatur Kalibrierungswert (Wert bei 30°C)
49  pCalibrationData = (uint16_t *)TEMPSENSOR_CAL1_ADDR;
50  calibrationData30  = * pCalibrationData;
51
52  //Berechnung Spannung in mV bei CAL Punk 30°C
53  //Kalbibrierung wurde mit 12 Bit und 3000mV Vref durchgeführt
54  calibrationData30 = calibrationData30 / 4096;
55  calTemperatureSensor30Value = calibrationData30 * 3000 ;      // jetzt haben wir die Kalibrierungsspannung in mVolt bei 30°C;
56}
57
58int CHIP_TEMPERATURE_Exec(uint32_t chiptemperature)
59{
60    int32_t temp;
61    //Aktuelle Spannung am Temp Sensor
62    temp = (3300 * (uint32_t)chiptemperature) / 65536;
63
64
65    temp = temp - (calTemperatureSensor30Value);
66
67    temp = temp / 2.530; //2,53mV/°C
68    temp = temp + 25; //30000 da Erste Kalibrierpunkt bei 25°C --> 25
69        return temp;
70    //Durch 10 teilen, damit es in 16 Bit signed modbus register passt
71}
72
73//------------------------------------------------------------------------------
74
75
76
Note: See TracBrowser for help on using the repository browser.