Simulink develop TestCase

01--Background

Hey, my friends

I am writing the blog in English so that I can improve my working language skills, so it might have lots of mistake like grammar and spell or something else. Please feel free to ignore the issues. For it's my first time writing like this , I am not sure if I can express myself clearly.

02--Test case condition

The condition you can see below the table:

The total capacity of the small battery is 10 Ah. 1C(Coulomb) on discharging.

There has to be a 30 seconds pause after each charge and discharge.

Take the first raw as an example to explan:

The initial value of the small battery's SOC is 90%, the temperature is -30℃, and  at the moment, the battery need to discharge with a constant value 10A, when the discharge capacity reaches 5Ah, then the MOS or relay state must change from discharge to charge. And the charge current is 20A until the SOC reaches 90%. All the above procedure is treat as the number 1 cycle, the total cycles is 2 cycles.

And in the other rows, temperature is different,works on the same way. Base on the situation so that the module is able to be developed.

03--SW develop

1--Single temperature value

In order to develop the module,first of all, because of the temperatures are not continuous value, and other parameters change too. We can consider to use stateflow module to make a quick development.

As we had mentioned before,take the first raw as example:

(The charge is represented by a negative number)

Calibration parameters:

This one stateflow means in the temperature of -30℃,

Reset:use for the cycle number counts,when the total cycles reaches 2,the cycle counts will reset to the value 0.

State: 0 means in the discharge state, 1 means in the charge state.

Charge_I: charge current in the charge state.

Dis_Ah: discharge capacity in 1 cycle

DisChargeAh: constant value 10

RestTime: because of the phrase “There has to be a 30 seconds pause after each charge and discharge.”,so it's constant value 30

SOC_THD: current percentage of SOC

Cycle: the repeat number of cycles

T: temperature

2--Multiple temperature values

The stateflow can in the same way to copy with different temperatures:

And here are the interface of the stateflow:

3--Current select function

The function generates the value of current

Outside view:

Inside:

The value of current is impact by the State if it's on charge state or discharge state.

4--SOC calculate function

Outside view:

Inside:

We use the simplest way to calculate the percentage of SOC.

                      SOC = init_SOC - current*time/capacity

init_SOC: the initial value of SOC

DT: the module sample time

5--Total discharge capacity function

We can calclate the whole discharge capacity

Outside view:

Inside:

We use a Switch module to ignore the charge current, when in the charge state, the total discharge capacity will not be accumulated.

5.1discharge capacity in every cycle:

Outside view:

Inside:

In one cycle the discharge capacity will accumulate by one to one sample time,but in the next cycle, the capacity will reset to value 0.

6--TotalCycle Counter function

Outside view:

Inside:

6.1--Cycle Counter function

Outside view:

Inside:

7--Overview

According to the table, we can calculate the total discharge capacity in all the cycles and temperatures.

discharge_ah_stop_simu = (2+5+8+10+5+4+3+2+5+8+6+7+9+4)*5 = 390

We set the value to 390.1, when the capacity reached, the simulation will stop.

8--Oscilloscope result

The temperature and current is synchronously changing

The total discharge capacity is 390

Total cycles are 78

Cycle Counter function

Current select function

The details you can see the attachment of the simulink module.

  • 20
    点赞
  • 26
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
SQLAlchemy 是一个 SQL 工具包和对象关系映射(ORM)库,用于 Python 编程语言。它提供了一个高级的 SQL 工具和对象关系映射工具,允许开发者以 Python 类和对象的形式操作数据库,而无需编写大量的 SQL 语句。SQLAlchemy 建立在 DBAPI 之上,支持多种数据库后端,如 SQLite, MySQL, PostgreSQL 等。 SQLAlchemy 的核心功能: 对象关系映射(ORM): SQLAlchemy 允许开发者使用 Python 类来表示数据库表,使用类的实例表示表中的行。 开发者可以定义类之间的关系(如一对多、多对多),SQLAlchemy 会自动处理这些关系在数据库中的映射。 通过 ORM,开发者可以像操作 Python 对象一样操作数据库,这大大简化了数据库操作的复杂性。 表达式语言: SQLAlchemy 提供了一个丰富的 SQL 表达式语言,允许开发者以 Python 表达式的方式编写复杂的 SQL 查询。 表达式语言提供了对 SQL 语句的灵活控制,同时保持了代码的可读性和可维护性。 数据库引擎和连接池: SQLAlchemy 支持多种数据库后端,并且为每种后端提供了对应的数据库引擎。 它还提供了连接池管理功能,以优化数据库连接的创建、使用和释放。 会话管理: SQLAlchemy 使用会话(Session)来管理对象的持久化状态。 会话提供了一个工作单元(unit of work)和身份映射(identity map)的概念,使得对象的状态管理和查询更加高效。 事件系统: SQLAlchemy 提供了一个事件系统,允许开发者在 ORM 的各个生命周期阶段插入自定义的钩子函数。 这使得开发者可以在对象加载、修改、删除等操作时执行额外的逻辑。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值