HVAC_M7_MODEL/Model_actuator.c

855 lines
26 KiB
C

/*
* File: Model_actuator.c
*
* Code generated for Simulink model 'Model_actuator'.
*
* Model version : 1.552
* Simulink Coder version : 24.1 (R2024a) 19-Nov-2023
* C/C++ source code generated on : Wed Dec 24 11:40:12 2025
*
* Target selection: ert.tlc
* Embedded hardware selection: ARM Compatible->ARM Cortex-M
* Emulation hardware selection:
* Differs from embedded hardware (MATLAB Host)
* Code generation objectives: Unspecified
* Validation result: Not run
*/
#include "Model_actuator.h"
#include <stdint.h>
#include "Model_actuator_private.h"
#include <stdbool.h>
#include "Model_actuator_types.h"
/* Exported block states */
ActuatorCmdBus controllerData; /* '<Root>/Data Store Memory15' */
/* Block signals (default storage) */
B rtB;
/* Block states (default storage) */
DW rtDW;
/* External inputs (root inport signals with default storage) */
ExtU rtU;
/* External outputs (root outports fed by signals with default storage) */
ExtY rtY;
/* Real-time model */
static RT_MODEL rtM_;
RT_MODEL *const rtM = &rtM_;
/*
* Output and update for action system:
* '<S10>/If Action Subsystem3'
* '<S9>/If Action Subsystem3'
* '<S8>/If Action Subsystem3'
* '<S2>/If Action Subsystem3'
* '<S5>/If Action Subsystem3'
* '<S7>/If Action Subsystem3'
* '<S1>/If Action Subsystem3'
*/
void IfActionSubsystem3(int8_t rtu_stepIn, int8_t *rty_step, uint8_t
rtd_com_loc[9])
{
int32_t i;
/* DataStoreWrite: '<S40>/Data Store Write3' */
for (i = 0; i < 9; i++) {
rtd_com_loc[i] = 0U;
}
/* End of DataStoreWrite: '<S40>/Data Store Write3' */
/* SignalConversion generated from: '<S40>/stepIn' */
*rty_step = rtu_stepIn;
}
/*
* Output and update for atomic system:
* '<S2>/MAX POSITION'
* '<S1>/MAX POSITION'
*/
void MAXPOSITION(const int16_t rtu_step[9], int16_t rty_y[9])
{
int32_t i;
/* : y = step; */
for (i = 0; i < 9; i++) {
rty_y[i] = rtu_step[i];
}
/* : fprintf('SIMULINK POSITION '); */
printf("SIMULINK POSITION ");
fflush(stdout);
/* : for i = 1:numel(step) */
for (i = 0; i < 9; i++) {
/* : fprintf('%d ', int16(step(i))); */
printf("%d ", rtu_step[i]);
fflush(stdout);
}
/* : fprintf('\n'); */
printf("\n");
fflush(stdout);
}
/*
* Output and update for atomic system:
* '<S2>/MAX POSITION1'
* '<S1>/MAX POSITION1'
*/
void MAXPOSITION1(const int8_t rtu_step[9], int8_t rty_y[9])
{
int32_t i;
/* : y = step; */
for (i = 0; i < 9; i++) {
rty_y[i] = rtu_step[i];
}
/* : fprintf('SIMULINK Stall_Slave '); */
printf("SIMULINK Stall_Slave ");
fflush(stdout);
/* : for i = 1:numel(step) */
for (i = 0; i < 9; i++) {
/* : fprintf('%d ', int16(step(i))); */
printf("%d ", (int16_t)rtu_step[i]);
fflush(stdout);
}
/* : fprintf('\n'); */
printf("\n");
fflush(stdout);
}
/* Model step function */
void Model_actuator_step(void)
{
int32_t i;
int16_t rtb_y_ff[9];
int8_t rtb_y_b[9];
bool rtb_RelationalOperator_j[9];
bool tmp;
bool tmp_0;
/* Switch: '<Root>/Switch' incorporates:
* DataStoreRead: '<Root>/Data Store Read'
*/
if (rtDW.stepSig < 1) {
/* Switch: '<Root>/Switch' incorporates:
* Constant: '<Root>/Constant1'
*/
rtDW.UnitDelay_DSTATE = 1;
}
/* End of Switch: '<Root>/Switch' */
/* SwitchCase: '<Root>/Switch Case' */
switch (rtDW.UnitDelay_DSTATE) {
case 1:
/* Outputs for IfAction SubSystem: '<Root>/Stop Mode' incorporates:
* ActionPort: '<S10>/Action Port'
*/
/* If: '<S10>/If1' incorporates:
* Inport: '<Root>/in_Busy_Ch0'
* Inport: '<Root>/in_Error_Connect_Ch0'
*/
if ((rtU.in_Busy_Ch0 == 0) && (rtU.in_Error_Connect_Ch0 == 0)) {
/* Outputs for IfAction SubSystem: '<S10>/If Action Subsystem2' incorporates:
* ActionPort: '<S39>/Action Port'
*/
for (i = 0; i < 9; i++) {
/* DataStoreWrite: '<S39>/Data Store Write2' */
rtDW.mode_loc[i] = 2U;
/* DataStoreWrite: '<S39>/Data Store Write3' */
rtDW.com_loc[i] = 1U;
}
/* Merge: '<Root>/Merge' incorporates:
* Constant: '<S39>/Constant'
* Merge: '<S10>/Merge'
* SignalConversion generated from: '<S39>/step'
* Sum: '<S39>/step inc'
*/
rtB.Merge = (int8_t)(rtDW.UnitDelay_DSTATE + 1);
/* MATLAB Function: '<S39>/stop mode' */
/* : y = step; */
/* : fprintf('SIMULINK Stop Mode\n'); */
printf("SIMULINK Stop Mode\n");
fflush(stdout);
printf("SIMULINK Stop Mode2\n");
fflush(stdout);
/* End of Outputs for SubSystem: '<S10>/If Action Subsystem2' */
} else {
/* Outputs for IfAction SubSystem: '<S10>/If Action Subsystem3' incorporates:
* ActionPort: '<S40>/Action Port'
*/
/* Merge: '<Root>/Merge' */
IfActionSubsystem3(rtDW.UnitDelay_DSTATE, &rtB.Merge, rtDW.com_loc);
/* End of Outputs for SubSystem: '<S10>/If Action Subsystem3' */
}
/* End of If: '<S10>/If1' */
/* End of Outputs for SubSystem: '<Root>/Stop Mode' */
break;
case 2:
/* Outputs for IfAction SubSystem: '<Root>/Initial CPOS Min' incorporates:
* ActionPort: '<S6>/Action Port'
*/
/* If: '<S6>/If' incorporates:
* Inport: '<Root>/in_Busy_Ch0'
* Inport: '<Root>/in_Error_Connect_Ch0'
*/
if ((rtU.in_Busy_Ch0 == 0) && (rtU.in_Error_Connect_Ch0 == 0)) {
/* Outputs for IfAction SubSystem: '<S6>/If Action Subsystem' incorporates:
* ActionPort: '<S27>/Action Port'
*/
for (i = 0; i < 9; i++) {
/* DataStoreWrite: '<S27>/Data Store Write' */
rtDW.pos_loc[i] = 6000U;
/* DataStoreWrite: '<S27>/Data Store Write1' */
rtDW.com_loc[i] = 2U;
}
/* MATLAB Function: '<S27>/Initial CPOS Min' */
/* : y = step; */
/* : fprintf('SIMULINK Initial CPOS Min - 6000\n'); */
printf("SIMULINK Initial CPOS Min - 6000\n");
fflush(stdout);
/* Merge: '<Root>/Merge' incorporates:
* Constant: '<S27>/Constant'
* Merge: '<S6>/Merge'
* SignalConversion generated from: '<S27>/step'
* Sum: '<S27>/step inc'
*/
rtB.Merge = (int8_t)(rtDW.UnitDelay_DSTATE + 1);
/* End of Outputs for SubSystem: '<S6>/If Action Subsystem' */
} else {
/* Outputs for IfAction SubSystem: '<S6>/If Action Subsystem3' incorporates:
* ActionPort: '<S28>/Action Port'
*/
/* DataStoreWrite: '<S28>/Data Store Write3' */
for (i = 0; i < 9; i++) {
rtDW.com_loc[i] = 0U;
}
/* End of DataStoreWrite: '<S28>/Data Store Write3' */
/* Merge: '<Root>/Merge' incorporates:
* Merge: '<S6>/Merge'
* SignalConversion generated from: '<S28>/stepIn1'
*/
rtB.Merge = rtDW.UnitDelay_DSTATE;
/* End of Outputs for SubSystem: '<S6>/If Action Subsystem3' */
}
/* End of If: '<S6>/If' */
/* End of Outputs for SubSystem: '<Root>/Initial CPOS Min' */
break;
case 3:
/* Outputs for IfAction SubSystem: '<Root>/Normal Mode' incorporates:
* ActionPort: '<S9>/Action Port'
*/
/* If: '<S9>/If1' incorporates:
* Inport: '<Root>/in_Busy_Ch0'
* Inport: '<Root>/in_Error_Connect_Ch0'
*/
if ((rtU.in_Busy_Ch0 == 0) && (rtU.in_Error_Connect_Ch0 == 0)) {
/* Outputs for IfAction SubSystem: '<S9>/If Action Subsystem2' incorporates:
* ActionPort: '<S36>/Action Port'
*/
for (i = 0; i < 9; i++) {
/* DataStoreWrite: '<S36>/Data Store Write' */
rtDW.mode_loc[i] = 0U;
/* DataStoreWrite: '<S36>/Data Store Write2' */
rtDW.com_loc[i] = 1U;
}
/* MATLAB Function: '<S36>/Normal Mode' */
/* : y = step; */
/* : fprintf('SIMULINK Normal Mode\n'); */
printf("SIMULINK Normal Mode\n");
fflush(stdout);
/* Merge: '<Root>/Merge' incorporates:
* Constant: '<S36>/Constant'
* SignalConversion generated from: '<S36>/step'
* Sum: '<S36>/step inc'
*/
rtB.Merge = (int8_t)(rtDW.UnitDelay_DSTATE + 1);
/* End of Outputs for SubSystem: '<S9>/If Action Subsystem2' */
} else {
/* Outputs for IfAction SubSystem: '<S9>/If Action Subsystem3' incorporates:
* ActionPort: '<S37>/Action Port'
*/
IfActionSubsystem3(rtDW.UnitDelay_DSTATE, &rtB.Merge, rtDW.com_loc);
/* End of Outputs for SubSystem: '<S9>/If Action Subsystem3' */
}
/* End of If: '<S9>/If1' */
/* End of Outputs for SubSystem: '<Root>/Normal Mode' */
break;
case 4:
/* Outputs for IfAction SubSystem: '<Root>/Move to position Min' incorporates:
* ActionPort: '<S8>/Action Port'
*/
/* If: '<S8>/If1' incorporates:
* Inport: '<Root>/in_Busy_Ch0'
* Inport: '<Root>/in_Error_Connect_Ch0'
*/
if ((rtU.in_Busy_Ch0 == 0) && (rtU.in_Error_Connect_Ch0 == 0)) {
/* Outputs for IfAction SubSystem: '<S8>/If Action Subsystem2' incorporates:
* ActionPort: '<S33>/Action Port'
*/
for (i = 0; i < 9; i++) {
/* DataStoreWrite: '<S33>/Data Store Write1' */
rtDW.stall_set_loc[i] = 1U;
/* DataStoreWrite: '<S33>/Data Store Write3' incorporates:
* Constant: '<S33>/Constant2'
*/
rtDW.lnoise_set_loc[i] = 0U;
/* DataStoreWrite: '<S33>/Data Store Write2' */
rtDW.com_loc[i] = 3U;
/* DataStoreWrite: '<S33>/Data Store Write4' incorporates:
* Constant: '<S33>/Constant4'
*/
rtDW.autos_set_loc[i] = 0U;
/* DataStoreWrite: '<S33>/Data Store Write5' incorporates:
* Constant: '<S33>/Constant5'
*/
rtDW.speed_set_loc[i] = 0U;
/* DataStoreWrite: '<S33>/Data Store Write6' incorporates:
* Constant: '<S33>/Constant6'
*/
rtDW.coils_stop_set_loc[i] = 0U;
/* DataStoreWrite: '<S33>/Data Store Write' */
rtDW.pos_loc[i] = 1U;
}
/* MATLAB Function: '<S33>/Move to position Min' */
/* : y = step; */
/* : fprintf('SIMULINK Move to position Min - 1\n'); */
printf("SIMULINK Move to position Min - 1\n");
fflush(stdout);
/* Merge: '<Root>/Merge' incorporates:
* Constant: '<S33>/Constant'
* SignalConversion generated from: '<S33>/step'
* Sum: '<S33>/step inc'
*/
rtB.Merge = (int8_t)(rtDW.UnitDelay_DSTATE + 1);
/* End of Outputs for SubSystem: '<S8>/If Action Subsystem2' */
} else {
/* Outputs for IfAction SubSystem: '<S8>/If Action Subsystem3' incorporates:
* ActionPort: '<S34>/Action Port'
*/
IfActionSubsystem3(rtDW.UnitDelay_DSTATE, &rtB.Merge, rtDW.com_loc);
/* End of Outputs for SubSystem: '<S8>/If Action Subsystem3' */
}
/* End of If: '<S8>/If1' */
/* End of Outputs for SubSystem: '<Root>/Move to position Min' */
break;
case 5:
/* Outputs for IfAction SubSystem: '<Root>/Check Stall Min' incorporates:
* ActionPort: '<S2>/Action Port'
*/
/* RelationalOperator: '<S2>/Relational Operator1' incorporates:
* DataStoreWrite: '<Root>/Data Store Write4'
* Inport: '<Root>/in_Act_Stall_Slave_Ch0'
*/
for (i = 0; i < 9; i++) {
rtb_RelationalOperator_j[i] = (rtU.in_Act_Stall_Slave_Ch0[i] == 1);
}
/* End of RelationalOperator: '<S2>/Relational Operator1' */
/* Logic: '<S2>/Logical Operator2' */
tmp = rtb_RelationalOperator_j[0];
for (i = 0; i < 8; i++) {
tmp = (tmp || rtb_RelationalOperator_j[i + 1]);
}
/* RelationalOperator: '<S2>/Relational Operator' incorporates:
* DataStoreWrite: '<Root>/Data Store Write1'
* Inport: '<Root>/in_CPOS_ALL_Ch0'
*/
for (i = 0; i < 9; i++) {
rtb_RelationalOperator_j[i] = (rtU.in_CPOS_ALL_Ch0[i] == 1);
}
/* End of RelationalOperator: '<S2>/Relational Operator' */
/* Logic: '<S2>/Logical Operator1' */
tmp_0 = rtb_RelationalOperator_j[0];
for (i = 0; i < 8; i++) {
tmp_0 = (tmp_0 || rtb_RelationalOperator_j[i + 1]);
}
/* If: '<S2>/If2' incorporates:
* DataTypeConversion: '<S2>/Data Type Conversion'
* DataTypeConversion: '<S2>/Data Type Conversion1'
* Inport: '<Root>/in_Busy_Ch0'
* Inport: '<Root>/in_Error_Connect_Ch0'
* Logic: '<S2>/Logical Operator'
* Logic: '<S2>/Logical Operator1'
* Logic: '<S2>/Logical Operator2'
*/
if ((rtU.in_Busy_Ch0 == 0) && (rtU.in_Error_Connect_Ch0 == 0) && (tmp ||
tmp_0)) {
/* Outputs for IfAction SubSystem: '<S2>/If Action Subsystem2' incorporates:
* ActionPort: '<S17>/Action Port'
*/
/* DataStoreWrite: '<S17>/Data Store Write1' incorporates:
* DataStoreWrite: '<Root>/Data Store Write1'
* Inport: '<Root>/in_CPOS_ALL_Ch0'
*/
for (i = 0; i < 9; i++) {
rtDW.Min_position_Ch0[i] = rtU.in_CPOS_ALL_Ch0[i];
}
/* End of DataStoreWrite: '<S17>/Data Store Write1' */
/* Merge: '<Root>/Merge' incorporates:
* Constant: '<S17>/Constant'
* Sum: '<S17>/step inc'
*/
rtB.Merge = (int8_t)(rtDW.UnitDelay_DSTATE + 1);
/* MATLAB Function: '<S17>/MIN POSITION' incorporates:
* DataStoreWrite: '<Root>/Data Store Write1'
* Inport: '<Root>/in_CPOS_ALL_Ch0'
*/
/* : y = step; */
/* : fprintf('SIMULINK Min_position_Ch0 '); */
printf("SIMULINK Min_position_Ch0 ");
fflush(stdout);
/* : for i = 1:numel(step) */
for (i = 0; i < 9; i++) {
/* : fprintf('%d ', int16(step(i))); */
printf("%d ", rtU.in_CPOS_ALL_Ch0[i]);
fflush(stdout);
}
/* : fprintf('\n'); */
printf("\n");
fflush(stdout);
/* End of MATLAB Function: '<S17>/MIN POSITION' */
/* End of Outputs for SubSystem: '<S2>/If Action Subsystem2' */
} else {
/* Outputs for IfAction SubSystem: '<S2>/If Action Subsystem3' incorporates:
* ActionPort: '<S18>/Action Port'
*/
IfActionSubsystem3(rtDW.UnitDelay_DSTATE, &rtB.Merge, rtDW.com_loc);
/* End of Outputs for SubSystem: '<S2>/If Action Subsystem3' */
}
/* End of If: '<S2>/If2' */
/* MATLAB Function: '<S2>/MAX POSITION' incorporates:
* Inport: '<Root>/in_CPOS_ALL_Ch0'
*/
MAXPOSITION(rtU.in_CPOS_ALL_Ch0, rtb_y_ff);
/* MATLAB Function: '<S2>/MAX POSITION1' incorporates:
* Inport: '<Root>/in_Act_Stall_Slave_Ch0'
*/
MAXPOSITION1(rtU.in_Act_Stall_Slave_Ch0, rtb_y_b);
/* End of Outputs for SubSystem: '<Root>/Check Stall Min' */
break;
case 6:
/* Outputs for IfAction SubSystem: '<Root>/Initial CPOS Max' incorporates:
* ActionPort: '<S5>/Action Port'
*/
/* If: '<S5>/If1' incorporates:
* Inport: '<Root>/in_Busy_Ch0'
* Inport: '<Root>/in_Error_Connect_Ch0'
*/
if ((rtU.in_Busy_Ch0 == 0) && (rtU.in_Error_Connect_Ch0 == 0)) {
/* Outputs for IfAction SubSystem: '<S5>/If Action Subsystem2' incorporates:
* ActionPort: '<S24>/Action Port'
*/
for (i = 0; i < 9; i++) {
/* DataStoreWrite: '<S24>/Data Store Write' */
rtDW.pos_loc[i] = 1U;
/* DataStoreWrite: '<S24>/Data Store Write1' */
rtDW.com_loc[i] = 2U;
}
/* MATLAB Function: '<S24>/Initial CPOS Max' */
/* : y = step; */
/* : fprintf('SIMULINK Initial CPOS Max - 1\n'); */
printf("SIMULINK Initial CPOS Max - 1\n");
fflush(stdout);
/* Merge: '<Root>/Merge' incorporates:
* Constant: '<S24>/Constant'
* SignalConversion generated from: '<S24>/step'
* Sum: '<S24>/step inc'
*/
rtB.Merge = (int8_t)(rtDW.UnitDelay_DSTATE + 1);
/* End of Outputs for SubSystem: '<S5>/If Action Subsystem2' */
} else {
/* Outputs for IfAction SubSystem: '<S5>/If Action Subsystem3' incorporates:
* ActionPort: '<S25>/Action Port'
*/
IfActionSubsystem3(rtDW.UnitDelay_DSTATE, &rtB.Merge, rtDW.com_loc);
/* End of Outputs for SubSystem: '<S5>/If Action Subsystem3' */
}
/* End of If: '<S5>/If1' */
/* End of Outputs for SubSystem: '<Root>/Initial CPOS Max' */
break;
case 7:
/* Outputs for IfAction SubSystem: '<Root>/Move to position Max' incorporates:
* ActionPort: '<S7>/Action Port'
*/
/* If: '<S7>/If1' incorporates:
* Inport: '<Root>/in_Busy_Ch0'
* Inport: '<Root>/in_Error_Connect_Ch0'
*/
if ((rtU.in_Busy_Ch0 == 0) && (rtU.in_Error_Connect_Ch0 == 0)) {
/* Outputs for IfAction SubSystem: '<S7>/If Action Subsystem2' incorporates:
* ActionPort: '<S30>/Action Port'
*/
for (i = 0; i < 9; i++) {
/* DataStoreWrite: '<S30>/Data Store Write1' */
rtDW.stall_set_loc[i] = 1U;
/* DataStoreWrite: '<S30>/Data Store Write3' incorporates:
* Constant: '<S30>/Constant2'
*/
rtDW.lnoise_set_loc[i] = 0U;
/* DataStoreWrite: '<S30>/Data Store Write2' */
rtDW.com_loc[i] = 3U;
/* DataStoreWrite: '<S30>/Data Store Write4' incorporates:
* Constant: '<S30>/Constant4'
*/
rtDW.autos_set_loc[i] = 0U;
/* DataStoreWrite: '<S30>/Data Store Write5' incorporates:
* Constant: '<S30>/Constant5'
*/
rtDW.speed_set_loc[i] = 0U;
/* DataStoreWrite: '<S30>/Data Store Write6' incorporates:
* Constant: '<S30>/Constant6'
*/
rtDW.coils_stop_set_loc[i] = 0U;
/* DataStoreWrite: '<S30>/Data Store Write' */
rtDW.pos_loc[i] = 6000U;
}
/* MATLAB Function: '<S30>/Move to position Max' */
/* : y = step; */
/* : fprintf('SIMULINK Move to position Max - 6000\n'); */
printf("SIMULINK Move to position Max - 6000\n");
fflush(stdout);
/* Merge: '<Root>/Merge' incorporates:
* Constant: '<S30>/Constant'
* SignalConversion generated from: '<S30>/step'
* Sum: '<S30>/step inc'
*/
rtB.Merge = (int8_t)(rtDW.UnitDelay_DSTATE + 1);
/* End of Outputs for SubSystem: '<S7>/If Action Subsystem2' */
} else {
/* Outputs for IfAction SubSystem: '<S7>/If Action Subsystem3' incorporates:
* ActionPort: '<S31>/Action Port'
*/
IfActionSubsystem3(rtDW.UnitDelay_DSTATE, &rtB.Merge, rtDW.com_loc);
/* End of Outputs for SubSystem: '<S7>/If Action Subsystem3' */
}
/* End of If: '<S7>/If1' */
/* End of Outputs for SubSystem: '<Root>/Move to position Max' */
break;
case 8:
/* Outputs for IfAction SubSystem: '<Root>/Check Stall Max' incorporates:
* ActionPort: '<S1>/Action Port'
*/
/* RelationalOperator: '<S1>/Relational Operator1' incorporates:
* DataStoreWrite: '<Root>/Data Store Write4'
* Inport: '<Root>/in_Act_Stall_Slave_Ch0'
*/
for (i = 0; i < 9; i++) {
rtb_RelationalOperator_j[i] = (rtU.in_Act_Stall_Slave_Ch0[i] == 1);
}
/* End of RelationalOperator: '<S1>/Relational Operator1' */
/* Logic: '<S1>/Logical Operator2' */
tmp = rtb_RelationalOperator_j[0];
for (i = 0; i < 8; i++) {
tmp = (tmp || rtb_RelationalOperator_j[i + 1]);
}
/* RelationalOperator: '<S1>/Relational Operator' incorporates:
* DataStoreWrite: '<Root>/Data Store Write1'
* Inport: '<Root>/in_CPOS_ALL_Ch0'
*/
for (i = 0; i < 9; i++) {
rtb_RelationalOperator_j[i] = (rtU.in_CPOS_ALL_Ch0[i] == 6000);
}
/* End of RelationalOperator: '<S1>/Relational Operator' */
/* Logic: '<S1>/Logical Operator1' */
tmp_0 = rtb_RelationalOperator_j[0];
for (i = 0; i < 8; i++) {
tmp_0 = (tmp_0 || rtb_RelationalOperator_j[i + 1]);
}
/* If: '<S1>/If2' incorporates:
* DataTypeConversion: '<S1>/Data Type Conversion'
* DataTypeConversion: '<S1>/Data Type Conversion1'
* Inport: '<Root>/in_Busy_Ch0'
* Inport: '<Root>/in_Error_Connect_Ch0'
* Logic: '<S1>/Logical Operator'
* Logic: '<S1>/Logical Operator1'
* Logic: '<S1>/Logical Operator2'
*/
if ((rtU.in_Busy_Ch0 == 0) && (rtU.in_Error_Connect_Ch0 == 0) && (tmp ||
tmp_0)) {
/* Outputs for IfAction SubSystem: '<S1>/If Action Subsystem2' incorporates:
* ActionPort: '<S12>/Action Port'
*/
/* DataStoreWrite: '<S12>/Data Store Write1' incorporates:
* DataStoreWrite: '<Root>/Data Store Write1'
* Inport: '<Root>/in_CPOS_ALL_Ch0'
*/
for (i = 0; i < 9; i++) {
rtDW.Max_position_Ch0[i] = rtU.in_CPOS_ALL_Ch0[i];
}
/* End of DataStoreWrite: '<S12>/Data Store Write1' */
/* Merge: '<Root>/Merge' incorporates:
* Constant: '<S12>/Constant'
* Sum: '<S12>/step inc'
*/
rtB.Merge = (int8_t)(rtDW.UnitDelay_DSTATE + 1);
/* MATLAB Function: '<S12>/MIN POSITION' incorporates:
* DataStoreWrite: '<Root>/Data Store Write1'
* Inport: '<Root>/in_CPOS_ALL_Ch0'
*/
/* : y = step; */
/* : fprintf('SIMULINK Max_position_Ch0 '); */
printf("SIMULINK Max_position_Ch0 ");
fflush(stdout);
/* : for i = 1:numel(step) */
for (i = 0; i < 9; i++) {
/* : fprintf('%d ', int16(step(i))); */
printf("%d ", rtU.in_CPOS_ALL_Ch0[i]);
fflush(stdout);
}
/* : fprintf('\n'); */
printf("\n");
fflush(stdout);
/* End of MATLAB Function: '<S12>/MIN POSITION' */
/* End of Outputs for SubSystem: '<S1>/If Action Subsystem2' */
} else {
/* Outputs for IfAction SubSystem: '<S1>/If Action Subsystem3' incorporates:
* ActionPort: '<S13>/Action Port'
*/
IfActionSubsystem3(rtDW.UnitDelay_DSTATE, &rtB.Merge, rtDW.com_loc);
/* End of Outputs for SubSystem: '<S1>/If Action Subsystem3' */
}
/* End of If: '<S1>/If2' */
/* MATLAB Function: '<S1>/MAX POSITION' incorporates:
* Inport: '<Root>/in_CPOS_ALL_Ch0'
*/
MAXPOSITION(rtU.in_CPOS_ALL_Ch0, rtb_y_ff);
/* MATLAB Function: '<S1>/MAX POSITION1' incorporates:
* Inport: '<Root>/in_Act_Stall_Slave_Ch0'
*/
MAXPOSITION1(rtU.in_Act_Stall_Slave_Ch0, rtb_y_b);
/* End of Outputs for SubSystem: '<Root>/Check Stall Max' */
break;
case 9:
/* Outputs for IfAction SubSystem: '<Root>/Homing' incorporates:
* ActionPort: '<S3>/Action Port'
*/
/* DataStoreWrite: '<S3>/Data Store Write3' */
for (i = 0; i < 9; i++) {
rtDW.com_loc[i] = 0U;
}
/* End of DataStoreWrite: '<S3>/Data Store Write3' */
/* Merge: '<Root>/Merge' incorporates:
* Constant: '<S3>/Constant2'
* SignalConversion generated from: '<S3>/step'
*/
rtB.Merge = 1;
/* MATLAB Function: '<S3>/MAX POSITION' incorporates:
* DataStoreRead: '<S3>/Data Store Read2'
*/
/* : y = step; */
/* : fprintf('SIMULINK MAX POSITION '); */
printf("SIMULINK MAX POSITION ");
fflush(stdout);
/* : for i = 1:numel(step) */
for (i = 0; i < 9; i++) {
/* : fprintf('%d ', int16(step(i))); */
printf("%d ", rtDW.Max_position_Ch0[i]);
fflush(stdout);
}
/* : fprintf('\n'); */
printf("\n");
fflush(stdout);
/* End of MATLAB Function: '<S3>/MAX POSITION' */
/* MATLAB Function: '<S3>/MIN POSITION' incorporates:
* DataStoreRead: '<S3>/Data Store Read3'
*/
/* : y = step; */
/* : fprintf('SIMULINK MIN POSITION '); */
printf("SIMULINK MIN POSITION ");
fflush(stdout);
/* : for i = 1:numel(step) */
for (i = 0; i < 9; i++) {
/* : fprintf('%d ', int16(step(i))); */
printf("%d ", rtDW.Min_position_Ch0[i]);
fflush(stdout);
}
/* : fprintf('\n'); */
printf("\n");
fflush(stdout);
/* End of MATLAB Function: '<S3>/MIN POSITION' */
/* End of Outputs for SubSystem: '<Root>/Homing' */
break;
case 0:
/* Outputs for IfAction SubSystem: '<Root>/Homing1' incorporates:
* ActionPort: '<S4>/Action Port'
*/
/* Merge: '<Root>/Merge' incorporates:
* SignalConversion generated from: '<S4>/stepIn'
*/
rtB.Merge = rtDW.UnitDelay_DSTATE;
/* End of Outputs for SubSystem: '<Root>/Homing1' */
break;
}
/* End of SwitchCase: '<Root>/Switch Case' */
/* DataStoreWrite: '<Root>/Start write stepSig' incorporates:
* Constant: '<Root>/Constant1'
*/
rtDW.stepSig = 1;
/* BusCreator: '<S11>/Bus Creator' incorporates:
* DataStoreRead: '<S11>/Data Store Read1'
* DataStoreRead: '<S11>/Data Store Read2'
* DataStoreRead: '<S11>/Data Store Read3'
* DataStoreRead: '<S11>/Data Store Read4'
* DataStoreRead: '<S11>/Data Store Read5'
* DataStoreRead: '<S11>/Data Store Read6'
* DataStoreRead: '<S11>/Data Store Read7'
* DataStoreRead: '<S11>/Data Store Read8'
* DataStoreRead: '<S11>/Data Store Read9'
* DataStoreWrite: '<S11>/Data Store Write'
*/
for (i = 0; i < 9; i++) {
controllerData.POS[i] = rtDW.pos_loc[i];
controllerData.BUS_ADR[i] = rtDW.busAdr_loc[i];
controllerData.MODE[i] = rtDW.mode_loc[i];
controllerData.COM[i] = rtDW.com_loc[i];
controllerData.Stall_SET[i] = rtDW.stall_set_loc[i];
controllerData.Lnoise_SET[i] = rtDW.lnoise_set_loc[i];
controllerData.Autos_SET[i] = rtDW.autos_set_loc[i];
controllerData.Speed_SET[i] = rtDW.speed_set_loc[i];
controllerData.Coils_Stop_SET[i] = rtDW.coils_stop_set_loc[i];
}
/* End of BusCreator: '<S11>/Bus Creator' */
/* Outport: '<Root>/Out1' incorporates:
* DataStoreRead: '<Root>/Data Store Read10'
*/
rtY.Out1 = controllerData;
/* Update for Switch: '<Root>/Switch' incorporates:
* UnitDelay: '<Root>/Unit Delay'
*/
rtDW.UnitDelay_DSTATE = rtB.Merge;
}
/* Model initialize function */
void Model_actuator_initialize(void)
{
/* (no initialization code required) */
}
/* Model terminate function */
void Model_actuator_terminate(void)
{
/* (no terminate code required) */
}
/*
* File trailer for generated code.
*
* [EOF]
*/