4.27.2. Bender iso165c

4.27.2.1. Module Files

4.27.2.1.1. Driver

  • src/app/driver/imd/bender/iso165c/bender_iso165c.c

  • src/app/driver/imd/bender/iso165c/bender_iso165c.h

4.27.2.1.2. Configuration

  • src/app/driver/imd/bender/iso165c/bender_iso165c.c

  • src/app/driver/imd/bender/iso165c/bender_iso165c.h

4.27.2.1.3. Unit Test

  • tests/unit/app/driver/imd/bender/iso165c/test_bender_iso165c.c

4.27.2.2. Description

4.27.2.2.1. Communication

The Bender iso165C is connected to the BMS via CAN-bus, the handling of the messages is implemented in the can callback files.

4.27.2.2.2. 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.27.2.2.2.1. Initialization procedure

The state flow diagram of the initialization procedure of the Bender iso165C state machine is depicted below.

# Copyright (c) 2010 - 2024, 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
}

Fig. 4.5 iso165C initialization state flow diagram

The initialization process is implemented in function I165C_Initialize.

4.27.2.2.2.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 - 2024, 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
}

Fig. 4.6 iso165C enable state flow diagram

The enabling process is implemented in function I165C_Enable.

4.27.2.2.2.3. Disable insulation measurement

The state flow diagram of the disabling procedure of the Bender iso165C state machine is depicted below.

# Copyright (c) 2010 - 2024, 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_disable_fsm {
    rankdir=TB;
    size="50!,200";
    compound=true;
    node [shape = doublecircle]     nd_never_run
    node [shape = circle]           nd_stop_measurement_ack
                                    nd_request_hv_relay_state
                                    nd_check_neg_hv_relay_state
                                    nd_check_pos_hv_relay_state

    nd_never_run                 [label=<<B>Disable Start</B>>];
    nd_stop_measurement_ack      [label=<<B>Wait for acknowledge</B>>];
    nd_request_hv_relay_state    [label=<<B>Request opening of relays</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_never_run -> nd_stop_measurement_ack [label=<<B>Disable measurement</B>>];
    nd_stop_measurement_ack -> nd_stop_measurement_ack
    nd_stop_measurement_ack -> 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
}

Fig. 4.7 iso165C disable state flow diagram

The disabling process is implemented in function I165C_Disable.

4.27.2.2.2.4. Insulation measurement

The state flow diagram of the periodic insulation measurement procedure of the Bender iso165C state machine is depicted below.

# Copyright (c) 2010 - 2024, 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_running_fsm {
    rankdir=TB;
    size="50!,200";
    compound=true;
    node [shape = doublecircle]     nd_never_run
    node [shape = circle]           nd_read_measurement_values
                                    nd_read_measurement_values_ack
                                    nd_get_measurement

    nd_never_run                    [label=<<B>Start insulation measurement</B>>];
    nd_read_measurement_values      [label=<<B>Request resistance measurement values</B>>];
    nd_read_measurement_values_ack  [label=<<B>Evaluate measurement result</B>>];
    nd_get_measurement              [label=<<B>Evaluate status and device flags</B>>];

    nd_never_run -> nd_read_measurement_values
    nd_read_measurement_values -> nd_read_measurement_values_ack
    nd_read_measurement_values_ack -> nd_read_measurement_values_ack
    nd_read_measurement_values_ack -> nd_get_measurement
    nd_get_measurement -> nd_read_measurement_values  [label=<<B>Restart measurement cycle</B>>];
}

Fig. 4.8 iso165C running state flow diagram

The measurement process is implemented in function I165C_Running.