foxBMS - Unit Tests  1.3.0
The foxBMS Unit Tests API Documentation
bender_ir155_helper.c File Reference

Driver for the insulation monitoring. More...

#include "bender_ir155_helper.h"
#include "bender_ir155_cfg.h"
#include "fram.h"
Include dependency graph for bender_ir155_helper.c:

Go to the source code of this file.

Macros

#define IR155_MAXIMUM_INSULATION_RESISTANCE_kOhm   (106800u)
 
#define IR155_MINIMUM_INSULATION_RESISTANCE_kOhm   (0u)
 
#define IR155_NORMAL_MODE_LOWER_DUTY_CYCLE_LIMIT_perc   (4.0f)
 
#define IR155_NORMAL_MODE_UPPER_DUTY_CYCLE_LIMIT_perc   (96.0f)
 
#define IR155_SPEED_START_ESTIMATION_GOOD_LOWER_DUTY_CYCLE_LIMIT_perc   (4.0f)
 
#define IR155_SPEED_START_ESTIMATION_GOOD_UPPER_DUTY_CYCLE_LIMIT_perc   (11.0f)
 
#define IR155_SPEED_START_ESTIMATION_BAD_LOWER_DUTY_CYCLE_LIMIT_perc   (89.0f)
 
#define IR155_SPEED_START_ESTIMATION_BAD_UPPER_DUTY_CYCLE_LIMIT_perc   (96.0f)
 
#define IR155_UNDERVOLTAGE_MODE_LOWER_DUTY_CYCLE_LIMIT_perc   (4.0f)
 
#define IR155_UNDERVOLTAGE_MODE_UPPER_DUTY_CYCLE_LIMIT_perc   (96.0f)
 
#define IR155_DEVICE_ERROR_LOWER_DUTY_CYCLE_LIMIT_perc   (46.5f)
 
#define IR155_DEVICE_ERROR_UPPER_DUTY_CYCLE_LIMIT_perc   (53.5f)
 
#define IR155_GROUND_ERROR_LOWER_DUTY_CYCLE_LIMIT_perc   (46.5f)
 
#define IR155_GROUND_ERROR_UPPER_DUTY_CYCLE_LIMIT_perc   (53.5f)
 

Functions

static IR155_MEASUREMENT_MODE_e IR155_GetMeasurementMode (float frequency_Hz)
 Determines frequency-dependent measurement state. More...
 
static uint32_t IR155_CalculateResistance (float dutyCycle_perc)
 Calculate insulation resistance from measured dutycycle. More...
 
static bool IR155_IsDutyCycleWithinInterval (float dutyCycle_perc, float lowerLimit_perc, float upperLimit_perc)
 Check if passed duty cycle is within interval limits. More...
 
void IR155_Initialize (uint8_t triggerTime_ms)
 Software initialization of Timer-module. More...
 
void IR155_Deinitialize (void)
 Software deinitialization of Timer-module. More...
 
IR155_MEASUREMENT_s IR155_GetMeasurementValues (void)
 Interface function which delivers the actual signal measurement (duty cyle) and evaluation. Use of intervals because of measuring and signal inaccuracy. The evaluated results are finally written in the database. More...
 

Variables

IR155_STATE_s ir155_state
 

Detailed Description

Driver for the insulation monitoring.

SPDX-License-Identifier: BSD-3-Clause

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

We kindly request you to use one or more of the following phrases to refer to foxBMS in your hardware, software, documentation or advertising materials:

  • ″This product uses parts of foxBMS®″
  • ″This product includes parts of foxBMS®″
  • ″This product is derived from foxBMS®″
Author
foxBMS Team
Date
2021-09-17 (date of creation)
Updated
2022-05-30 (date of last update)
Version
v1.3.0
Prefix
IR155

Definition in file bender_ir155_helper.c.

Macro Definition Documentation

◆ IR155_DEVICE_ERROR_LOWER_DUTY_CYCLE_LIMIT_perc

#define IR155_DEVICE_ERROR_LOWER_DUTY_CYCLE_LIMIT_perc   (46.5f)

Definition at line 84 of file bender_ir155_helper.c.

◆ IR155_DEVICE_ERROR_UPPER_DUTY_CYCLE_LIMIT_perc

#define IR155_DEVICE_ERROR_UPPER_DUTY_CYCLE_LIMIT_perc   (53.5f)

Definition at line 85 of file bender_ir155_helper.c.

◆ IR155_GROUND_ERROR_LOWER_DUTY_CYCLE_LIMIT_perc

#define IR155_GROUND_ERROR_LOWER_DUTY_CYCLE_LIMIT_perc   (46.5f)

Definition at line 88 of file bender_ir155_helper.c.

◆ IR155_GROUND_ERROR_UPPER_DUTY_CYCLE_LIMIT_perc

#define IR155_GROUND_ERROR_UPPER_DUTY_CYCLE_LIMIT_perc   (53.5f)

Definition at line 89 of file bender_ir155_helper.c.

◆ IR155_MAXIMUM_INSULATION_RESISTANCE_kOhm

#define IR155_MAXIMUM_INSULATION_RESISTANCE_kOhm   (106800u)

