simulink

Programmatically connect two subsystems

心不动则不痛 提交于 2019-12-02 19:54:15
问题 I'm trying to build a complex model programmatically reusing some custom blocks/models I have developed before, but I cannot manage to connect two PMC_Port This is what I have: % Main system sys_name = 'model'; sys = new_system(sys_name) open_system(sys_name) load_system('circuit_cell') % Subsystem with 6 PMC_Port elements % stored in circuit_cell.mdl file % Add cell #1 add_block('built-in/Subsystem', [sys_name '/cell1']) Simulink.BlockDiagram.copyContentsToSubSystem('circuit_cell', [sys_name

Feedback loop in Simulink/HDL Coder

故事扮演 提交于 2019-12-02 13:35:26
I have a system in Simulink/HDL coder (see below image please). I have 3 outputs and 3 inputs. I want my system to run 10 times. After each iteration it should select the outputs and use them as inputs. How I can do that? Build a loop using a memory and a initial value block for each signal. The memory block allows you to access the previous iteration signal and the initial value block is used to set the input for the first iteration. A simple example looping back one signal can be found here in the documentation In your case it would look like this: To get 10 iterations, set your simulation

Programmatically connect two subsystems

房东的猫 提交于 2019-12-02 11:37:10
I'm trying to build a complex model programmatically reusing some custom blocks/models I have developed before, but I cannot manage to connect two PMC_Port This is what I have: % Main system sys_name = 'model'; sys = new_system(sys_name) open_system(sys_name) load_system('circuit_cell') % Subsystem with 6 PMC_Port elements % stored in circuit_cell.mdl file % Add cell #1 add_block('built-in/Subsystem', [sys_name '/cell1']) Simulink.BlockDiagram.copyContentsToSubSystem('circuit_cell', [sys_name '/cell1']); % Add cell #2 add_block('built-in/Subsystem', [sys_name '/cell2']) Simulink.BlockDiagram

Implementation of custom counter logic in SIMULINK

六月ゝ 毕业季﹏ 提交于 2019-12-02 11:14:26
I am trying to implement a counter logic in SIMULINK where in1, in2 are inputs out1 is the output if in2 = 0, out1 = 0; if in2 = 1, out1 = 1 after x high edges of in1 I have tried using "Detect Rise Positive" block but failed miserably because I don't have sufficient experience of implementing a timing diagram correctly in SIMULINK. Could anyone kindly point me to the right direction? Update An approach I have taken since I posted this question is the "Triggered and enabled subsystem". I am trying to set it up so that: in2 becomes the enable signal in1 becomes the trigger in2 becomes the

Can you explain this Embedded MATLAB Function error?

六月ゝ 毕业季﹏ 提交于 2019-12-02 11:02:42
问题 I'm having a problem sending a value from a GUI to an Embedded MATLAB Function (EMF) in a Simulink model. I get this value from a slider in my GUI and send it to an EMF block in my model. I can confirm that the value is being transferred correctly from my GUI to my Simulink block, since I can display the value with a display block in my model and see the value change when I change the slider position in my GUI. However I keep getting this error when I run my model: Could not determine the

Serial block doesn't work with simulink coder

眉间皱痕 提交于 2019-12-02 10:25:26
问题 I receive some data signals from Serial Port using Serial Receive block (and Serial Configuration block of course). I use it to move a marker in a video. It works during simulation but when I generate .exe file using Simulink Coder marker doesn't move during execution. It would seem that it does not receive data from serial. * EDIT: *The original data is an int16 but the "source" is built on Arduino Mega2560 using Target Support Package and so using an Arduino serial send block it generates

Arduino stepper motor control with Simulink

徘徊边缘 提交于 2019-12-02 08:56:49
问题 Hi Im quite new in Arduino and electronics so bear with me. I have a project to control a step motor using Matlab and Simulink. For now I just want to get the thing up and running. I have hooked up the schematic tested it with a simple code for a step motor and it works (this has been done without Matlab). My problem is how can i get the motor to run using Simulink and Matlab? When i try to Run the Simulink model i get this My step motor driver board is ULN2003APG and my motor is . I have

Initialization of a Dymola FMU in Simulink

爱⌒轻易说出口 提交于 2019-12-02 07:50:20
I have encountered an issue while trying to simulate a model using an fmu file in Simulink: I am using the Modelon FMI toolbox for a Dymola/Simulink interface to import a Model-Exchange type fmu file (version 1.0) into the Simulink model. I have a Matlab m-file that programmatically simulates the model sequentially, saving the final internal states of the model for initialization in the next simulation. The first iteration of the simulation runs without errors, but on the second iteration, Matlab returns the following errors at the call for the simulation: module = partial_run_sim2/BasicModels

Serial block doesn't work with simulink coder

旧时模样 提交于 2019-12-02 07:24:10
I receive some data signals from Serial Port using Serial Receive block (and Serial Configuration block of course). I use it to move a marker in a video. It works during simulation but when I generate .exe file using Simulink Coder marker doesn't move during execution. It would seem that it does not receive data from serial. * EDIT: *The original data is an int16 but the "source" is built on Arduino Mega2560 using Target Support Package and so using an Arduino serial send block it generates the source on USB COM port with a baud rate of 9600. Because Arduino serial block wants only uint8 I

Arduino stepper motor control with Simulink

时间秒杀一切 提交于 2019-12-02 06:28:32
Hi Im quite new in Arduino and electronics so bear with me. I have a project to control a step motor using Matlab and Simulink. For now I just want to get the thing up and running. I have hooked up the schematic tested it with a simple code for a step motor and it works (this has been done without Matlab). My problem is how can i get the motor to run using Simulink and Matlab? When i try to Run the Simulink model i get this My step motor driver board is ULN2003APG and my motor is . I have downloaded the Arduino Hardware Support Package for Matlab and have already uploaded the server program to