foxBMS - Unit Tests  1.5.0
The foxBMS Unit Tests API Documentation
bender_ir155_helper.h
Go to the documentation of this file.
1 /**
2  *
3  * @copyright © 2010 - 2023, 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 2023-02-03 (date of last update)
47  * @version v1.5.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 
61 /* clang-format off */
62 #include "imd.h"
63 /* clang-format on */
64 
65 #include "io.h"
66 #include "pwm.h"
67 
68 #include <stdint.h>
69 
70 /*========== Macros and Definitions =========================================*/
71 
72 /* Read pin state of digital status pin (OKHS) */
73 #define IR155_GET_DIGITAL_STATUS_PIN_STATE() \
74  IO_PinGet(&IR155_DIGITAL_STATUS_INPUT_PORT->DIN, IR155_DIGITAL_STATUS_INPUT_PIN)
75 
76 /**
77  * symbolic names for the different measurement modes of Bender Isometer.
78  * Defined through the frequency of the measurement signal.
79  */
80 typedef enum IR155_MEASUREMENT_MODE {
81  IR155_NORMAL_MODE, /*!< PWM frequency: 10Hz */
82  IR155_SPEEDSTART_MODE, /*!< PWM frequency: 30Hz */
83  IR155_UNDERVOLTAGE_MODE, /*!< PWM frequency: 20Hz */
84  IR155_IMD_ERROR_MODE, /*!< PWM frequency: 40Hz */
85  IR155_GROUNDERROR_MODE, /*!< PWM frequency: 50Hz */
86  IR155_SHORT_CLAMP, /*!< PWM frequency: 0Hz */
87  IR155_UNDEFINED_FREQUENCY, /*!< illegal frequency detected*/
88  IR155_DUTY_CYCLE_MEASUREMENT, /*!< corrupt signal measurement (e.g. T_on > T_periode,)*/
89  IR155_NOSIGNAL, /*!< no signal (e.g. if 100% -> wire break, if 0% -> shortcut to GND */
92 
93 /**
94  * symbolic names for the different operating states Bender Isometer.
95  * Defined through the duty cycle of the measurement signal.
96  */
98  IR155_RESISTANCE_MEASUREMENT, /*!< valid normal measurement working */
99  IR155_RESISTANCE_MEASUREMENT_UNKNOWN, /*!< normal measurement with undefined duty cycle */
100  IR155_RESISTANCE_ESTIMATION, /*!< SPEEDSTART estimation working */
101  IR155_RESISTANCE_ESTIMATION_UNKNOWN, /*!< SPEEDSTART estimation with undefined duty cycle */
102  IR155_UNDERVOLTAGE_MEASUREMENT, /*!< SPEEDSTART estimation working */
103  IR155_UNDERVOLTAGE_MEASUREMENT_UNKNOWN, /*!< SPEEDSTART estimation with undefined duty cycle */
104  IR155_GROUND_ERROR_MODE, /*!< ground error detected */
105  IR155_GROUND_ERROR_MODE_UNKNOWN, /*!< ground error detected with undefined duty cycle */
106  IR155_IMD_ERROR_MEASUREMENT, /*!< device error detected */
107  IR155_IMD_ERROR_MEASUREMENT_UNKNOWN, /*!< device error detected with unkown duty cycle*/
108  IR155_SIGNAL_SHORT, /*!< signal short detected */
109  IR155_MEASUREMENT_NOT_VALID, /*!< Invalid measurement detected */
110  IR155_UNINITIALIZED, /*!< Uninitialized state */
112 
113 /** type definition for structure of insulation measurement */
114 typedef struct {
115  bool isMeasurementValid; /*!< flag if measurement value is valid or not */
116  bool isUndervoltageDetected; /*!< flag if undervoltage has been detected */
117  PWM_SIGNAL_s pwmSignal; /*!< duty cycle and frequency of measured pwm signal */
118  uint32_t resistance_kOhm; /*!< measured insulation resistance in kOhm */
119  STD_PIN_STATE_e digitalStatusPin; /*!< pin state of Status output (OK_HS) */
120  IR155_MEASUREMENT_MODE_e measurementMode; /*!< IR155 measurement mode */
121  IR155_MEASUREMENT_STATE_e measurementState; /*!< IR155 measurement state */
123 
124 /** IR155 state struct */
125 typedef struct {
126  bool ir155Initialized; /*!< flag if IR155 module is initialied */
127  IR155_MEASUREMENT_s measurement; /*!< latest measurement */
128  uint32_t timeUntilValidMeasurement_ms; /*!< time until valid measurement result is valid */
129  uint16_t periodTriggerTime_ms; /*!< periodic call time of IR155 module */
130 } IR155_STATE_s;
131 
132 /*========== Extern Constant and Variable Declarations ======================*/
134 
135 /*========== Extern Function Prototypes =====================================*/
136 /**
137  * @brief Software initialization of Timer-module
138  * @param triggerTime_ms cyclic call time of IR155_GetMeasurementValues function
139  */
140 extern void IR155_Initialize(uint8_t triggerTime_ms);
141 
142 /**
143  * @brief Software deinitialization of Timer-module
144  */
145 extern void IR155_Deinitialize(void);
146 
147 /**
148  * @brief Interface function which delivers the actual signal measurement (duty cyle) and evaluation.
149  * Use of intervals because of measuring and signal inaccuracy. The evaluated results are
150  * finally written in the database.
151  * @return #IR155_MEASUREMENT_s measurement result of IR155 measurement
152  */
154 
155 /*========== Externalized Static Functions Prototypes (Unit Test) ===========*/
156 #ifdef UNITY_UNIT_TEST
157 #endif
158 
159 #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:88
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