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

Last change on this file since 26 was 26, checked in by f.jahn, 7 weeks ago
  • Bug in ADC Kalibrierung (STM32 ADC Strom) behoben
  • DMA Buffer für ADC 1 und ADC wird vor Überschreibung während bearbeitung geschützt, indem Datenübertragung nur einmalig erfolgt und erst nach Auswertung wieder gestartet wird
  • RS485Modbus: Timeout Zeit wird für Baudraten >19200 korrekt berechnet
  • Hardware ID geändert
  • Separates Register für "Batterie Empty detection mode" auf Adresse 92 angelegt
File size: 2.5 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
21
22
23//      --- LOKALE TYPE DEFS - bitte hier dokumentieren-------------------------------
24
25//      --- DEFINITIONEN GLOBALER VARIABLEN - Bitte in Header dokumentieren ----------
26
27//      --- LOKALE VARIABLEN - bitte hier dokumentieren ------------------------------
28
29//      --- LOKALE FUNKTIONS PROTOTYPEN ----------------------------------------------
30
31//      --- LOKALE FUNKTIONEN - bitte hier dokumentieren -----------------------------
32
33//      --- GLOBALE FUNKTIONEN - bitte in Header dokumentieren------------------------
34void CurrentOffsetCal(uint32_t newVal)
35{
36  sys_data.s.parameter.batteryCurrentOffsetFast = newVal-FAST_CURRENT_ADC_OFFSET;
37}
38
39void CurrentGainCal(uint32_t newVal)
40{
41  double correction;
42  double valWithoutGainCorrection;
43
44  valWithoutGainCorrection = ((int32_t) newVal - FAST_CURRENT_ADC_OFFSET - sys_data.s.parameter.batteryCurrentOffsetFast) * VREF ;
45  valWithoutGainCorrection = valWithoutGainCorrection / FAST_CURRENT_ADC_RESOLUTION;
46  valWithoutGainCorrection = valWithoutGainCorrection / FAST_CURRENT_I_SENSE_GAIN ;
47  valWithoutGainCorrection = valWithoutGainCorrection / FAST_CURRENT_SHUNT_RESISTOR ;
48
49  correction = (double)  sys_data.s.parameter.batteryCurrentGainRefCurrent / valWithoutGainCorrection;
50  sys_data.s.parameter.batteryCurrentGainCorrectionFaktorFast = correction * 1000000;
51
52}
53void FAST_CURRENT_Exec(uint32_t newVal )
54{
55 
56  //Umrechung auf Strom
57  double temp_current;
58  temp_current = ((int32_t) newVal - FAST_CURRENT_ADC_OFFSET - sys_data.s.parameter.batteryCurrentOffsetFast) * VREF ;
59  temp_current = temp_current / FAST_CURRENT_ADC_RESOLUTION;
60  temp_current = temp_current / FAST_CURRENT_I_SENSE_GAIN ;
61  temp_current = temp_current / FAST_CURRENT_SHUNT_RESISTOR ;
62  sys_data.s.values.fast_current = temp_current * (sys_data.s.parameter.batteryCurrentGainCorrectionFaktorFast / 1000000.0);
63 
64}
65
66/*************************** End of file ****************************/
Note: See TracBrowser for help on using the repository browser.