4.23.2. Bender iso165c
4.23.2.2. Description
4.23.2.2.1. Description of the IMD state machine
The Bender iso165C driver is interfaced and controlled by the superimposed IMD state machine. The required functionality, that needs to be provided by this driver is:
Initialize the Bender iso165C device
Activate the insulation measurement
Deactivate the insulation measurement
Measurement of the insulation resistance
Each functionality is implemented in a dedicated state machine that is explained in detail in the following.
4.23.2.2.1.1. Initialization procedure
The state flow diagram of the initialization procedure of the Bender iso165C state machine is depicted below.
![# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V.
# All rights reserved.
#
# 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®"
digraph iso165c_init_fsm {
rankdir=TB;
size="50!,200";
compound=true;
node [shape = doublecircle] nd_never_run
node [shape = circle] nd_unlock_wait_ack
nd_check_meas_state
nd_check_meas_state_ack
nd_open_hv_relay
nd_request_hv_relay_state
nd_check_neg_hv_relay_state
nd_check_pos_hv_relay_state
nd_request_self_test
nd_request_self_test_ack
nd_wait_self_test
nd_set_averaging_factor
nd_set_averaging_factor_ack
nd_set_error_threshold
nd_set_error_threshold_ack
nd_set_warning_threshold
nd_set_warning_threshold_ack
nd_disable_measurement
nd_disable_measurement_ack
nd_never_run [label=<<B>Initialization Start</B>>];
nd_unlock_wait_ack [label=<<B>Wait for acknowledge</B>>];
nd_check_meas_state [label=<<B>Check insulation measurement state</B>>];
nd_check_meas_state_ack [label=<<B>Wait for acknowledge</B>>];
nd_open_hv_relay [label=<<B>Open HV Relays</B>>];
nd_request_hv_relay_state [label=<<B>Request relay state</B>>];
nd_check_neg_hv_relay_state [label=<<B>Check negative HV relay state</B>>];
nd_check_pos_hv_relay_state [label=<<B>Check positive HV relay state</B>>];
nd_request_self_test [label=<<B>Start self-test</B>>];
nd_request_self_test_ack [label=<<B>Wait for acknowledge</B>>];
nd_wait_self_test [label=<<B>Wait until self-test finished</B>>];
nd_set_averaging_factor [label=<<B>Set measurement averaging factor</B>>];
nd_set_averaging_factor_ack [label=<<B>Wait for acknowledge</B>>];
nd_set_error_threshold [label=<<B>Set insulation resistance error threshold</B>>];
nd_set_error_threshold_ack [label=<<B>Wait for acknowledge</B>>];
nd_set_warning_threshold [label=<<B>Set insulation resistance warning threshold</B>>];
nd_set_warning_threshold_ack [label=<<B>Wait for acknowledge</B>>];
nd_disable_measurement [label=<<B>Disable insulation measurement</B>>];
nd_disable_measurement_ack [label=<<B>Wait for acknowledge</B>>];
nd_never_run -> nd_unlock_wait_ack [label=<<B>Unlock device</B>>];
nd_unlock_wait_ack -> nd_check_meas_state
nd_check_meas_state -> nd_check_meas_state_ack [label=<<B>Enable measurement if disabled</B>>];
nd_check_meas_state_ack -> nd_check_meas_state_ack
nd_check_meas_state_ack -> nd_open_hv_relay [label=<<B>Measurement enabled</B>>];
nd_check_meas_state -> nd_open_hv_relay
nd_open_hv_relay -> nd_request_hv_relay_state
nd_request_hv_relay_state -> nd_check_neg_hv_relay_state
nd_check_neg_hv_relay_state -> nd_check_pos_hv_relay_state
nd_check_pos_hv_relay_state -> nd_request_self_test
nd_request_self_test -> nd_request_self_test_ack
nd_request_self_test -> nd_disable_measurement [label=<<B>Skip configuration if device has already been configured</B>>];
nd_request_self_test_ack -> nd_request_self_test_ack
nd_request_self_test_ack -> nd_wait_self_test
nd_wait_self_test -> nd_wait_self_test [label=<<B>Wait until finished</B>>];
nd_wait_self_test -> nd_set_averaging_factor
nd_set_averaging_factor -> nd_set_averaging_factor_ack
nd_set_averaging_factor_ack -> nd_set_averaging_factor_ack
nd_set_averaging_factor_ack -> nd_set_error_threshold
nd_set_error_threshold -> nd_set_error_threshold_ack
nd_set_error_threshold_ack -> nd_set_error_threshold_ack
nd_set_error_threshold_ack -> nd_set_warning_threshold
nd_set_warning_threshold -> nd_set_warning_threshold_ack
nd_set_warning_threshold_ack -> nd_set_warning_threshold_ack
nd_set_warning_threshold_ack -> nd_disable_measurement
nd_disable_measurement -> nd_disable_measurement_ack
nd_disable_measurement_ack -> nd_disable_measurement_ack
}](../../../../../_images/graphviz-fe86c0aab75c9b2ec01ed3548102875134d3903e.png)
Fig. 4.5 iso165C initialization state flow diagram
The initialization process is implemented in function I165C_Initialize.
4.23.2.2.1.2. Activation of insulation measurement
The state flow diagram of the enabling procedure of the Bender iso165C state machine is depicted below.
![# Copyright (c) 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V.
# All rights reserved.
#
# 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®"
digraph iso165c_enable_fsm {
rankdir=TB;
size="50!,200";
compound=true;
node [shape = doublecircle] nd_never_run
node [shape = circle] nd_request_hv_relay_state
nd_check_neg_hv_relay_state
nd_check_pos_hv_relay_state
nd_start_measurement
nd_start_measurement_ack
nd_never_run [label=<<B>Enable Start</B>>];
nd_request_hv_relay_state [label=<<B>Request relay state</B>>];
nd_check_neg_hv_relay_state [label=<<B>Check negative HV relay state</B>>];
nd_check_pos_hv_relay_state [label=<<B>Check positive HV relay state</B>>];
nd_start_measurement [label=<<B>Start insulation measurement</B>>];
nd_start_measurement_ack [label=<<B>Wait for acknowledge</B>>];
nd_never_run -> nd_request_hv_relay_state [label=<<B>Close HV relays</B>>];
nd_request_hv_relay_state -> nd_check_neg_hv_relay_state
nd_check_neg_hv_relay_state -> nd_check_pos_hv_relay_state
nd_check_pos_hv_relay_state -> nd_start_measurement
nd_start_measurement -> nd_start_measurement_ack
nd_start_measurement_ack -> nd_start_measurement_ack
}](../../../../../_images/graphviz-aaec08918ff4787b4e76f5579c5fde496daea899.png)
Fig. 4.6 iso165C enable state flow diagram
The enabling process is implemented in function I165C_Enable.