foxBMS  1.3.0
The foxBMS Battery Management System API Documentation
bender_ir155_helper.h
Go to the documentation of this file.
1 /**
2  *
3  * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V.
4  * All rights reserved.
5  *
6  * SPDX-License-Identifier: BSD-3-Clause
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions are met:
10  *
11  * 1. Redistributions of source code must retain the above copyright notice, this
12  * list of conditions and the following disclaimer.
13  *
14  * 2. Redistributions in binary form must reproduce the above copyright notice,
15  * this list of conditions and the following disclaimer in the documentation
16  * and/or other materials provided with the distribution.
17  *
18  * 3. Neither the name of the copyright holder nor the names of its
19  * contributors may be used to endorse or promote products derived from
20  * this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
26  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  *
33  * We kindly request you to use one or more of the following phrases to refer to
34  * foxBMS in your hardware, software, documentation or advertising materials:
35  *
36  * - ″This product uses parts of foxBMS®″
37  * - ″This product includes parts of foxBMS®″
38  * - ″This product is derived from foxBMS®″
39  *
40  */
41 
42 /**
43  * @file bender_ir155_helper.h
44  * @author foxBMS Team
45  * @date 2021-09-17 (date of creation)
46  * @updated 2022-05-30 (date of last update)
47  * @version v1.3.0
48  * @ingroup DRIVERS
49  * @prefix IR155
50  *
51  * @brief Headers for the configuration for the insulation monitoring
52  *
53  *
54  */
55 
56 #ifndef FOXBMS__BENDER_IR155_HELPER_H_
57 #define FOXBMS__BENDER_IR155_HELPER_H_
58 
59 /*========== Includes =======================================================*/
60 #include "general.h"
61 
62 /* clang-format off */
63 #include "imd.h"
64 /* clang-format on */
65 
66 #include "io.h"
67 #include "pwm.h"
68 
69 /*========== Macros and Definitions =========================================*/
70 
71 /* Read pin state of digital status pin (OKHS) */
72 #define IR155_GET_DIGITAL_STATUS_PIN_STATE() \
73  IO_PinGet(&IR155_DIGITAL_STATUS_INPUT_PORT->DIN, IR155_DIGITAL_STATUS_INPUT_PIN)
74 
75 /**
76  * symbolic names for the different measurement modes of Bender Isometer.
77  * Defined through the frequency of the measurement signal.
78  */
79 typedef enum IR155_MEASUREMENT_MODE {
80  IR155_NORMAL_MODE, /*!< PWM frequency: 10Hz */
81  IR155_SPEEDSTART_MODE, /*!< PWM frequency: 30Hz */
82  IR155_UNDERVOLTAGE_MODE, /*!< PWM frequency: 20Hz */
83  IR155_IMD_ERROR_MODE, /*!< PWM frequency: 40Hz */
84  IR155_GROUNDERROR_MODE, /*!< PWM frequency: 50Hz */
85  IR155_SHORT_CLAMP, /*!< PWM frequency: 0Hz */
86  IR155_UNDEFINED_FREQUENCY, /*!< illegal frequency detected*/
87  IR155_DUTY_CYCLE_MEASUREMENT, /*!< corrupt signal measurement (e.g. T_on > T_periode,)*/
88  IR155_NOSIGNAL, /*!< no signal (e.g. if 100% -> wire break, if 0% -> shortcut to GND */
91 
92 /**
93  * symbolic names for the different operating states Bender Isometer.
94  * Defined through the duty cycle of the measurement signal.
95  */
97  IR155_RESISTANCE_MEASUREMENT, /*!< valid normal measurement working */
98  IR155_RESISTANCE_MEASUREMENT_UNKNOWN, /*!< normal measurement with undefined duty cycle */
99  IR155_RESISTANCE_ESTIMATION, /*!< SPEEDSTART estimation working */
100  IR155_RESISTANCE_ESTIMATION_UNKNOWN, /*!< SPEEDSTART estimation with undefined duty cycle */
101  IR155_UNDERVOLTAGE_MEASUREMENT, /*!< SPEEDSTART estimation working */
102  IR155_UNDERVOLTAGE_MEASUREMENT_UNKNOWN, /*!< SPEEDSTART estimation with undefined duty cycle */
103  IR155_GROUND_ERROR_MODE, /*!< ground error detected */
104  IR155_GROUND_ERROR_MODE_UNKNOWN, /*!< ground error detected with undefined duty cycle */
105  IR155_IMD_ERROR_MEASUREMENT, /*!< device error detected */
106  IR155_IMD_ERROR_MEASUREMENT_UNKNOWN, /*!< device error detected with unkown duty cycle*/
107  IR155_SIGNAL_SHORT, /*!< signal short detected */
108  IR155_MEASUREMENT_NOT_VALID, /*!< Invalid measurement detected */
109  IR155_UNINITIALIZED, /*!< Uninitialized state */
111 
112 /** type definition for structure of insulation measurement */
113 typedef struct {
114  bool isMeasurementValid; /*!< flag if measurement value is valid or not */
115  bool isUndervoltageDetected; /*!< flag if undervoltage has been detected */
116  PWM_SIGNAL_s pwmSignal; /*!< duty cycle and frequency of measured pwm signal */
117  uint32_t resistance_kOhm; /*!< measured insulation resistance in kOhm */
118  STD_PIN_STATE_e digitalStatusPin; /*!< pin state of Status output (OK_HS) */
119  IR155_MEASUREMENT_MODE_e measurementMode; /*!< IR155 measurement mode */
120  IR155_MEASUREMENT_STATE_e measurementState; /*!< IR155 measurement state */
122 
123 /** IR155 state struct */
124 typedef struct {
125  bool ir155Initialized; /*!< flag if IR155 module is initialied */
126  IR155_MEASUREMENT_s measurement; /*!< latest measurement */
127  uint32_t timeUntilValidMeasurement_ms; /*!< time until valid measurement result is valid */
128  uint16_t periodTriggerTime_ms; /*!< periodic call time of IR155 module */
129 } IR155_STATE_s;
130 
131 /*========== Extern Constant and Variable Declarations ======================*/
133 
134 /*========== Extern Function Prototypes =====================================*/
135 /**
136  * @brief Software initialization of Timer-module
137  * @param triggerTime_ms cyclic call time of IR155_GetMeasurementValues function
138  */
139 extern void IR155_Initialize(uint8_t triggerTime_ms);
140 
141 /**
142  * @brief Software deinitialization of Timer-module
143  */
144 extern void IR155_Deinitialize(void);
145 
146 /**
147  * @brief Interface function which delivers the actual signal measurement (duty cyle) and evaluation.
148  * Use of intervals because of measuring and signal inaccuracy. The evaluated results are
149  * finally written in the database.
150  * @return #IR155_MEASUREMENT_s measurement result of IR155 measurement
151  */
153 
154 /*========== Externalized Static Functions Prototypes (Unit Test) ===========*/
155 
156 #endif /* FOXBMS__BENDER_IR155_HELPER_H_ */
IR155_MEASUREMENT_MODE
@ IR155_NOSIGNAL
@ IR155_NORMAL_MODE
@ IR155_UNDEFINED_FREQUENCY
@ IR155_SPEEDSTART_MODE
@ IR155_SHORT_CLAMP
@ IR155_IMD_ERROR_MODE
@ IR155_UNKNOWN
@ IR155_UNDERVOLTAGE_MODE
@ IR155_DUTY_CYCLE_MEASUREMENT
@ IR155_GROUNDERROR_MODE
enum IR155_MEASUREMENT_STATE IR155_MEASUREMENT_STATE_e
void IR155_Initialize(uint8_t triggerTime_ms)
Software initialization of Timer-module.
IR155_MEASUREMENT_STATE
@ IR155_SIGNAL_SHORT
@ IR155_GROUND_ERROR_MODE_UNKNOWN
@ IR155_UNINITIALIZED
@ IR155_IMD_ERROR_MEASUREMENT_UNKNOWN
@ IR155_UNDERVOLTAGE_MEASUREMENT_UNKNOWN
@ IR155_IMD_ERROR_MEASUREMENT
@ IR155_RESISTANCE_MEASUREMENT
@ IR155_RESISTANCE_ESTIMATION_UNKNOWN
@ IR155_RESISTANCE_ESTIMATION
@ IR155_MEASUREMENT_NOT_VALID
@ IR155_RESISTANCE_MEASUREMENT_UNKNOWN
@ IR155_UNDERVOLTAGE_MEASUREMENT
@ IR155_GROUND_ERROR_MODE
void IR155_Deinitialize(void)
Software deinitialization of Timer-module.
enum IR155_MEASUREMENT_MODE IR155_MEASUREMENT_MODE_e
IR155_MEASUREMENT_s IR155_GetMeasurementValues(void)
Interface function which delivers the actual signal measurement (duty cyle) and evaluation....
IR155_STATE_s ir155_state
STD_PIN_STATE_e
Definition: fstd_types.h:87
General macros and definitions for the whole platform.
API header for the insulation monitoring device.
Header for the driver for the IO module.
PWM driver for the TMS570LC43xx.
IR155_MEASUREMENT_MODE_e measurementMode
STD_PIN_STATE_e digitalStatusPin
IR155_MEASUREMENT_STATE_e measurementState
uint16_t periodTriggerTime_ms
IR155_MEASUREMENT_s measurement
uint32_t timeUntilValidMeasurement_ms