Maximum measurable resistance according to formula: ((90 * 1200kOhm) / (dc - 5) ) - 1200kOhm with dc ]5%,95%[

Definition at line 65 of file bender_ir155_helper.c.

◆ IR155_MINIMUM_INSULATION_RESISTANCE_kOhm

#define IR155_MINIMUM_INSULATION_RESISTANCE_kOhm   (0u)

Definition at line 66 of file bender_ir155_helper.c.

◆ IR155_NORMAL_MODE_LOWER_DUTY_CYCLE_LIMIT_perc

#define IR155_NORMAL_MODE_LOWER_DUTY_CYCLE_LIMIT_perc   (4.0f)

Definition at line 69 of file bender_ir155_helper.c.

◆ IR155_NORMAL_MODE_UPPER_DUTY_CYCLE_LIMIT_perc

#define IR155_NORMAL_MODE_UPPER_DUTY_CYCLE_LIMIT_perc   (96.0f)

Definition at line 70 of file bender_ir155_helper.c.

◆ IR155_SPEED_START_ESTIMATION_BAD_LOWER_DUTY_CYCLE_LIMIT_perc

#define IR155_SPEED_START_ESTIMATION_BAD_LOWER_DUTY_CYCLE_LIMIT_perc   (89.0f)

Definition at line 76 of file bender_ir155_helper.c.

◆ IR155_SPEED_START_ESTIMATION_BAD_UPPER_DUTY_CYCLE_LIMIT_perc

#define IR155_SPEED_START_ESTIMATION_BAD_UPPER_DUTY_CYCLE_LIMIT_perc   (96.0f)

Definition at line 77 of file bender_ir155_helper.c.

◆ IR155_SPEED_START_ESTIMATION_GOOD_LOWER_DUTY_CYCLE_LIMIT_perc

#define IR155_SPEED_START_ESTIMATION_GOOD_LOWER_DUTY_CYCLE_LIMIT_perc   (4.0f)

Definition at line 73 of file bender_ir155_helper.c.

◆ IR155_SPEED_START_ESTIMATION_GOOD_UPPER_DUTY_CYCLE_LIMIT_perc

#define IR155_SPEED_START_ESTIMATION_GOOD_UPPER_DUTY_CYCLE_LIMIT_perc   (11.0f)

Definition at line 74 of file bender_ir155_helper.c.

◆ IR155_UNDERVOLTAGE_MODE_LOWER_DUTY_CYCLE_LIMIT_perc

#define IR155_UNDERVOLTAGE_MODE_LOWER_DUTY_CYCLE_LIMIT_perc   (4.0f)

Definition at line 80 of file bender_ir155_helper.c.

◆ IR155_UNDERVOLTAGE_MODE_UPPER_DUTY_CYCLE_LIMIT_perc

#define IR155_UNDERVOLTAGE_MODE_UPPER_DUTY_CYCLE_LIMIT_perc   (96.0f)

Definition at line 81 of file bender_ir155_helper.c.

Function Documentation

◆ IR155_CalculateResistance()

static uint32_t IR155_CalculateResistance ( float  dutyCycle_perc)
static

Calculate insulation resistance from measured dutycycle.

Function check, that passed duty-cycle lies within allowed range. Otherwise, the calculated resistance will be limited to the next reasonable value.

Parameters
[in]dutyCycle_percmeasured signal duty-cycle in percentage
Returns
measured insulation resistance in kOhm

Definition at line 167 of file bender_ir155_helper.c.

◆ IR155_Deinitialize()

void IR155_Deinitialize ( void  )

Software deinitialization of Timer-module.

Definition at line 216 of file bender_ir155_helper.c.

◆ IR155_GetMeasurementMode()

static IR155_MEASUREMENT_MODE_e IR155_GetMeasurementMode ( float  frequency_Hz)
static

Determines frequency-dependent measurement state.

Use of intervals because of measuring and signal inaccuracy. This interval is configurable via define IR155_MEASUREMENT_INTERVAL_RANGE_Hz

Parameters
[in]frequency_Hzmeasured signal frequency in Hz
Returns
IR155_MEASUREMENT_MODE_e bender measurement mode

Definition at line 137 of file bender_ir155_helper.c.

◆ IR155_GetMeasurementValues()

IR155_MEASUREMENT_s IR155_GetMeasurementValues ( void  )

Interface function which delivers the actual signal measurement (duty cyle) and evaluation. Use of intervals because of measuring and signal inaccuracy. The evaluated results are finally written in the database.

Returns
IR155_MEASUREMENT_s measurement result of IR155 measurement

Definition at line 230 of file bender_ir155_helper.c.

Here is the call graph for this function:

◆ IR155_Initialize()

void IR155_Initialize ( uint8_t  triggerTime_ms)

Software initialization of Timer-module.

Parameters
triggerTime_mscyclic call time of IR155_GetMeasurementValues function

Definition at line 194 of file bender_ir155_helper.c.

Here is the call graph for this function:

◆ IR155_IsDutyCycleWithinInterval()

static bool IR155_IsDutyCycleWithinInterval ( float  dutyCycle_perc,
float  lowerLimit_perc,
float  upperLimit_perc 
)
static

Check if passed duty cycle is within interval limits.

Parameters
[in]dutyCycle_percmeasured signal duty-cycle in percentage
[in]lowerLimit_perclower interval limit
[in]upperLimit_percupper interval limit
Returns
measured insulation resistance in kOhm

Definition at line 182 of file bender_ir155_helper.c.

Variable Documentation

◆ ir155_state

IR155_STATE_s ir155_state
extern
Initial value:
= {
.ir155Initialized = false,
.measurement.isMeasurementValid = false,
.measurement.isUndervoltageDetected = false,
.measurement.measurementState = IR155_UNINITIALIZED,
.measurement.measurementMode = IR155_UNKNOWN,
.measurement.digitalStatusPin = STD_PIN_LOW,
.measurement.resistance_kOhm = 0,
.measurement.pwmSignal.dutyCycle_perc = 0.0f,
.measurement.pwmSignal.frequency_Hz = 0.0f,
.periodTriggerTime_ms = IMD_PERIODIC_CALL_TIME_ms,
}
@ IR155_UNKNOWN
@ IR155_UNINITIALIZED
@ STD_PIN_LOW
Definition: fstd_types.h:88
#define IMD_PERIODIC_CALL_TIME_ms
Definition: imd.h:67