当前位置:网站首页>2837xd code generation - stateflow (3)
2837xd code generation - stateflow (3)
2022-07-02 09:43:00 【Quikk】
2837xd Code generation ——StateFlow(3)
11 True Table
stay Chart Add True Table Model .

Then add the corresponding elements in the truth table :

Truth table is divided into condition table and action table , Such as the condition table D1 It means , When shift==1 when , Executive action 1. and D3 As long as shift Not for 1 perhaps 2 Perform the third action . Then it needs to be in Model Explorer Add the corresponding input and output variables , Before that, put True Table Name modification of , Otherwise, it will report a mistake .

Then need to be for chart Define inputs and outputs , The calling method is consistent with the function :

Build external components to DEBUG that will do :

12 Use of plural
Use and definition of plural , With the choice of language (m or c) It matters . such as matlab Built in functions in abs() You can receive complex number modulo , however c In language abs There is no such function . If at this time c Language compilation environment , Can use Matlab Function To call matlab Medium abs() Function to get . The following compilation environments are matlab Language .

After building the periphery ,DEBUG You can get the following :

Pay attention here , Default Model Explorer in complexity by off, If the received data is complex , It needs to turn on itself (on perhaps inherited Choose according to your needs ).

13 Output size Changed data
stay Chart Make sure that , Support variable data size :

Then build the following Simulink Function To call :


Build peripheral components , Set relevant variable parameters ,size Be sure to set with maximum output size identical , Otherwise, it will report a mistake .


The following results can be observed ,out Output changed size The data of :

14 Implicit event
Chart There are four implicit events in :1)change(chg)、enter(en)、exit(ex)、tick(wakeup)
Build the following chart,state1 And state2 Is a parallel execution relationship ,state2 State transition and y The value of ( When y When there is a change ,state2 The state changes ).

It is still a parallel relationship , Change to en And ex Implicit event :
C、D And state1.B State entry and exit are closely related .

tick Observation of events :
after(5,tick) The state transition is allowed only after the meaning conversion request occurs five times .

Adopt fixed step simulation (0.5s):

You can find every 2.5s Enter once state2, Every time state2 Middle stay 1.5s Back entry state1.
15 Structure operation
Simulink Available in BUS Component building structure ,BUS And MUX The difference is BUS Structure will be generated , and MUX Just let multiple data streams adopt one line transmission .

Pay attention to setting the signal number , The default is Signaln. Then build a Chart modular :

here mydata and indata It's all structural , Its operation is exactly the same as the point operation of the structure . The point is that we need to Model Explorer The structure is defined in :
First select ,Base Workspace, Click on Add, Choose Simulink Bus Add structure .

And then click Launch Bus Editor

by Bus Add object , Here I choose and Bus The object names in are consistent , Inconsistency can also be passed .

Then set the dimension of each object separately :

After the chart The variables in the (mydata、indata) Change to just set Bus:

The next steps are the same as others chart The model construction is consistent .
Here's how to use c The way language introduces structures :
So let's set up a .h The file is placed in the storage address of the model file :

And then in Configuration Parameters Defined in :

Build the following chart:


And then in Model Explorer Relevant definitions in , Note that there is no need for mydata Define , Because it has been defined in the header file , The results are as follows :

If the simulation is ok , Can press Ctrl+B Generate code , At this time, you need to switch the output to the port (Out). You can see the statement of the application header file :

Now try to manage the code , Before code management :

First, replace the input and output with ports :

Then find the following tools ( Notice that there is already a label on the signal ):


Then generate the code again , This part of the content will be studied systematically , I don't quite understand yet .
边栏推荐
- Amq6126 problem solving ideas
- College Students' CET-4 and CET-6 composition template (self created version, successfully crossed CET-6)
- Typeerror: X () got multiple values for argument 'y‘
- MySql报错:unblock with mysqladmin flush-hosts
- Navicat remote connection MySQL reports an error 1045 - access denied for user 'root' @ '222.173.220.236' (using password: yes)
- 每天睡前30分钟阅读Day6_Day6_Date_Calendar_LocalDate_TimeStamp_LocalTime
- Creation and jump of activity
- MySQL事务
- 攻防世界-Web进阶区-unserialize3
- Safety production early warning system software - Download safety production app software
猜你喜欢

Matplotlib swordsman line - layout guide and multi map implementation (Updated)

2837xd code generation - stateflow (4)

idea查看字节码配置

记录一下初次使用Xray的有趣过程

自定義Redis連接池

Image recognition - data augmentation

Typeerror: X () got multiple values for argument 'y‘

Creation and jump of activity

How to use PHP spoole to implement millisecond scheduled tasks

2837xd 代碼生成——StateFlow(4)
随机推荐
College Students' CET-4 and CET-6 composition template (self created version, successfully crossed CET-6)
道阻且长,行则将至
Fragmenttabhost implements the interface of housing loan calculator
kinect dk 获取CV::Mat格式的彩色RGB图像(openpose中使用)
MySQL multi column in operation
Redis installation and deployment (windows/linux)
Solutions to Chinese garbled code in CMD window
Creation and jump of activity
Beats (filebeat, metricbeat), kibana, logstack tutorial of elastic stack
记录一下初次使用Xray的有趣过程
Image recognition - Data Cleaning
Alibaba /热门json解析开源项目 fastjson2
Record personal understanding and experience of game console configuration
PI control of grid connected inverter (grid connected mode)
MySQL事务
What are the differences between TP5 and laravel
Break the cocoon | one article explains what is the real cloud primordial
Redis 序列化 GenericJackson2JsonRedisSerializer和Jackson2JsonRedisSerializer的区别
QT qlabel style settings
FragmentTabHost实现房贷计算器界面