source: trunk/fw_g473rct/SES/src/fast_current.c @ 24

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

Shunt Temperatursensor aktiviert

File size: 2.0 KB
Line 
1/******************************************************************************
2*
3* @file    fast_current.c
4* @author  ECS, Falko Jahn
5* @version V1.0.0
6* @date    2022-01-16
7* @brief       
8*
9******************************************************************************/
10
11//      --- INCLUDES -----------------------------------------------------------------
12#include "fast_current.h"
13#include "main.h"
14#include "sysdata.h"
15
16//      --- EXTERNE VARIABLEN --------------------------------------------------------
17
18//      --- LOKALE DEFINES - bitte hier dokumentieren --------------------------------
19
20#define I_SENSE_GAIN    40.0
21#define ADC_OFFSET                                                        32768
22#define ADC_RESOLUTION                                            32768 //65536/2 da im differential mode
23
24
25  #if (DEVICETYPE == 500)
26    #define SHUNT_RESISTOR      0.000125       
27  #elif (DEVICETYPE == 250)
28    #define SHUNT_RESISTOR      0.000250       
29  #elif (DEVICETYPE == 125)
30    #define SHUNT_RESISTOR      0.000500       
31  #else
32  #error No valid device type
33  #endif
34               
35
36
37
38
39//      --- LOKALE TYPE DEFS - bitte hier dokumentieren-------------------------------
40
41//      --- DEFINITIONEN GLOBALER VARIABLEN - Bitte in Header dokumentieren ----------
42
43//      --- LOKALE VARIABLEN - bitte hier dokumentieren ------------------------------
44
45//      --- LOKALE FUNKTIONS PROTOTYPEN ----------------------------------------------
46
47//      --- LOKALE FUNKTIONEN - bitte hier dokumentieren -----------------------------
48
49//      --- GLOBALE FUNKTIONEN - bitte in Header dokumentieren------------------------
50
51
52void FAST_CURRENT_Exec(uint32_t newVal )
53{
54 
55  //Umrechung auf Strom
56  double temp_current;
57  temp_current = ((int32_t) newVal - ADC_OFFSET) * VREF ;
58  temp_current = temp_current / ADC_RESOLUTION;
59  temp_current = temp_current / I_SENSE_GAIN ;
60  temp_current = temp_current / SHUNT_RESISTOR ;
61  sys_data.s.values.fast_current = temp_current * (sys_data.s.parameter.batteryCurrentGainCorrectionFaktor / 1000000.0);
62 
63}
64
65/*************************** End of file ****************************/
Note: See TracBrowser for help on using the repository browser.