当前位置:网站首页>MATLAB/Simulink&&STM32CubeMX工具链完成基于模型的设计开发(MBD)(三)
MATLAB/Simulink&&STM32CubeMX工具链完成基于模型的设计开发(MBD)(三)
2022-07-31 03:57:00 【小师兄1995】
前言
基于上两篇内容,本篇博客借助于STM32提供的MATLAB硬件支持包完成基于模型的开发。此工具链用到的工具为MATLAB/Simulink和STM32CubeMX,而省略了Keil工具进行手工代码集成的步骤,所有的工作仅在MATLAB/Simulink和STM32CubeMX完成。
注:应用此工具链需要安装STM32硬件支持包,STM32CubeMX和STM32CubeProgrammer,并进行硬件环境配置。
一、概述
设计需求:通过按键控制两个LED的状态,按一次按键两个LED亮,再按一次按键两个LED以1s时间间隔交替闪烁,再按一次按键,两个LED灭。
控制器:STM32F407ZG
应用层开发:MATLAB/Simulink
底层配置:STM32CubeMX
二、使用步骤
1.硬件设计
指示灯:LED0、LED1
按键:KEY0

2.软件设计
1、MATLAB->APP->Run on Hardware Board,选择目标开发板。我的板子是STM32F407ZG,因此选STM32F4xx Based

2、新建STM32CubeMX工程,配置底层。配置PF9、PF10为输出,PE4为输入,进行Project Manager设置,保存工程




3、在MATLAB中打开设置将STM32CubeMX工程进行加载,进入MATLAB/Simulink进行应用层编程。
4、MATLAB编程如下
4.1安装STM32硬件支持包后在Simulink会出现该支持包的硬件资源
4.2读取PE4的状态,当产生一个下降沿表明按键KEY0被按下,触发子系统运行。触发第一次,子系统输出0;触发第二次,子系统输出1;触发第三次子系统输出3,重复循环。
4.2当触发子系统输出0时,关闭LED0、LED1,PF9、PF10输出1。
4.3当触发子系统输出1时,打开LED0、LED1,PF9、PF10输出0。
4.4当触发子系统输出2时,LED0和LED1成流水状态,1s间隔周期
5、设置求解器,自动处理数据传输的速率转换
6、打开开发板,点击Builid Deploy & Start,等待下载完成观察实验现象。

7、实验现象
0730
边栏推荐
- (六)枚举、注解
- The application and practice of mid-to-platform brand advertising platform
- IIR filter and FIR filter
- 识Flutter 基本组件之showTimePicker 方法
- 高等数学---第九章二重积分
- (8) Math class, Arrays class, System class, Biglnteger and BigDecimal classes, date class
- 安全20220718
- BUG definition of SonarQube
- (5) final, abstract class, interface, inner class
- Difference between unallocated blocks and unused blocks in database files
猜你喜欢

TCP和UDP详解

Database implements distributed locks

Unity2D 自定义Scriptable Tiles的理解与使用(四)——开始着手构建一个基于Tile类的自定义tile(下)

LocalDate addition and subtraction operations and comparison size

浅识Flutter 基本组件之CheckboxListTile组件

Postgresql 15 source code analysis (5) - pg_control

5. How does the SAP ABAP OData service support the $filter operation

A brief introduction to the CheckBox component of the basic components of Flutter
![[C language] General method for finding the sum of the greatest common factor and the least common multiple of two integers m and n, the classical solution](/img/60/fa75e06af4d143ee3fb493221fa3d9.jpg)
[C language] General method for finding the sum of the greatest common factor and the least common multiple of two integers m and n, the classical solution

扫雷游戏(c语言写)
随机推荐
"A daily practice, happy water problem" 1331. Array serial number conversion
pom文件成橘红色未加载的解决方案
Mysql 45 study notes (twenty-five) MYSQL guarantees high availability
扫雷游戏(c语言写)
postgresql 15源码浅析(5)—— pg_control
安全20220709
What skills do I need to learn to move from manual testing to automated testing?
IIR filter and FIR filter
Know the showTimePicker method of the basic components of Flutter
(四)递归、可变参数、访问修饰符、理解 main 方法、代码块
Daily practice of LeetCode - 138. Copy a linked list with random pointers
Understanding and Using Unity2D Custom Scriptable Tiles (4) - Start to build a custom tile based on the Tile class (below)
高等数学---第九章二重积分
type_traits metaprogramming library learning
Redis counts new and retained users
SocialFi 何以成就 Web3 去中心化社交未来
Redis 使用 sorted set 做最新评论缓存
(八)Math 类、Arrays 类、System类、Biglnteger 和 BigDecimal 类、日期类
Knowledge Distillation 7: Detailed Explanation of Knowledge Distillation Code
SIP Protocol Standard and Implementation Mechanism