diff --git a/emBODY/eBcode/arch-arm/board/amcbldc/application/proj/amcbldc-application2.uvoptx b/emBODY/eBcode/arch-arm/board/amcbldc/application/proj/amcbldc-application2.uvoptx
index f4d23d0f5..b329986a8 100644
--- a/emBODY/eBcode/arch-arm/board/amcbldc/application/proj/amcbldc-application2.uvoptx
+++ b/emBODY/eBcode/arch-arm/board/amcbldc/application/proj/amcbldc-application2.uvoptx
@@ -1352,7 +1352,7 @@
mbd
- 0
+ 1
0
0
0
@@ -1488,6 +1488,18 @@
0
0
+
+ 18
+ 75
+ 8
+ 0
+ 0
+ 0
+ ..\..\..\..\mbd\amcbldc\sharedutils\rt_hypotf.cpp
+ rt_hypotf.cpp
+ 0
+ 0
+
@@ -1498,7 +1510,7 @@
0
19
- 75
+ 76
8
0
0
@@ -1518,7 +1530,7 @@
0
20
- 76
+ 77
8
0
0
@@ -1531,23 +1543,11 @@
- mbd::supervisor-rx
+ mbd::supervisor
0
0
0
0
-
- 21
- 77
- 8
- 0
- 0
- 0
- ..\..\..\..\mbd\amcbldc\supervisor-rx\SupervisorFSM_RX.cpp
- SupervisorFSM_RX.cpp
- 0
- 0
-
21
78
@@ -1555,8 +1555,8 @@
0
0
0
- ..\..\..\..\mbd\amcbldc\supervisor-rx\SupervisorFSM_RX_data.cpp
- SupervisorFSM_RX_data.cpp
+ ..\..\..\..\mbd\amcbldc\supervisor\supervisor.cpp
+ supervisor.cpp
0
0
@@ -1632,18 +1632,6 @@
0
0
-
- 24
- 83
- 8
- 0
- 0
- 0
- ..\..\..\..\mbd\amcbldc\control-foc\control_foc_data.cpp
- control_foc_data.cpp
- 0
- 0
-
@@ -1654,7 +1642,7 @@
0
25
- 84
+ 83
8
0
0
@@ -1674,7 +1662,7 @@
0
26
- 85
+ 84
8
0
0
@@ -1694,7 +1682,7 @@
0
27
- 86
+ 85
8
0
0
@@ -1706,6 +1694,38 @@
+
+ mbd::motion-controller
+ 0
+ 0
+ 0
+ 0
+
+ 28
+ 86
+ 8
+ 0
+ 0
+ 0
+ ..\..\..\..\mbd\amcbldc\motion-controller\motion_controller.cpp
+ motion_controller.cpp
+ 0
+ 0
+
+
+ 28
+ 87
+ 8
+ 0
+ 0
+ 0
+ ..\..\..\..\mbd\amcbldc\motion-controller-single\motion_controller_single.cpp
+ motion_controller_single.cpp
+ 0
+ 0
+
+
+
::CMSIS
0
diff --git a/emBODY/eBcode/arch-arm/board/amcbldc/application/proj/amcbldc-application2.uvprojx b/emBODY/eBcode/arch-arm/board/amcbldc/application/proj/amcbldc-application2.uvprojx
index dfd920a9b..d68919186 100644
--- a/emBODY/eBcode/arch-arm/board/amcbldc/application/proj/amcbldc-application2.uvprojx
+++ b/emBODY/eBcode/arch-arm/board/amcbldc/application/proj/amcbldc-application2.uvprojx
@@ -340,7 +340,7 @@
-Wno-pragma-pack -Wno-deprecated-register -DEMBOT_USE_rtos_osal -DEMBOT_AMCBLDC_APP05
USE_STM32HAL STM32HAL_BOARD_AMCBLDC STM32HAL_DRIVER_V122
- ..\..\bsp;..\..\..\..\libs\highlevel\abslayer\osal\api;..\..\..\..\libs\midware\eventviewer\api;..\..\..\..\libs\lowlevel\stm32hal\api;..\..\..\..\embot\app;..\..\..\..\embot\i2h;..\..\..\..\embot\hw;..\..\..\..\embot\os;..\..\..\..\embot;..\..\..\..\embot\app\dsp;..\..\..\..\embot\app\skeleton;..\..\..\..\embot\prot\can;..\..\..\..\..\..\..\..\icub-firmware-shared\can\canProtocolLib;..\..\..\..\..\..\..\..\icub-firmware-shared\embot\core;..\..\..\..\..\..\..\..\icub-firmware-shared\embot\tools;..\..\..\..\libs\lowlevel\cmsis\dsp\v160\Include;..\..\..\..\libs\highlevel\abslayer\hal2\api;..\src\motorhal2;..\..\..\..\mbd\amcbldc\sharedutils;..\..\..\..\mbd\amcbldc\can-decoder;..\..\..\..\mbd\amcbldc\can-raw2struct;..\..\..\..\mbd\amcbldc\supervisor-rx;..\..\..\..\mbd\amcbldc\supervisor-tx;..\..\..\..\mbd\amcbldc\can-encoder;..\..\..\..\mbd\amcbldc\control-outer;..\..\..\..\mbd\amcbldc\control-foc;..\..\..\..\mbd\amcbldc\estimator;..\..\..\..\mbd\amcbldc\amc-bldc;..\..\..\..\mbd\amcbldc\filter-current;..\..\..\..\embot\app\bldc;..\src\app-board-amcbldc
+ ..\..\bsp;..\..\..\..\libs\highlevel\abslayer\osal\api;..\..\..\..\libs\midware\eventviewer\api;..\..\..\..\libs\lowlevel\stm32hal\api;..\..\..\..\embot\app;..\..\..\..\embot\i2h;..\..\..\..\embot\hw;..\..\..\..\embot\os;..\..\..\..\embot;..\..\..\..\embot\app\dsp;..\..\..\..\embot\app\skeleton;..\..\..\..\embot\prot\can;..\..\..\..\..\..\..\..\icub-firmware-shared\can\canProtocolLib;..\..\..\..\..\..\..\..\icub-firmware-shared\embot\core;..\..\..\..\..\..\..\..\icub-firmware-shared\embot\tools;..\..\..\..\libs\lowlevel\cmsis\dsp\v160\Include;..\..\..\..\libs\highlevel\abslayer\hal2\api;..\src\motorhal2;..\..\..\..\mbd\amcbldc\sharedutils;..\..\..\..\mbd\amcbldc\can-decoder;..\..\..\..\mbd\amcbldc\can-raw2struct;..\..\..\..\mbd\amcbldc\supervisor;..\..\..\..\mbd\amcbldc\supervisor-tx;..\..\..\..\mbd\amcbldc\can-encoder;..\..\..\..\mbd\amcbldc\control-outer;..\..\..\..\mbd\amcbldc\control-foc;..\..\..\..\mbd\amcbldc\estimator;..\..\..\..\mbd\amcbldc\amc-bldc;..\..\..\..\mbd\amcbldc\filter-current;..\..\..\..\mbd\amcbldc\motion-controller;..\..\..\..\mbd\amcbldc\motion-controller-single;..\..\..\..\embot\app\bldc;..\src\app-board-amcbldc
@@ -1167,6 +1167,11 @@
8
..\..\..\..\mbd\amcbldc\sharedutils\uMultiWordShl.cpp
+
+ rt_hypotf.cpp
+ 8
+ ..\..\..\..\mbd\amcbldc\sharedutils\rt_hypotf.cpp
+
@@ -1190,17 +1195,12 @@
- mbd::supervisor-rx
+ mbd::supervisor
- SupervisorFSM_RX.cpp
- 8
- ..\..\..\..\mbd\amcbldc\supervisor-rx\SupervisorFSM_RX.cpp
-
-
- SupervisorFSM_RX_data.cpp
+ supervisor.cpp
8
- ..\..\..\..\mbd\amcbldc\supervisor-rx\SupervisorFSM_RX_data.cpp
+ ..\..\..\..\mbd\amcbldc\supervisor\supervisor.cpp
@@ -1306,11 +1306,6 @@
8
..\..\..\..\mbd\amcbldc\control-foc\FOCInnerLoop.cpp
-
- control_foc_data.cpp
- 8
- ..\..\..\..\mbd\amcbldc\control-foc\control_foc_data.cpp
-
@@ -1343,6 +1338,21 @@
+
+ mbd::motion-controller
+
+
+ motion_controller.cpp
+ 8
+ ..\..\..\..\mbd\amcbldc\motion-controller\motion_controller.cpp
+
+
+ motion_controller_single.cpp
+ 8
+ ..\..\..\..\mbd\amcbldc\motion-controller-single\motion_controller_single.cpp
+
+
+
::CMSIS
@@ -2509,6 +2519,11 @@
8
..\..\..\..\mbd\amcbldc\sharedutils\uMultiWordShl.cpp
+
+ rt_hypotf.cpp
+ 8
+ ..\..\..\..\mbd\amcbldc\sharedutils\rt_hypotf.cpp
+
@@ -2532,17 +2547,12 @@
- mbd::supervisor-rx
+ mbd::supervisor
- SupervisorFSM_RX.cpp
- 8
- ..\..\..\..\mbd\amcbldc\supervisor-rx\SupervisorFSM_RX.cpp
-
-
- SupervisorFSM_RX_data.cpp
+ supervisor.cpp
8
- ..\..\..\..\mbd\amcbldc\supervisor-rx\SupervisorFSM_RX_data.cpp
+ ..\..\..\..\mbd\amcbldc\supervisor\supervisor.cpp
@@ -2579,11 +2589,6 @@
8
..\..\..\..\mbd\amcbldc\control-foc\FOCInnerLoop.cpp
-
- control_foc_data.cpp
- 8
- ..\..\..\..\mbd\amcbldc\control-foc\control_foc_data.cpp
-
@@ -2616,6 +2621,21 @@
+
+ mbd::motion-controller
+
+
+ motion_controller.cpp
+ 8
+ ..\..\..\..\mbd\amcbldc\motion-controller\motion_controller.cpp
+
+
+ motion_controller_single.cpp
+ 8
+ ..\..\..\..\mbd\amcbldc\motion-controller-single\motion_controller_single.cpp
+
+
+
::CMSIS
diff --git a/emBODY/eBcode/arch-arm/board/amcbldc/application/src/app-board-amcbldc/embot_app_board_amcbldc_theMBD.cpp b/emBODY/eBcode/arch-arm/board/amcbldc/application/src/app-board-amcbldc/embot_app_board_amcbldc_theMBD.cpp
index ca07d796e..fa14d1928 100644
--- a/emBODY/eBcode/arch-arm/board/amcbldc/application/src/app-board-amcbldc/embot_app_board_amcbldc_theMBD.cpp
+++ b/emBODY/eBcode/arch-arm/board/amcbldc/application/src/app-board-amcbldc/embot_app_board_amcbldc_theMBD.cpp
@@ -450,7 +450,7 @@ bool embot::app::board::amcbldc::theMBD::Impl::tick(const std::vector(electricalAngle)*0.0054931640625f; // (60 interval angle)
@@ -549,13 +549,13 @@ void embot::app::board::amcbldc::theMBD::Impl::onCurrents_FOC_innerloop(void *ow
// -----------------------------------------------------------------------------
- AMC_BLDC_U.SensorsData_p.jointpositions.position = static_cast(position) * 0.0054931640625f; // iCubDegree -> deg
+ AMC_BLDC_U.SensorsData_p.jointpositions = static_cast(position) * 0.0054931640625f; // iCubDegree -> deg
// Set the voltages
embot::hw::motor::PWMperc pwmperc
{
- AMC_BLDC_Y.ControlOutputs_p.Vabc[0], AMC_BLDC_Y.ControlOutputs_p.Vabc[1], AMC_BLDC_Y.ControlOutputs_p.Vabc[2]
+ AMC_BLDC_Y.ControlOutputs.Vabc[0], AMC_BLDC_Y.ControlOutputs.Vabc[1], AMC_BLDC_Y.ControlOutputs.Vabc[2]
};
embot::hw::motor::setPWM(embot::hw::MOTOR::one, pwmperc);
diff --git a/emBODY/eBcode/arch-arm/mbd/amcbldc/amc-bldc/AMC_BLDC.cpp b/emBODY/eBcode/arch-arm/mbd/amcbldc/amc-bldc/AMC_BLDC.cpp
index e728fdf3c..68dd9a402 100644
--- a/emBODY/eBcode/arch-arm/mbd/amcbldc/amc-bldc/AMC_BLDC.cpp
+++ b/emBODY/eBcode/arch-arm/mbd/amcbldc/amc-bldc/AMC_BLDC.cpp
@@ -7,9 +7,9 @@
//
// Code generated for Simulink model 'AMC_BLDC'.
//
-// Model version : 7.13
+// Model version : 7.54
// Simulink Coder version : 23.2 (R2023b) 01-Aug-2023
-// C/C++ source code generated on : Tue Feb 13 11:55:25 2024
+// C/C++ source code generated on : Wed Feb 28 11:29:48 2024
//
// Target selection: ert.tlc
// Embedded hardware selection: ARM Compatible->ARM Cortex-M
@@ -20,26 +20,73 @@
#include "rtw_mutex.h"
#include "rtwtypes.h"
#include "AMC_BLDC_types.h"
-#include "control_foc.h"
-#include "estimation_velocity.h"
-#include "filter_current.h"
#include "can_decoder.h"
-#include "SupervisorFSM_RX.h"
#include "SupervisorFSM_TX.h"
#include "can_encoder.h"
-#include "control_outer.h"
+#include "motion_controller_single.h"
+#include "mc_supervisor_defines.h"
// Exported block parameters
-ConfigurationParameters InitConfParams = {
+ActuatorConfiguration InitConfParams = {
+ {
+ 40000.0F,
+ 0.35F,
+ 0.7F,
+ 1.0F,
+ 0U,
+ 0.0F
+ },
+
+ {
+ {
+ ControlModes_Current,
+ 0.0F,
+ 0.0F,
+ 2.0F,
+ 500.0F,
+ 0.0F,
+ 10.0F,
+ 0.0F,
+ 0.0F,
+ 0U
+ },
+
+ {
+ ControlModes_Velocity,
+ 0.0F,
+ 0.0F,
+ -3.0e-5F,
+ -3.0e-5F,
+ 0.0F,
+ 10.0F,
+ 0.0F,
+ 0.0F,
+ 0U
+ },
+
+ {
+ ControlModes_Position,
+ 0.0F,
+ 0.0F,
+ 0.0F,
+ 0.0F,
+ 0.0F,
+ 0.0F,
+ 0.0F,
+ 0.0F,
+ 0U
+ }
+ },
+
{
- 30.0F,
- true,
true,
false,
false,
- true,
false,
- 16000,
+ false,
+ false,
+ 0,
+ 0,
0,
0U,
7U,
@@ -48,97 +95,28 @@ ConfigurationParameters InitConfParams = {
0.0F,
0.0F,
24.0F,
+ 44.0F,
25.9F,
271.0F,
16.0F,
797.5F
- },
-
- {
- EstimationVelocityModes_MovingAverage,
- 0.9995F
- },
-
- {
- 0.0F,
- 0.0F,
- 2.0F,
- 500.0F,
- 0.0F,
- 10.0F,
- 0.0F,
- 0.0F,
- 0U
- },
-
- {
- 0.0F,
- 0.0F,
- 0.0F,
- 0.0F,
- 0.0F,
- 0.0F,
- 0.0F,
- 0.0F,
- 0U
- },
-
- {
- 0.0F,
- 0.0F,
- -3.0e-5F,
- -3.0e-5F,
- 0.0F,
- 10.0F,
- 0.0F,
- 0.0F,
- 0U
- },
-
- {
- 0.0F,
- 0.0F,
- 0.0F,
- 0.0F,
- 0.0F,
- 0.0F,
- 0.0F,
- 0.0F,
- 0U
- },
-
- {
- 1.0F,
- 359.0F,
- 0.0F,
- 360.0F,
- 0.0F,
- 0.0F,
- 40000.0F,
- 10U,
- 2.0F,
- 5.0F,
- 10.0F,
- 32000U,
- 70.0F
- },
- 25.0F
+ }
} ; // Variable: InitConfParams
- // Referenced by: '/SupervisorFSM_RX'
+ // Referenced by: '/Motion Controller Single'
real32_T CAN_ANGLE_DEG2ICUB = 182.044449F;// Variable: CAN_ANGLE_DEG2ICUB
- // Referenced by: '/CAN_Encoder'
+ // Referenced by: '/CAN_Encoder'
// 2^16/360
real32_T CAN_ANGLE_ICUB2DEG = 0.00549316406F;// Variable: CAN_ANGLE_ICUB2DEG
- // Referenced by: '/CAN_Decoder'
+ // Referenced by: '/CAN_Decoder'
// 360/2^16
uint8_T CAN_ID_AMC = 3U; // Variable: CAN_ID_AMC
// Referenced by:
- // '/CAN_Decoder'
- // '/CAN_Encoder'
+ // '/CAN_Decoder'
+ // '/CAN_Encoder'
// 4 bits defining the ID of the AMC_BLDC board.
@@ -159,170 +137,35 @@ RT_MODEL_AMC_BLDC_T AMC_BLDC_M_ = RT_MODEL_AMC_BLDC_T();
RT_MODEL_AMC_BLDC_T *const AMC_BLDC_M = &AMC_BLDC_M_;
// Model step function for TID0
-void AMC_BLDC_step0(void) // Sample time: [5.0E-6s, 0.0s]
+void AMC_BLDC_step0(void) // Sample time: [1.1428571428571438E-6s, 0.0s]
{
- // (no output/update code required)
+ // ModelReference: '/Motion Controller Single'
+ mc_base_tick();
}
// Model step function for TID1
-void AMC_BLDC_step_FOC(void) // Sample time: [4.5E-5s, 0.0s]
+void AMC_BLDC_step_FOC(void) // Sample time: [3.65714285714286E-5s, 0.0s]
{
int8_T wrBufIdx;
- // RateTransition generated from: '/Adapter1' incorporates:
- // BusCreator: '/Bus Creator1'
- // Constant: '/Constant'
-
- rtw_mutex_lock();
- wrBufIdx = static_cast
- (AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0_LstB +
- 1);
- if (wrBufIdx == 3) {
- wrBufIdx = 0;
- }
-
- if (wrBufIdx ==
- AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0_RDBu)
- {
- wrBufIdx = static_cast(wrBufIdx + 1);
- if (wrBufIdx == 3) {
- wrBufIdx = 0;
- }
- }
-
- rtw_mutex_unlock();
- switch (wrBufIdx) {
- case 0:
- AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0_Bu_d.temperature
- = 0.0F;
- break;
-
- case 1:
- AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0_Bu_j.temperature
- = 0.0F;
- break;
-
- case 2:
- AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0_Bu_o.temperature
- = 0.0F;
- break;
- }
-
- AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0_LstB =
- wrBufIdx;
-
- // End of RateTransition generated from: '/Adapter1'
-
- // RateTransition generated from: '/Adapter2'
- rtw_mutex_lock();
- AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_1_RD =
- AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_1_Ls;
- rtw_mutex_unlock();
- AMC_BLDC_B.BusConversion_InsertedFor_FOC_at_inport_1_BusCreator1.flags =
- AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_1_Bu[AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_1_RD];
-
- // RateTransition generated from: '/Adapter2'
- rtw_mutex_lock();
- AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_2_RD =
- AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_2_Ls;
- rtw_mutex_unlock();
- AMC_BLDC_B.BusConversion_InsertedFor_FOC_at_inport_1_BusCreator1.configurationparameters
- =
- AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_2_Bu[AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_2_RD];
-
- // RateTransition generated from: '/Adapter2'
- rtw_mutex_lock();
- AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_3_RD =
- AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_3_Ls;
- rtw_mutex_unlock();
- AMC_BLDC_B.BusConversion_InsertedFor_FOC_at_inport_1_BusCreator1.estimateddata
- =
- AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_3_Bu[AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_3_RD];
-
- // RateTransition generated from: '/Adapter2'
- rtw_mutex_lock();
- AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_4_RD =
- AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_4_Ls;
- rtw_mutex_unlock();
- AMC_BLDC_B.BusConversion_InsertedFor_FOC_at_inport_1_BusCreator1.targets =
- AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_4_Bu[AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_4_RD];
-
- // RateTransition generated from: '/Adapter2'
- rtw_mutex_lock();
- AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_5_RD =
- AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_5_Ls;
- rtw_mutex_unlock();
- AMC_BLDC_B.BusConversion_InsertedFor_FOC_at_inport_1_BusCreator1.controlouteroutputs
- =
- AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_5_Bu[AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_5_RD];
-
- // ModelReference: '/FOC' incorporates:
- // Inport generated from: '/In Bus Element5'
+ // ModelReference: '/Motion Controller Single' incorporates:
+ // Inport generated from: '/In Bus Element3'
// Outport generated from: '/Out Bus Element'
- control_foc(&AMC_BLDC_U.SensorsData_p,
- &AMC_BLDC_B.BusConversion_InsertedFor_FOC_at_inport_1_BusCreator1,
- &AMC_BLDC_Y.ControlOutputs_p, &(AMC_BLDC_DW.FOC_InstanceData.rtb),
- &(AMC_BLDC_DW.FOC_InstanceData.rtdw),
- &(AMC_BLDC_DW.FOC_InstanceData.rtzce));
+ mc_foc_tick(&AMC_BLDC_U.SensorsData_p, &AMC_BLDC_Y.ControlOutputs,
+ &(AMC_BLDC_DW.MotionControllerSingle_InstanceData.rtdw));
- // RateTransition generated from: '/Adapter1' incorporates:
+ // RateTransition generated from: '/SupervisorFSM_TX' incorporates:
// Outport generated from: '/Out Bus Element'
rtw_mutex_lock();
wrBufIdx = static_cast
- (AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0_Ls_j +
- 1);
- if (wrBufIdx == 3) {
- wrBufIdx = 0;
- }
-
- if (wrBufIdx ==
- AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0_RD_a)
- {
- wrBufIdx = static_cast(wrBufIdx + 1);
- if (wrBufIdx == 3) {
- wrBufIdx = 0;
- }
- }
-
- rtw_mutex_unlock();
- switch (wrBufIdx) {
- case 0:
- AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0_Buf0 =
- AMC_BLDC_Y.ControlOutputs_p;
- break;
-
- case 1:
- AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0_Buf1 =
- AMC_BLDC_Y.ControlOutputs_p;
- break;
-
- case 2:
- AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0_Buf2 =
- AMC_BLDC_Y.ControlOutputs_p;
- break;
- }
-
- AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0_Ls_j =
- wrBufIdx;
-
- // End of RateTransition generated from: '/Adapter1'
-
- // RateTransition generated from: '/Adapter3' incorporates:
- // Inport generated from: '/In Bus Element5'
-
- rtw_mutex_lock();
- wrBufIdx = static_cast
- (AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0_LstB +
- 1);
+ (AMC_BLDC_DW.TmpRTBAtSupervisorFSM_TXInport4_LstBufWR + 1);
if (wrBufIdx == 3) {
wrBufIdx = 0;
}
- if (wrBufIdx ==
- AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0_RDBu)
- {
+ if (wrBufIdx == AMC_BLDC_DW.TmpRTBAtSupervisorFSM_TXInport4_RDBuf) {
wrBufIdx = static_cast(wrBufIdx + 1);
if (wrBufIdx == 3) {
wrBufIdx = 0;
@@ -332,445 +175,158 @@ void AMC_BLDC_step_FOC(void) // Sample time: [4.5E-5s, 0.0s]
rtw_mutex_unlock();
switch (wrBufIdx) {
case 0:
- AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0_Buf0 =
- AMC_BLDC_U.SensorsData_p;
+ AMC_BLDC_DW.TmpRTBAtSupervisorFSM_TXInport4_Buf0 = AMC_BLDC_Y.ControlOutputs;
break;
case 1:
- AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0_Buf1 =
- AMC_BLDC_U.SensorsData_p;
+ AMC_BLDC_DW.TmpRTBAtSupervisorFSM_TXInport4_Buf1 = AMC_BLDC_Y.ControlOutputs;
break;
case 2:
- AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0_Buf2 =
- AMC_BLDC_U.SensorsData_p;
+ AMC_BLDC_DW.TmpRTBAtSupervisorFSM_TXInport4_Buf2 = AMC_BLDC_Y.ControlOutputs;
break;
}
- AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0_LstB =
- wrBufIdx;
+ AMC_BLDC_DW.TmpRTBAtSupervisorFSM_TXInport4_LstBufWR = wrBufIdx;
- // End of RateTransition generated from: '/Adapter3'
+ // End of RateTransition generated from: '/SupervisorFSM_TX'
}
// Model step function for TID2
void AMC_BLDC_step_Time_1ms(void) // Sample time: [0.001s, 0.0s]
{
// local block i/o variables
- Targets rtb_SupervisorFSM_RX_o2;
- ControlOuterOutputs rtb_OuterControl;
+ BUS_CAN_RX_ERRORS_MULTIPLE rtb_CAN_Decoder_o2;
BUS_STATUS_TX rtb_SupervisorFSM_TX_o2;
- int8_T wrBufIdx;
-
- // UnitDelay generated from: '/Adapter4'
- AMC_BLDC_B.ZOHBlockInsertedForAdapter_InsertedFor_Adapter4_at_outport_0 =
- AMC_BLDC_DW.ZOHBlockInsertedForAdapter_InsertedFor_Adapter4_at_outport_0;
-
- // RateTransition generated from: '/Adapter3'
- rtw_mutex_lock();
- AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0_RDBu =
- AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0_LstB;
- rtw_mutex_unlock();
- switch
- (AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0_RDBu) {
- case 0:
- // RateTransition generated from: '/Adapter3'
- AMC_BLDC_B.RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0 =
- AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0_Buf0;
- break;
-
- case 1:
- // RateTransition generated from: '/Adapter3'
- AMC_BLDC_B.RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0 =
- AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0_Buf1;
- break;
-
- case 2:
- // RateTransition generated from: '/Adapter3'
- AMC_BLDC_B.RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0 =
- AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0_Buf2;
- break;
- }
+ FOCOutputs rtb_TmpRTBAtSupervisorFSM_TXInport4;
- // End of RateTransition generated from: '/Adapter3'
+ // UnitDelay generated from: '/Adapter'
+ AMC_BLDC_B.ZOHBlockInsertedForAdapter_InsertedFor_Adapter_at_outport_0 =
+ AMC_BLDC_DW.ZOHBlockInsertedForAdapter_InsertedFor_Adapter_at_outport_0_;
- // ModelReference: '/Estimation_Velocity'
- estimation_velocity
- (&AMC_BLDC_B.RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0,
- &AMC_BLDC_B.ZOHBlockInsertedForAdapter_InsertedFor_Adapter4_at_outport_0,
- &AMC_BLDC_Y.EstimatedData_p.jointvelocities,
- &(AMC_BLDC_DW.Estimation_Velocity_InstanceData.rtdw));
-
- // RateTransition generated from: '/Adapter1'
- rtw_mutex_lock();
- AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0_RD_a =
- AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0_Ls_j;
- rtw_mutex_unlock();
- switch
- (AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0_RD_a) {
- case 0:
- // RateTransition generated from: '/Adapter1'
- AMC_BLDC_B.RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0 =
- AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0_Buf0;
- break;
-
- case 1:
- // RateTransition generated from: '/Adapter1'
- AMC_BLDC_B.RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0 =
- AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0_Buf1;
- break;
+ // ModelReference: '/CAN_Decoder' incorporates:
+ // Inport generated from: '/In Bus Element2'
- case 2:
- // RateTransition generated from: '/Adapter1'
- AMC_BLDC_B.RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0 =
- AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0_Buf2;
- break;
- }
+ can_decoder(&AMC_BLDC_U.PacketsRx,
+ &AMC_BLDC_B.ZOHBlockInsertedForAdapter_InsertedFor_Adapter_at_outport_0,
+ &AMC_BLDC_B.CAN_Decoder_o1[0], &rtb_CAN_Decoder_o2,
+ &(AMC_BLDC_DW.CAN_Decoder_InstanceData.rtb),
+ &(AMC_BLDC_DW.CAN_Decoder_InstanceData.rtdw));
- // End of RateTransition generated from: '/Adapter1'
+ // ModelReference: '/Motion Controller Single' incorporates:
+ // Inport generated from: '/In Bus Element4'
+ // Outport generated from: '/Out Bus Element3'
+ // Outport generated from: '/Out Bus Element2'
+ // Outport generated from: '/Out Bus Element4'
- // ModelReference: '/Filter_Current'
- filter_current
- (&AMC_BLDC_B.RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0,
- &AMC_BLDC_Y.EstimatedData_p.Iq_filtered,
- &(AMC_BLDC_DW.Filter_Current_InstanceData.rtdw));
+ mc_1ms_tick(&AMC_BLDC_B.CAN_Decoder_o1[0], &AMC_BLDC_U.ExternalFlags_p,
+ &AMC_BLDC_Y.EstimatedData_p, &AMC_BLDC_Y.Flags_p,
+ &AMC_BLDC_Y.ConfigurationParameters,
+ &(AMC_BLDC_DW.MotionControllerSingle_InstanceData.rtb),
+ &(AMC_BLDC_DW.MotionControllerSingle_InstanceData.rtdw));
- // RateTransition generated from: '/Adapter1'
+ // RateTransition generated from: '/SupervisorFSM_TX'
rtw_mutex_lock();
- AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0_RDBu =
- AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0_LstB;
+ AMC_BLDC_DW.TmpRTBAtSupervisorFSM_TXInport4_RDBuf =
+ AMC_BLDC_DW.TmpRTBAtSupervisorFSM_TXInport4_LstBufWR;
rtw_mutex_unlock();
- switch
- (AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0_RDBu) {
+ switch (AMC_BLDC_DW.TmpRTBAtSupervisorFSM_TXInport4_RDBuf) {
case 0:
- AMC_BLDC_Y.EstimatedData_p.motor_temperature =
- AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0_Bu_d;
+ rtb_TmpRTBAtSupervisorFSM_TXInport4 =
+ AMC_BLDC_DW.TmpRTBAtSupervisorFSM_TXInport4_Buf0;
break;
case 1:
- AMC_BLDC_Y.EstimatedData_p.motor_temperature =
- AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0_Bu_j;
+ rtb_TmpRTBAtSupervisorFSM_TXInport4 =
+ AMC_BLDC_DW.TmpRTBAtSupervisorFSM_TXInport4_Buf1;
break;
case 2:
- AMC_BLDC_Y.EstimatedData_p.motor_temperature =
- AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0_Bu_o;
+ rtb_TmpRTBAtSupervisorFSM_TXInport4 =
+ AMC_BLDC_DW.TmpRTBAtSupervisorFSM_TXInport4_Buf2;
break;
}
- // End of RateTransition generated from: '/Adapter1'
-
- // ModelReference: '/CAN_Decoder' incorporates:
- // Inport generated from: '/In Bus Element2'
-
- can_decoder(&AMC_BLDC_U.PacketsRx,
- &AMC_BLDC_B.ZOHBlockInsertedForAdapter_InsertedFor_Adapter4_at_outport_0,
- &AMC_BLDC_B.CAN_Decoder_o1, &AMC_BLDC_B.CAN_Decoder_o2,
- &AMC_BLDC_B.CAN_Decoder_o3);
+ // End of RateTransition generated from: '/SupervisorFSM_TX'
- // ModelReference: '/SupervisorFSM_RX' incorporates:
- // Inport generated from: '/In Bus Element'
- // Outport generated from: '/Out Bus Element3'
- // Outport generated from: '/Out Bus Element2'
- // Outport generated from: '/Out Bus Element4'
-
- SupervisorFSM_RX
- (&AMC_BLDC_B.RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0,
- &AMC_BLDC_U.ExternalFlags_p,
- &AMC_BLDC_B.RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0,
- &AMC_BLDC_B.CAN_Decoder_o1, &AMC_BLDC_Y.EstimatedData_p,
- &AMC_BLDC_B.CAN_Decoder_o2, &AMC_BLDC_B.CAN_Decoder_o3, &AMC_BLDC_Y.Flags_p,
- &rtb_SupervisorFSM_RX_o2, &AMC_BLDC_Y.ConfigurationParameters_p);
-
- // ModelReference: '/SupervisorFSM_TX' incorporates:
- // Outport generated from: '/Out Bus Element3'
+ // ModelReference generated from: '/SupervisorFSM_TX' incorporates:
+ // Inport generated from: '/In Bus Element4'
+ // Inport generated from: '/In Bus Element3'
// Outport generated from: '/Out Bus Element2'
// Outport generated from: '/Out Bus Element4'
- SupervisorFSM_TX
- (&AMC_BLDC_B.RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0,
- &AMC_BLDC_Y.EstimatedData_p, &AMC_BLDC_Y.Flags_p,
- &AMC_BLDC_B.RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0,
- &AMC_BLDC_B.MessagesTx, &rtb_SupervisorFSM_TX_o2);
+ SupervisorFSM_TX(&AMC_BLDC_U.SensorsData_p, &AMC_BLDC_Y.EstimatedData_p,
+ &AMC_BLDC_Y.Flags_p, &rtb_TmpRTBAtSupervisorFSM_TXInport4,
+ &AMC_BLDC_U.ExternalFlags_p.fault_button,
+ &AMC_BLDC_B.MessagesTx, &rtb_SupervisorFSM_TX_o2,
+ &(AMC_BLDC_DW.SupervisorFSM_TX_InstanceData.rtb),
+ &(AMC_BLDC_DW.SupervisorFSM_TX_InstanceData.rtdw));
- // ModelReference: '/CAN_Encoder' incorporates:
+ // ModelReference: '/CAN_Encoder' incorporates:
// Outport generated from: '/Out Bus Element1'
can_encoder(&AMC_BLDC_B.MessagesTx, &rtb_SupervisorFSM_TX_o2,
- &AMC_BLDC_B.ZOHBlockInsertedForAdapter_InsertedFor_Adapter4_at_outport_0,
- &AMC_BLDC_Y.PacketsTx);
+ &AMC_BLDC_B.ZOHBlockInsertedForAdapter_InsertedFor_Adapter_at_outport_0,
+ &AMC_BLDC_Y.PacketsTx, &(AMC_BLDC_DW.CAN_Encoder_InstanceData.rtb));
- // ModelReference: '/OuterControl' incorporates:
+ // Update for UnitDelay generated from: '/Adapter' incorporates:
// Outport generated from: '/Out Bus Element3'
- // Outport generated from: '/Out Bus Element2'
- // Outport generated from: '/Out Bus Element4'
- control_outer(&AMC_BLDC_Y.Flags_p, &AMC_BLDC_Y.ConfigurationParameters_p,
- &rtb_SupervisorFSM_RX_o2,
- &AMC_BLDC_B.RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0,
- &AMC_BLDC_Y.EstimatedData_p, &rtb_OuterControl,
- &(AMC_BLDC_DW.OuterControl_InstanceData.rtb),
- &(AMC_BLDC_DW.OuterControl_InstanceData.rtdw),
- &(AMC_BLDC_DW.OuterControl_InstanceData.rtzce));
-
- // RateTransition generated from: '/Adapter2'
- rtw_mutex_lock();
- wrBufIdx = static_cast
- (AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_5_Ls +
- 1);
- if (wrBufIdx == 3) {
- wrBufIdx = 0;
- }
-
- if (wrBufIdx ==
- AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_5_RD)
- {
- wrBufIdx = static_cast(wrBufIdx + 1);
- if (wrBufIdx == 3) {
- wrBufIdx = 0;
- }
- }
-
- rtw_mutex_unlock();
- AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_5_Bu[wrBufIdx]
- = rtb_OuterControl;
- AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_5_Ls =
- wrBufIdx;
-
- // RateTransition generated from: '/Adapter2' incorporates:
- // Outport generated from: '/Out Bus Element4'
-
- rtw_mutex_lock();
- wrBufIdx = static_cast
- (AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_1_Ls +
- 1);
- if (wrBufIdx == 3) {
- wrBufIdx = 0;
- }
-
- if (wrBufIdx ==
- AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_1_RD)
- {
- wrBufIdx = static_cast(wrBufIdx + 1);
- if (wrBufIdx == 3) {
- wrBufIdx = 0;
- }
- }
-
- rtw_mutex_unlock();
- AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_1_Bu[wrBufIdx]
- = AMC_BLDC_Y.Flags_p;
- AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_1_Ls =
- wrBufIdx;
-
- // RateTransition generated from: '/Adapter2' incorporates:
- // Outport generated from: '/Out Bus Element3'
-
- rtw_mutex_lock();
- wrBufIdx = static_cast
- (AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_2_Ls +
- 1);
- if (wrBufIdx == 3) {
- wrBufIdx = 0;
- }
-
- if (wrBufIdx ==
- AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_2_RD)
- {
- wrBufIdx = static_cast(wrBufIdx + 1);
- if (wrBufIdx == 3) {
- wrBufIdx = 0;
- }
- }
-
- rtw_mutex_unlock();
- AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_2_Bu[wrBufIdx]
- = AMC_BLDC_Y.ConfigurationParameters_p;
- AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_2_Ls =
- wrBufIdx;
-
- // RateTransition generated from: '/Adapter2'
- rtw_mutex_lock();
- wrBufIdx = static_cast
- (AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_4_Ls +
- 1);
- if (wrBufIdx == 3) {
- wrBufIdx = 0;
- }
-
- if (wrBufIdx ==
- AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_4_RD)
- {
- wrBufIdx = static_cast(wrBufIdx + 1);
- if (wrBufIdx == 3) {
- wrBufIdx = 0;
- }
- }
-
- rtw_mutex_unlock();
- AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_4_Bu[wrBufIdx]
- = rtb_SupervisorFSM_RX_o2;
- AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_4_Ls =
- wrBufIdx;
-
- // RateTransition generated from: '/Adapter2' incorporates:
- // Outport generated from: '/Out Bus Element2'
-
- rtw_mutex_lock();
- wrBufIdx = static_cast
- (AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_3_Ls +
- 1);
- if (wrBufIdx == 3) {
- wrBufIdx = 0;
- }
-
- if (wrBufIdx ==
- AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_3_RD)
- {
- wrBufIdx = static_cast(wrBufIdx + 1);
- if (wrBufIdx == 3) {
- wrBufIdx = 0;
- }
- }
-
- rtw_mutex_unlock();
- AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_3_Bu[wrBufIdx]
- = AMC_BLDC_Y.EstimatedData_p;
- AMC_BLDC_DW.RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_3_Ls =
- wrBufIdx;
-
- // Update for UnitDelay generated from: '/Adapter4' incorporates:
- // Outport generated from: '/Out Bus Element3'
-
- AMC_BLDC_DW.ZOHBlockInsertedForAdapter_InsertedFor_Adapter4_at_outport_0 =
- AMC_BLDC_Y.ConfigurationParameters_p;
+ AMC_BLDC_DW.ZOHBlockInsertedForAdapter_InsertedFor_Adapter_at_outport_0_ =
+ AMC_BLDC_Y.ConfigurationParameters;
}
// Model initialize function
void AMC_BLDC_initialize(void)
{
- // Model Initialize function for ModelReference Block: '/Estimation_Velocity'
- estimation_velocity_initialize(rtmGetErrorStatusPointer(AMC_BLDC_M),
- &(AMC_BLDC_DW.Estimation_Velocity_InstanceData.rtm),
- &(AMC_BLDC_DW.Estimation_Velocity_InstanceData.rtdw));
-
- // Model Initialize function for ModelReference Block: '/Filter_Current'
- filter_current_initialize(rtmGetErrorStatusPointer(AMC_BLDC_M),
- &(AMC_BLDC_DW.Filter_Current_InstanceData.rtm),
- &(AMC_BLDC_DW.Filter_Current_InstanceData.rtdw));
-
- // Model Initialize function for ModelReference Block: '/FOC'
- control_foc_initialize(rtmGetErrorStatusPointer(AMC_BLDC_M),
- &(AMC_BLDC_DW.FOC_InstanceData.rtm), &(AMC_BLDC_DW.FOC_InstanceData.rtb),
- &(AMC_BLDC_DW.FOC_InstanceData.rtdw), &(AMC_BLDC_DW.FOC_InstanceData.rtzce));
-
- // Model Initialize function for ModelReference Block: '/CAN_Decoder'
- can_decoder_initialize(rtmGetErrorStatusPointer(AMC_BLDC_M));
+ // Model Initialize function for ModelReference Block: '/CAN_Decoder'
+ can_decoder_initialize(rtmGetErrorStatusPointer(AMC_BLDC_M),
+ &(AMC_BLDC_DW.CAN_Decoder_InstanceData.rtm));
- // Model Initialize function for ModelReference Block: '/CAN_Encoder'
- can_encoder_initialize(rtmGetErrorStatusPointer(AMC_BLDC_M));
+ // Model Initialize function for ModelReference Block: '/CAN_Encoder'
+ can_encoder_initialize(rtmGetErrorStatusPointer(AMC_BLDC_M),
+ &(AMC_BLDC_DW.CAN_Encoder_InstanceData.rtm));
- // Model Initialize function for ModelReference Block: '/OuterControl'
- control_outer_initialize(rtmGetErrorStatusPointer(AMC_BLDC_M),
- &(AMC_BLDC_DW.OuterControl_InstanceData.rtm),
- &(AMC_BLDC_DW.OuterControl_InstanceData.rtb),
- &(AMC_BLDC_DW.OuterControl_InstanceData.rtdw),
- &(AMC_BLDC_DW.OuterControl_InstanceData.rtzce));
+ // Model Initialize function for ModelReference Block: '/Motion Controller Single'
+ mc_initialize(rtmGetErrorStatusPointer(AMC_BLDC_M),
+ &(AMC_BLDC_DW.MotionControllerSingle_InstanceData.rtm),
+ &(AMC_BLDC_DW.MotionControllerSingle_InstanceData.rtdw));
- // Model Initialize function for ModelReference Block: '/SupervisorFSM_RX'
- SupervisorFSM_RX_initialize(rtmGetErrorStatusPointer(AMC_BLDC_M));
+ // Model Initialize function for ModelReference Block: '/SupervisorFSM_TX'
+ SupervisorFSM_TX_initialize(rtmGetErrorStatusPointer(AMC_BLDC_M),
+ &(AMC_BLDC_DW.SupervisorFSM_TX_InstanceData.rtm));
- // Model Initialize function for ModelReference Block: '/SupervisorFSM_TX'
- SupervisorFSM_TX_initialize(rtmGetErrorStatusPointer(AMC_BLDC_M));
-
- // Start for RateTransition generated from: '/Adapter1'
- rtw_mutex_init();
-
- // Start for RateTransition generated from: '/Adapter2'
- rtw_mutex_init();
-
- // Start for RateTransition generated from: '/Adapter2'
+ // Start for RateTransition generated from: '/SupervisorFSM_TX'
rtw_mutex_init();
- // Start for RateTransition generated from: '/Adapter2'
- rtw_mutex_init();
-
- // Start for RateTransition generated from: '/Adapter2'
- rtw_mutex_init();
-
- // Start for RateTransition generated from: '/Adapter2'
- rtw_mutex_init();
-
- // Start for RateTransition generated from: '/Adapter1'
- rtw_mutex_init();
-
- // Start for RateTransition generated from: '/Adapter3'
- rtw_mutex_init();
-
- // SystemInitialize for ModelReference: '/Estimation_Velocity'
- estimation_velocity_Init(&(AMC_BLDC_DW.Estimation_Velocity_InstanceData.rtdw));
-
- // SystemInitialize for ModelReference: '/Filter_Current'
- filter_current_Init(&(AMC_BLDC_DW.Filter_Current_InstanceData.rtdw));
-
- // SystemInitialize for ModelReference: '/FOC'
- control_foc_Init(&(AMC_BLDC_DW.FOC_InstanceData.rtdw));
-
- // SystemInitialize for ModelReference: '/CAN_Decoder' incorporates:
- // Inport generated from: '/In Bus Element2'
-
- can_decoder_Init();
-
- // SystemInitialize for ModelReference: '/OuterControl'
- control_outer_Init(&(AMC_BLDC_DW.OuterControl_InstanceData.rtdw));
+ // SystemInitialize for ModelReference: '/CAN_Decoder'
+ can_decoder_Init(&(AMC_BLDC_DW.CAN_Decoder_InstanceData.rtb),
+ &(AMC_BLDC_DW.CAN_Decoder_InstanceData.rtdw));
- // SystemInitialize for ModelReference: '/SupervisorFSM_RX' incorporates:
- // Inport generated from: '/In Bus Element'
+ // SystemInitialize for ModelReference: '/Motion Controller Single' incorporates:
// Outport generated from: '/Out Bus Element3'
// Outport generated from: '/Out Bus Element4'
- SupervisorFSM_RX_Init(&AMC_BLDC_Y.Flags_p,
- &AMC_BLDC_Y.ConfigurationParameters_p);
-
- // SystemInitialize for ModelReference: '/SupervisorFSM_TX' incorporates:
- // Outport generated from: '/Out Bus Element3'
- // Outport generated from: '/Out Bus Element4'
+ motion_controller_single_Init(&AMC_BLDC_Y.Flags_p,
+ &AMC_BLDC_Y.ConfigurationParameters,
+ &(AMC_BLDC_DW.MotionControllerSingle_InstanceData.rtdw));
+ // SystemInitialize for ModelReference generated from: '/SupervisorFSM_TX'
SupervisorFSM_TX_Init(&AMC_BLDC_B.MessagesTx);
- // Enable for ModelReference: '/OuterControl'
- control_outer_Enable(&(AMC_BLDC_DW.OuterControl_InstanceData.rtdw));
+ // Enable for ModelReference: '/Motion Controller Single'
+ motion_controller_single_Enable
+ (&(AMC_BLDC_DW.MotionControllerSingle_InstanceData.rtdw));
}
// Model terminate function
void AMC_BLDC_terminate(void)
{
- // Terminate for RateTransition generated from: '/Adapter1'
- rtw_mutex_destroy();
-
- // Terminate for RateTransition generated from: '/Adapter2'
- rtw_mutex_destroy();
-
- // Terminate for RateTransition generated from: '/Adapter2'
- rtw_mutex_destroy();
+ // Terminate for ModelReference: '/Motion Controller Single'
+ mc_terminate(&(AMC_BLDC_DW.MotionControllerSingle_InstanceData.rtdw));
- // Terminate for RateTransition generated from: '/Adapter2'
+ // Terminate for RateTransition generated from: '/SupervisorFSM_TX'
rtw_mutex_destroy();
-
- // Terminate for RateTransition generated from: '/Adapter2'
- rtw_mutex_destroy();
-
- // Terminate for RateTransition generated from: '/Adapter2'
- rtw_mutex_destroy();
-
- // Terminate for RateTransition generated from: '/Adapter1'
- rtw_mutex_destroy();
-
- // Terminate for RateTransition generated from: '/Adapter3'
- rtw_mutex_destroy();
-
- // Terminate for ModelReference: '/Filter_Current'
- filter_current_Term(&(AMC_BLDC_DW.Filter_Current_InstanceData.rtdw));
}
//
diff --git a/emBODY/eBcode/arch-arm/mbd/amcbldc/amc-bldc/AMC_BLDC.h b/emBODY/eBcode/arch-arm/mbd/amcbldc/amc-bldc/AMC_BLDC.h
index 1f4da48af..8dc061ac1 100644
--- a/emBODY/eBcode/arch-arm/mbd/amcbldc/amc-bldc/AMC_BLDC.h
+++ b/emBODY/eBcode/arch-arm/mbd/amcbldc/amc-bldc/AMC_BLDC.h
@@ -7,9 +7,9 @@
//
// Code generated for Simulink model 'AMC_BLDC'.
//
-// Model version : 7.13
+// Model version : 7.54
// Simulink Coder version : 23.2 (R2023b) 01-Aug-2023
-// C/C++ source code generated on : Tue Feb 13 11:55:25 2024
+// C/C++ source code generated on : Wed Feb 28 11:29:48 2024
//
// Target selection: ert.tlc
// Embedded hardware selection: ARM Compatible->ARM Cortex-M
@@ -20,11 +20,12 @@
#define RTW_HEADER_AMC_BLDC_h_
#include "rtwtypes.h"
#include "AMC_BLDC_types.h"
-#include "control_foc.h"
-#include "estimation_velocity.h"
-#include "filter_current.h"
-#include "control_outer.h"
+#include "motion_controller_single.h"
+#include "can_decoder.h"
+#include "SupervisorFSM_TX.h"
+#include "can_encoder.h"
#include
+#include "mc_supervisor_defines.h"
#include "zero_crossing_types.h"
// Macros for accessing real-time model data structure
@@ -50,65 +51,26 @@
// Block signals (default storage)
struct B_AMC_BLDC_T {
- FOCSlowInputs BusConversion_InsertedFor_FOC_at_inport_1_BusCreator1;
- BUS_MESSAGES_RX_MULTIPLE CAN_Decoder_o1;// '/CAN_Decoder'
- ConfigurationParameters
- ZOHBlockInsertedForAdapter_InsertedFor_Adapter4_at_outport_0;// '/Adapter4'
- BUS_MESSAGES_TX MessagesTx; // '/SupervisorFSM_TX'
- SensorsData RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0;// '/Adapter3'
- ControlOutputs RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0;// '/Adapter1'
- BUS_STATUS_RX_MULTIPLE CAN_Decoder_o2;// '/CAN_Decoder'
- BUS_CAN_RX_ERRORS_MULTIPLE CAN_Decoder_o3;// '/CAN_Decoder'
+ ActuatorConfiguration
+ ZOHBlockInsertedForAdapter_InsertedFor_Adapter_at_outport_0;// '/Adapter'
+ SupervisorReceivedEvents CAN_Decoder_o1[MAX_EVENTS_PER_TICK];// '/CAN_Decoder'
+ BUS_MESSAGES_TX MessagesTx; // '/SupervisorFSM_TX'
};
// Block states (default storage) for system ''
struct DW_AMC_BLDC_T {
- ConfigurationParameters
- ZOHBlockInsertedForAdapter_InsertedFor_Adapter4_at_outport_0;// synthesized block
- ConfigurationParameters
- RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_2_Bu[3];// synthesized block
- SensorsData RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0_Buf0;// synthesized block
- SensorsData RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0_Buf1;// synthesized block
- SensorsData RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0_Buf2;// synthesized block
- ControlOutputs RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0_Buf0;// synthesized block
- ControlOutputs RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0_Buf1;// synthesized block
- ControlOutputs RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0_Buf2;// synthesized block
- Targets RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_4_Bu[3];// synthesized block
- EstimatedData RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_3_Bu[3];// synthesized block
- ControlOuterOutputs
- RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_5_Bu[3];// synthesized block
- Flags RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_1_Bu[3];// synthesized block
- MotorTemperature RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0_Bu_d;// synthesized block
- MotorTemperature RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0_Bu_j;// synthesized block
- MotorTemperature RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0_Bu_o;// synthesized block
- void* RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0_SEMA;// synthesized block
- void* RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_1_SE;// synthesized block
- void* RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_2_SE;// synthesized block
- void* RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_3_SE;// synthesized block
- void* RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_4_SE;// synthesized block
- void* RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_5_SE;// synthesized block
- void* RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0_SE_h;// synthesized block
- void* RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0_SEMA;// synthesized block
- int8_T RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0_LstB;// synthesized block
- int8_T RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0_RDBu;// synthesized block
- int8_T RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_1_Ls;// synthesized block
- int8_T RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_1_RD;// synthesized block
- int8_T RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_2_Ls;// synthesized block
- int8_T RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_2_RD;// synthesized block
- int8_T RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_3_Ls;// synthesized block
- int8_T RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_3_RD;// synthesized block
- int8_T RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_4_Ls;// synthesized block
- int8_T RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_4_RD;// synthesized block
- int8_T RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_5_Ls;// synthesized block
- int8_T RTBInsertedForAdapter_InsertedFor_Adapter2_at_outport_0_5_RD;// synthesized block
- int8_T RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0_Ls_j;// synthesized block
- int8_T RTBInsertedForAdapter_InsertedFor_Adapter1_at_outport_0_RD_a;// synthesized block
- int8_T RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0_LstB;// synthesized block
- int8_T RTBInsertedForAdapter_InsertedFor_Adapter3_at_outport_0_RDBu;// synthesized block
- MdlrefDW_control_foc_T FOC_InstanceData;// '/FOC'
- MdlrefDW_estimation_velocity_T Estimation_Velocity_InstanceData;// '/Estimation_Velocity'
- MdlrefDW_filter_current_T Filter_Current_InstanceData;// '/Filter_Current'
- MdlrefDW_control_outer_T OuterControl_InstanceData;// '/OuterControl'
+ ActuatorConfiguration
+ ZOHBlockInsertedForAdapter_InsertedFor_Adapter_at_outport_0_;// synthesized block
+ FOCOutputs TmpRTBAtSupervisorFSM_TXInport4_Buf0;// synthesized block
+ FOCOutputs TmpRTBAtSupervisorFSM_TXInport4_Buf1;// synthesized block
+ FOCOutputs TmpRTBAtSupervisorFSM_TXInport4_Buf2;// synthesized block
+ void* TmpRTBAtSupervisorFSM_TXInport4_SEMAPHORE;// synthesized block
+ int8_T TmpRTBAtSupervisorFSM_TXInport4_LstBufWR;// synthesized block
+ int8_T TmpRTBAtSupervisorFSM_TXInport4_RDBuf;// synthesized block
+ MdlrefDW_motion_controller_single_T MotionControllerSingle_InstanceData;// '/Motion Controller Single'
+ MdlrefDW_can_decoder_T CAN_Decoder_InstanceData;// '/CAN_Decoder'
+ MdlrefDW_SupervisorFSM_TX_T SupervisorFSM_TX_InstanceData;// '/SupervisorFSM_TX'
+ MdlrefDW_can_encoder_T CAN_Encoder_InstanceData;// '/CAN_Encoder'
};
// External inputs (root inport signals with default storage)
@@ -120,8 +82,8 @@ struct ExtU_AMC_BLDC_T {
// External outputs (root outports fed by signals with default storage)
struct ExtY_AMC_BLDC_T {
- ControlOutputs ControlOutputs_p; // '/ControlOutputs'
- ConfigurationParameters ConfigurationParameters_p;// '/ConfigurationParameters'
+ FOCOutputs ControlOutputs; // '/ControlOutputs'
+ ActuatorConfiguration ConfigurationParameters;// '/ConfigurationParameters'
Flags Flags_p; // '/Flags'
EstimatedData EstimatedData_p; // '/EstimatedData'
BUS_CAN_MULTIPLE PacketsTx; // '/PacketsTx'
@@ -189,21 +151,21 @@ extern "C"
// these parameters and exports their symbols.
//
-extern ConfigurationParameters InitConfParams;// Variable: InitConfParams
- // Referenced by: '/SupervisorFSM_RX'
+extern ActuatorConfiguration InitConfParams;// Variable: InitConfParams
+ // Referenced by: '/Motion Controller Single'
extern real32_T CAN_ANGLE_DEG2ICUB; // Variable: CAN_ANGLE_DEG2ICUB
- // Referenced by: '/CAN_Encoder'
+ // Referenced by: '/CAN_Encoder'
// 2^16/360
extern real32_T CAN_ANGLE_ICUB2DEG; // Variable: CAN_ANGLE_ICUB2DEG
- // Referenced by: '/CAN_Decoder'
+ // Referenced by: '/CAN_Decoder'
// 360/2^16
extern uint8_T CAN_ID_AMC; // Variable: CAN_ID_AMC
// Referenced by:
- // '/CAN_Decoder'
- // '/CAN_Encoder'
+ // '/CAN_Decoder'
+ // '/CAN_Encoder'
// 4 bits defining the ID of the AMC_BLDC board.
@@ -258,19 +220,8 @@ extern "C"
// Here is the system hierarchy for this model
//
// '' : 'AMC_BLDC'
-// '' : 'AMC_BLDC/Adapter1'
-// '' : 'AMC_BLDC/Adapter2'
-// '' : 'AMC_BLDC/Adapter3'
-// '' : 'AMC_BLDC/Adapter4'
-// '' : 'AMC_BLDC/Estimation'
-// '' : 'AMC_BLDC/Messaging'
-// '' : 'AMC_BLDC/Supervision'
-// '' : 'AMC_BLDC/Estimation/Adapter'
-// '' : 'AMC_BLDC/Estimation/Adapter1'
-// '' : 'AMC_BLDC/Estimation/Adapter3'
-// '' : 'AMC_BLDC/Estimation/Estimation_Temperature'
-// '' : 'AMC_BLDC/Estimation/Mux'
-// '' : 'AMC_BLDC/Estimation/Estimation_Temperature/Disabled'
+// '' : 'AMC_BLDC/Adapter'
+// '' : 'AMC_BLDC/Messaging'
#endif // RTW_HEADER_AMC_BLDC_h_
diff --git a/emBODY/eBcode/arch-arm/mbd/amcbldc/amc-bldc/AMC_BLDC_private.h b/emBODY/eBcode/arch-arm/mbd/amcbldc/amc-bldc/AMC_BLDC_private.h
index 1de82f4e4..15073bb13 100644
--- a/emBODY/eBcode/arch-arm/mbd/amcbldc/amc-bldc/AMC_BLDC_private.h
+++ b/emBODY/eBcode/arch-arm/mbd/amcbldc/amc-bldc/AMC_BLDC_private.h
@@ -7,9 +7,9 @@
//
// Code generated for Simulink model 'AMC_BLDC'.
//
-// Model version : 7.13
+// Model version : 7.54
// Simulink Coder version : 23.2 (R2023b) 01-Aug-2023
-// C/C++ source code generated on : Tue Feb 13 11:55:25 2024
+// C/C++ source code generated on : Wed Feb 28 11:29:48 2024
//
// Target selection: ert.tlc
// Embedded hardware selection: ARM Compatible->ARM Cortex-M
diff --git a/emBODY/eBcode/arch-arm/mbd/amcbldc/amc-bldc/AMC_BLDC_types.h b/emBODY/eBcode/arch-arm/mbd/amcbldc/amc-bldc/AMC_BLDC_types.h
index 980edb620..c118d3568 100644
--- a/emBODY/eBcode/arch-arm/mbd/amcbldc/amc-bldc/AMC_BLDC_types.h
+++ b/emBODY/eBcode/arch-arm/mbd/amcbldc/amc-bldc/AMC_BLDC_types.h
@@ -7,9 +7,9 @@
//
// Code generated for Simulink model 'AMC_BLDC'.
//
-// Model version : 7.13
+// Model version : 7.54
// Simulink Coder version : 23.2 (R2023b) 01-Aug-2023
-// C/C++ source code generated on : Tue Feb 13 11:55:25 2024
+// C/C++ source code generated on : Wed Feb 28 11:29:48 2024
//
// Target selection: ert.tlc
// Embedded hardware selection: ARM Compatible->ARM Cortex-M
@@ -22,6 +22,7 @@
// Includes for objects with custom storage classes
#include "rtw_defines.h"
+#include "mc_supervisor_defines.h"
//
// Registered constraints for dimension variants
@@ -30,17 +31,24 @@
# error "The preprocessor definition 'CAN_MAX_NUM_PACKETS' must be greater than '0'"
#endif
+#if MAX_EVENTS_PER_TICK <= 0
+# error "The preprocessor definition 'MAX_EVENTS_PER_TICK' must be greater than '0'"
+#endif
+
#if CAN_MAX_NUM_PACKETS >= 16
# error "The preprocessor definition 'CAN_MAX_NUM_PACKETS' must be less than '16'"
#endif
-#ifndef DEFINED_TYPEDEF_FOR_JointPositions_
-#define DEFINED_TYPEDEF_FOR_JointPositions_
+#if MAX_EVENTS_PER_TICK >= 5
+# error "The preprocessor definition 'MAX_EVENTS_PER_TICK' must be less than '5'"
+#endif
+
+#ifndef DEFINED_TYPEDEF_FOR_DriverSensors_
+#define DEFINED_TYPEDEF_FOR_DriverSensors_
-struct JointPositions
+struct DriverSensors
{
- // joint positions
- real32_T position;
+ real32_T Vcc;
};
#endif
@@ -62,29 +70,28 @@ struct MotorSensors
#endif
-#ifndef DEFINED_TYPEDEF_FOR_SupplyVoltage_
-#define DEFINED_TYPEDEF_FOR_SupplyVoltage_
-
-struct SupplyVoltage
-{
- real32_T voltage;
-};
-
-#endif
-
#ifndef DEFINED_TYPEDEF_FOR_SensorsData_
#define DEFINED_TYPEDEF_FOR_SensorsData_
struct SensorsData
{
// position encoders
- JointPositions jointpositions;
-
- // motor probes
+ real32_T jointpositions;
+ DriverSensors driversensors;
MotorSensors motorsensors;
+};
+
+#endif
+
+#ifndef DEFINED_TYPEDEF_FOR_Targets_
+#define DEFINED_TYPEDEF_FOR_Targets_
- // supply probes
- SupplyVoltage supplyvoltagesensors;
+struct Targets
+{
+ real32_T jointpositions;
+ real32_T jointvelocities;
+ real32_T motorcurrent;
+ real32_T motorvoltage;
};
#endif
@@ -100,39 +107,69 @@ typedef enum {
ControlModes_Current,
ControlModes_Velocity,
ControlModes_Voltage,
- ControlModes_Torque,
ControlModes_HwFaultCM
} ControlModes;
#endif
-#ifndef DEFINED_TYPEDEF_FOR_Flags_
-#define DEFINED_TYPEDEF_FOR_Flags_
+#ifndef DEFINED_TYPEDEF_FOR_PID_
+#define DEFINED_TYPEDEF_FOR_PID_
-struct Flags
+struct PID
{
- // control mode
- ControlModes control_mode;
- boolean_T enable_sending_msg_status;
- boolean_T fault_button;
- boolean_T enable_thermal_protection;
+ ControlModes type;
+ real32_T OutMax;
+ real32_T OutMin;
+ real32_T P;
+ real32_T I;
+ real32_T D;
+ real32_T N;
+ real32_T I0;
+ real32_T D0;
+ uint8_T shift_factor;
};
#endif
-#ifndef DEFINED_TYPEDEF_FOR_MotorConfig_
-#define DEFINED_TYPEDEF_FOR_MotorConfig_
+#ifndef DEFINED_TYPEDEF_FOR_SupervisorEvents_
+#define DEFINED_TYPEDEF_FOR_SupervisorEvents_
-struct MotorConfig
+typedef enum {
+ SupervisorEvents_None = 0, // Default value
+ SupervisorEvents_SetLimit,
+ SupervisorEvents_SetControlMode,
+ SupervisorEvents_SetMotorConfig,
+ SupervisorEvents_SetPid,
+ SupervisorEvents_SetTarget
+} SupervisorEvents;
+
+#endif
+
+#ifndef DEFINED_TYPEDEF_FOR_SupervisorInputLimits_
+#define DEFINED_TYPEDEF_FOR_SupervisorInputLimits_
+
+struct SupervisorInputLimits
+{
+ real32_T overload;
+ real32_T peak;
+ real32_T nominal;
+ ControlModes type;
+};
+
+#endif
+
+#ifndef DEFINED_TYPEDEF_FOR_MotorConfiguration_
+#define DEFINED_TYPEDEF_FOR_MotorConfiguration_
+
+struct MotorConfiguration
{
- // Angular offset in degrees between the stator windings and the hall sensors.
- real32_T hall_sens_offset;
boolean_T has_hall_sens;
boolean_T has_quadrature_encoder;
boolean_T has_speed_quadrature_encoder;
boolean_T has_torque_sens;
boolean_T use_index;
boolean_T enable_verbosity;
+ int16_T hall_sensors_offset;
int16_T rotor_encoder_resolution;
int16_T rotor_index_offset;
uint8_T encoder_tolerance;
@@ -141,6 +178,7 @@ struct MotorConfig
real32_T Rphase;
real32_T Imin;
real32_T Imax;
+ real32_T Vcc;
real32_T Vmax;
real32_T resistance;
real32_T inductance;
@@ -150,77 +188,96 @@ struct MotorConfig
#endif
-#ifndef DEFINED_TYPEDEF_FOR_EstimationVelocityModes_
-#define DEFINED_TYPEDEF_FOR_EstimationVelocityModes_
+#ifndef DEFINED_TYPEDEF_FOR_SupervisorReceivedEvents_
+#define DEFINED_TYPEDEF_FOR_SupervisorReceivedEvents_
-typedef enum {
- EstimationVelocityModes_Disabled = 0,// Default value
- EstimationVelocityModes_MovingAverage,
- EstimationVelocityModes_LeastSquares
-} EstimationVelocityModes;
+struct SupervisorReceivedEvents
+{
+ Targets targets_content;
+ PID pid_content;
+ SupervisorEvents event_type;
+ ControlModes control_mode_content;
+ SupervisorInputLimits limits_content;
+ MotorConfiguration motor_config_content;
+};
#endif
-#ifndef DEFINED_TYPEDEF_FOR_EstimationConfig_
-#define DEFINED_TYPEDEF_FOR_EstimationConfig_
+#ifndef DEFINED_TYPEDEF_FOR_ExternalFlags_
+#define DEFINED_TYPEDEF_FOR_ExternalFlags_
-struct EstimationConfig
+struct ExternalFlags
{
- EstimationVelocityModes velocity_mode;
-
- // Forgetting factor in [0, 1] for exponential weighting-based estimation of RMS current value
- real32_T current_rms_lambda;
+ // External Fault Button (1 == pressed)
+ boolean_T fault_button;
};
#endif
-#ifndef DEFINED_TYPEDEF_FOR_PIDConfig_
-#define DEFINED_TYPEDEF_FOR_PIDConfig_
+#ifndef DEFINED_TYPEDEF_FOR_FOCOutputs_
+#define DEFINED_TYPEDEF_FOR_FOCOutputs_
-struct PIDConfig
+struct FOCOutputs
{
- real32_T OutMax;
- real32_T OutMin;
- real32_T P;
- real32_T I;
- real32_T D;
- real32_T N;
- real32_T I0;
- real32_T D0;
- uint8_T shift_factor;
+ // control effort (quadrature)
+ real32_T Vq;
+
+ // control effort (3-phases)
+ real32_T Vabc[3];
+
+ // quadrature current
+ real32_T Iq_fbk;
+
+ // direct current
+ real32_T Id_fbk;
+
+ // RMS of Iq
+ real32_T Iq_rms;
+
+ // RMS of Id
+ real32_T Id_rms;
};
#endif
-#ifndef DEFINED_TYPEDEF_FOR_Thresholds_
-#define DEFINED_TYPEDEF_FOR_Thresholds_
+#ifndef DEFINED_TYPEDEF_FOR_EstimatedData_
+#define DEFINED_TYPEDEF_FOR_EstimatedData_
-struct Thresholds
+struct EstimatedData
{
- // It shall be greater than hardwareJntPosMin
- real32_T jntPosMin;
+ // velocity
+ real32_T jointvelocities;
+
+ // filtered motor current
+ real32_T Iq_filtered;
+
+ // motor temperature
+ real32_T motor_temperature;
+};
- // It shall be smaller than hardwareJntPosMax
- real32_T jntPosMax;
+#endif
- // Imposed by hardware constraint
- real32_T hardwareJntPosMin;
+#ifndef DEFINED_TYPEDEF_FOR_Flags_
+#define DEFINED_TYPEDEF_FOR_Flags_
- // Imposed by hardware constraint
- real32_T hardwareJntPosMax;
+struct Flags
+{
+ boolean_T enable_sending_msg_status;
- // If robotMin == rotorMax == 0, there's no check
- real32_T rotorPosMin;
+ // control mode
+ ControlModes control_mode;
+ boolean_T enable_thermal_protection;
+};
- // If robotMin == rotorMax == 0, there's no check
- real32_T rotorPosMax;
+#endif
- // Can be only non-negative
- real32_T jntVelMax;
+#ifndef DEFINED_TYPEDEF_FOR_Thresholds_
+#define DEFINED_TYPEDEF_FOR_Thresholds_
- // Timeout on reception of velocity setpoint
+struct Thresholds
+{
// Can be only non-negative
- uint32_T velocityTimeout;
+ real32_T jntVelMax;
// Current that can be kept for an indefinite period of time w/o damaging the motor
// Expressed in [A] as all the internal computations are done this way
@@ -248,159 +305,44 @@ struct Thresholds
#endif
-#ifndef DEFINED_TYPEDEF_FOR_ConfigurationParameters_
-#define DEFINED_TYPEDEF_FOR_ConfigurationParameters_
+#ifndef DEFINED_TYPEDEF_FOR_PIDsConfiguration_
+#define DEFINED_TYPEDEF_FOR_PIDsConfiguration_
-struct ConfigurationParameters
+struct PIDsConfiguration
{
- MotorConfig motorconfig;
- EstimationConfig estimationconfig;
- PIDConfig CurLoopPID;
- PIDConfig PosLoopPID;
- PIDConfig VelLoopPID;
- PIDConfig DirLoopPID;
- Thresholds thresholds;
- real32_T environment_temperature;
+ PID currentPID;
+ PID velocityPID;
+ PID positionPID;
};
#endif
-#ifndef DEFINED_TYPEDEF_FOR_JointVelocities_
-#define DEFINED_TYPEDEF_FOR_JointVelocities_
+#ifndef DEFINED_TYPEDEF_FOR_ActuatorConfiguration_
+#define DEFINED_TYPEDEF_FOR_ActuatorConfiguration_
-struct JointVelocities
+struct ActuatorConfiguration
{
- // joint velocities
- real32_T velocity;
+ Thresholds thresholds;
+ PIDsConfiguration pids;
+ MotorConfiguration motor;
};
#endif
-#ifndef DEFINED_TYPEDEF_FOR_MotorCurrent_
-#define DEFINED_TYPEDEF_FOR_MotorCurrent_
+#ifndef DEFINED_TYPEDEF_FOR_BUS_MSG_FOC_
+#define DEFINED_TYPEDEF_FOR_BUS_MSG_FOC_
-struct MotorCurrent
+// Fields of a FOC message.
+struct BUS_MSG_FOC
{
- // motor current
+ // Current feedback in A.
real32_T current;
-};
-
-#endif
-
-#ifndef DEFINED_TYPEDEF_FOR_MotorTemperature_
-#define DEFINED_TYPEDEF_FOR_MotorTemperature_
-struct MotorTemperature
-{
- // motor temperature
- real32_T temperature;
-};
-
-#endif
-
-#ifndef DEFINED_TYPEDEF_FOR_EstimatedData_
-#define DEFINED_TYPEDEF_FOR_EstimatedData_
-
-struct EstimatedData
-{
- // velocity
- JointVelocities jointvelocities;
-
- // filtered motor current
- MotorCurrent Iq_filtered;
-
- // motor temperature
- MotorTemperature motor_temperature;
-};
-
-#endif
-
-#ifndef DEFINED_TYPEDEF_FOR_MotorVoltage_
-#define DEFINED_TYPEDEF_FOR_MotorVoltage_
-
-struct MotorVoltage
-{
- // motor voltage
- real32_T voltage;
-};
-
-#endif
-
-#ifndef DEFINED_TYPEDEF_FOR_Targets_
-#define DEFINED_TYPEDEF_FOR_Targets_
-
-struct Targets
-{
- JointPositions jointpositions;
- JointVelocities jointvelocities;
- MotorCurrent motorcurrent;
- MotorVoltage motorvoltage;
-};
-
-#endif
-
-#ifndef DEFINED_TYPEDEF_FOR_ControlOuterOutputs_
-#define DEFINED_TYPEDEF_FOR_ControlOuterOutputs_
-
-struct ControlOuterOutputs
-{
- boolean_T vel_en;
- boolean_T cur_en;
- boolean_T out_en;
- boolean_T pid_reset;
- MotorCurrent motorcurrent;
- real32_T current_limiter;
-};
-
-#endif
-
-#ifndef DEFINED_TYPEDEF_FOR_FOCSlowInputs_
-#define DEFINED_TYPEDEF_FOR_FOCSlowInputs_
-
-struct FOCSlowInputs
-{
- Flags flags;
- ConfigurationParameters configurationparameters;
- EstimatedData estimateddata;
- Targets targets;
- ControlOuterOutputs controlouteroutputs;
-};
-
-#endif
-
-#ifndef DEFINED_TYPEDEF_FOR_ControlOutputs_
-#define DEFINED_TYPEDEF_FOR_ControlOutputs_
-
-struct ControlOutputs
-{
- // control effort (quadrature)
- real32_T Vq;
-
- // control effort (3-phases)
- real32_T Vabc[3];
-
- // quadrature current
- MotorCurrent Iq_fbk;
-
- // direct current
- MotorCurrent Id_fbk;
-
- // RMS of Iq
- MotorCurrent Iq_rms;
-
- // RMS of Id
- MotorCurrent Id_rms;
-};
-
-#endif
-
-#ifndef DEFINED_TYPEDEF_FOR_ExternalFlags_
-#define DEFINED_TYPEDEF_FOR_ExternalFlags_
+ // Position feedback in deg.
+ real32_T position;
-struct ExternalFlags
-{
- // External Fault Button (1 == pressed)
- boolean_T fault_button;
+ // Velocity feedback in deg/s.
+ real32_T velocity;
};
#endif
@@ -420,217 +362,6 @@ typedef enum {
#endif
-#ifndef DEFINED_TYPEDEF_FOR_BUS_MSG_CONTROL_MODE_
-#define DEFINED_TYPEDEF_FOR_BUS_MSG_CONTROL_MODE_
-
-// Fields of a CONTROL_MODE message.
-struct BUS_MSG_CONTROL_MODE
-{
- // Motor selector.
- boolean_T motor;
-
- // Control mode.
- MCControlModes mode;
-};
-
-#endif
-
-#ifndef DEFINED_TYPEDEF_FOR_BUS_MSG_CURRENT_LIMIT_
-#define DEFINED_TYPEDEF_FOR_BUS_MSG_CURRENT_LIMIT_
-
-// Fields of a CURRENT_LIMIT message.
-struct BUS_MSG_CURRENT_LIMIT
-{
- // Motor selector.
- boolean_T motor;
-
- // Nominal current in A.
- real32_T nominal;
-
- // Peak current in A.
- real32_T peak;
-
- // Overload current in A.
- real32_T overload;
-};
-
-#endif
-
-#ifndef DEFINED_TYPEDEF_FOR_BUS_MSG_DESIRED_TARGETS_
-#define DEFINED_TYPEDEF_FOR_BUS_MSG_DESIRED_TARGETS_
-
-// Fields of a DESIRED_TARGETS message.
-struct BUS_MSG_DESIRED_TARGETS
-{
- // Target current in A.
- real32_T current;
-
- // Target voltage in %.
- real32_T voltage;
-
- // Target veocity in deg/s.
- real32_T velocity;
-};
-
-#endif
-
-#ifndef DEFINED_TYPEDEF_FOR_BUS_MSG_PID_
-#define DEFINED_TYPEDEF_FOR_BUS_MSG_PID_
-
-// Fields of a CURRENT_PID message.
-struct BUS_MSG_PID
-{
- // Motor selector.
- boolean_T motor;
-
- // Proportional gain.
- real32_T Kp;
-
- // Integral gain.
- real32_T Ki;
-
- // Derivative gain.
- real32_T Kd;
-
- // Shift factor.
- uint8_T Ks;
-};
-
-#endif
-
-#ifndef DEFINED_TYPEDEF_FOR_BUS_MSG_MOTOR_CONFIG_
-#define DEFINED_TYPEDEF_FOR_BUS_MSG_MOTOR_CONFIG_
-
-struct BUS_MSG_MOTOR_CONFIG
-{
- boolean_T has_hall_sens;
- boolean_T has_quadrature_encoder;
- boolean_T has_speed_quadrature_encoder;
- boolean_T has_torque_sens;
- boolean_T use_index;
- boolean_T enable_verbosity;
-
- // Number of polese of the motor.
- uint8_T number_poles;
-
- // Encoder tolerance.
- uint8_T encoder_tolerance;
-
- // Resolution of rotor encoder.
- int16_T rotor_encoder_resolution;
-
- // Offset of the rotor encoder.
- int16_T rotor_index_offset;
-};
-
-#endif
-
-#ifndef DEFINED_TYPEDEF_FOR_BUS_MESSAGES_RX_
-#define DEFINED_TYPEDEF_FOR_BUS_MESSAGES_RX_
-
-// Aggregate of all CAN received messages.
-struct BUS_MESSAGES_RX
-{
- BUS_MSG_CONTROL_MODE control_mode;
- BUS_MSG_CURRENT_LIMIT current_limit;
- BUS_MSG_DESIRED_TARGETS desired_targets;
- BUS_MSG_PID pid;
- BUS_MSG_MOTOR_CONFIG motor_config;
-};
-
-#endif
-
-#ifndef DEFINED_TYPEDEF_FOR_BUS_MESSAGES_RX_MULTIPLE_
-#define DEFINED_TYPEDEF_FOR_BUS_MESSAGES_RX_MULTIPLE_
-
-struct BUS_MESSAGES_RX_MULTIPLE
-{
- BUS_MESSAGES_RX messages[CAN_MAX_NUM_PACKETS];
-};
-
-#endif
-
-#ifndef DEFINED_TYPEDEF_FOR_BUS_STATUS_RX_
-#define DEFINED_TYPEDEF_FOR_BUS_STATUS_RX_
-
-// Aggregate of all events specifying types of received messages.
-struct BUS_STATUS_RX
-{
- boolean_T control_mode;
- boolean_T current_limit;
- boolean_T desired_targets;
- boolean_T current_pid;
- boolean_T velocity_pid;
- boolean_T motor_config;
-};
-
-#endif
-
-#ifndef DEFINED_TYPEDEF_FOR_BUS_STATUS_RX_MULTIPLE_
-#define DEFINED_TYPEDEF_FOR_BUS_STATUS_RX_MULTIPLE_
-
-struct BUS_STATUS_RX_MULTIPLE
-{
- BUS_STATUS_RX status[CAN_MAX_NUM_PACKETS];
-};
-
-#endif
-
-#ifndef DEFINED_TYPEDEF_FOR_CANErrorTypes_
-#define DEFINED_TYPEDEF_FOR_CANErrorTypes_
-
-typedef enum {
- CANErrorTypes_No_Error = 0, // Default value
- CANErrorTypes_Packet_Not4Us,
- CANErrorTypes_Packet_Unrecognized,
- CANErrorTypes_Packet_Malformed,
- CANErrorTypes_Packet_MultiFunctionsDetected,
- CANErrorTypes_Mode_Unrecognized
-} CANErrorTypes;
-
-#endif
-
-#ifndef DEFINED_TYPEDEF_FOR_BUS_CAN_RX_ERRORS_
-#define DEFINED_TYPEDEF_FOR_BUS_CAN_RX_ERRORS_
-
-// Specifies the CAN error types.
-struct BUS_CAN_RX_ERRORS
-{
- // True if an error has been detected.
- boolean_T event;
- CANErrorTypes type;
-};
-
-#endif
-
-#ifndef DEFINED_TYPEDEF_FOR_BUS_CAN_RX_ERRORS_MULTIPLE_
-#define DEFINED_TYPEDEF_FOR_BUS_CAN_RX_ERRORS_MULTIPLE_
-
-struct BUS_CAN_RX_ERRORS_MULTIPLE
-{
- BUS_CAN_RX_ERRORS errors[CAN_MAX_NUM_PACKETS];
-};
-
-#endif
-
-#ifndef DEFINED_TYPEDEF_FOR_BUS_MSG_FOC_
-#define DEFINED_TYPEDEF_FOR_BUS_MSG_FOC_
-
-// Fields of a FOC message.
-struct BUS_MSG_FOC
-{
- // Current feedback in A.
- real32_T current;
-
- // Position feedback in deg.
- real32_T position;
-
- // Velocity feedback in deg/s.
- real32_T velocity;
-};
-
-#endif
-
#ifndef DEFINED_TYPEDEF_FOR_BUS_FLAGS_TX_
#define DEFINED_TYPEDEF_FOR_BUS_FLAGS_TX_
@@ -752,6 +483,43 @@ struct BUS_CAN_MULTIPLE
#endif
+#ifndef DEFINED_TYPEDEF_FOR_CANErrorTypes_
+#define DEFINED_TYPEDEF_FOR_CANErrorTypes_
+
+typedef enum {
+ CANErrorTypes_No_Error = 0, // Default value
+ CANErrorTypes_Packet_Not4Us,
+ CANErrorTypes_Packet_Unrecognized,
+ CANErrorTypes_Packet_Malformed,
+ CANErrorTypes_Packet_MultiFunctionsDetected,
+ CANErrorTypes_Mode_Unrecognized
+} CANErrorTypes;
+
+#endif
+
+#ifndef DEFINED_TYPEDEF_FOR_BUS_CAN_RX_ERRORS_
+#define DEFINED_TYPEDEF_FOR_BUS_CAN_RX_ERRORS_
+
+// Specifies the CAN error types.
+struct BUS_CAN_RX_ERRORS
+{
+ // True if an error has been detected.
+ boolean_T event;
+ CANErrorTypes type;
+};
+
+#endif
+
+#ifndef DEFINED_TYPEDEF_FOR_BUS_CAN_RX_ERRORS_MULTIPLE_
+#define DEFINED_TYPEDEF_FOR_BUS_CAN_RX_ERRORS_MULTIPLE_
+
+struct BUS_CAN_RX_ERRORS_MULTIPLE
+{
+ BUS_CAN_RX_ERRORS errors[CAN_MAX_NUM_PACKETS];
+};
+
+#endif
+
#ifndef DEFINED_TYPEDEF_FOR_CANClassTypes_
#define DEFINED_TYPEDEF_FOR_CANClassTypes_
@@ -767,6 +535,17 @@ typedef enum {
#endif
+#ifndef DEFINED_TYPEDEF_FOR_EstimationVelocityModes_
+#define DEFINED_TYPEDEF_FOR_EstimationVelocityModes_
+
+typedef enum {
+ EstimationVelocityModes_Disabled = 0,// Default value
+ EstimationVelocityModes_MovingAverage,
+ EstimationVelocityModes_LeastSquares
+} EstimationVelocityModes;
+
+#endif
+
// Forward declaration for rtModel
typedef struct tag_RTM_AMC_BLDC_T RT_MODEL_AMC_BLDC_T;
diff --git a/emBODY/eBcode/arch-arm/mbd/amcbldc/can-decoder/can_decoder.cpp b/emBODY/eBcode/arch-arm/mbd/amcbldc/can-decoder/can_decoder.cpp
index 3a6aa79f2..4545a135c 100644
--- a/emBODY/eBcode/arch-arm/mbd/amcbldc/can-decoder/can_decoder.cpp
+++ b/emBODY/eBcode/arch-arm/mbd/amcbldc/can-decoder/can_decoder.cpp
@@ -7,9 +7,9 @@
//
// Code generated for Simulink model 'can_decoder'.
//
-// Model version : 6.3
+// Model version : 6.43
// Simulink Coder version : 23.2 (R2023b) 01-Aug-2023
-// C/C++ source code generated on : Tue Feb 13 11:54:24 2024
+// C/C++ source code generated on : Wed Feb 28 11:27:59 2024
//
// Target selection: ert.tlc
// Embedded hardware selection: ARM Compatible->ARM Cortex-M
@@ -17,12 +17,12 @@
// Validation result: Not run
//
#include "can_decoder.h"
-#include "can_decoder_private.h"
#include "rtwtypes.h"
#include "can_decoder_types.h"
#include
#include
-#include "rtw_defines.h"
+#include "mc_supervisor_defines.h"
+#include "can_decoder_private.h"
// Named constants for Chart: '/Decoding Logic'
const int32_T can_decoder_CALL_EVENT = -1;
@@ -32,13 +32,6 @@ const uint8_T can_decoder_IN_Home_p = 2U;
const int32_T can_decoder_event_ev_error_mode_unrecognized = 0;
const int32_T can_decoder_event_ev_error_pck_malformed = 1;
const int32_T can_decoder_event_ev_error_pck_not4us = 2;
-MdlrefDW_can_decoder_T can_decoder_MdlrefDW;
-
-// Block signals (default storage)
-B_can_decoder_c_T can_decoder_B;
-
-// Block states (default storage)
-DW_can_decoder_f_T can_decoder_DW;
// Forward declaration for local functions
static int32_T can_decoder_safe_cast_to_MCStreaming(int32_T input);
@@ -47,6 +40,7 @@ static void can_decoder_ERROR_HANDLING(boolean_T rtu_pck_available,
static int16_T can_decoder_merge_2bytes_signed(uint16_T bl, uint16_T bh);
static boolean_T can_decoder_is_controlmode_recognized(int32_T mode);
static int32_T can_decoder_safe_cast_to_MCControlModes(int32_T input);
+static ControlModes can_decoder_convertMode(MCControlModes mccontrolmode);
static uint16_T can_decoder_merge_2bytes_unsigned(uint16_T bl, uint16_T bh);
// Forward declaration for local functions
@@ -151,6 +145,35 @@ static int32_T can_decoder_safe_cast_to_MCControlModes(int32_T input)
return output;
}
+// Function for Chart: '/Decoding Logic'
+static ControlModes can_decoder_convertMode(MCControlModes mccontrolmode)
+{
+ ControlModes controlmode;
+ switch (mccontrolmode) {
+ case MCControlModes_Idle:
+ controlmode = ControlModes_Idle;
+ break;
+
+ case MCControlModes_Current:
+ controlmode = ControlModes_Current;
+ break;
+
+ case MCControlModes_SpeedVoltage:
+ controlmode = ControlModes_Velocity;
+ break;
+
+ case MCControlModes_OpenLoop:
+ controlmode = ControlModes_Voltage;
+ break;
+
+ default:
+ controlmode = ControlModes_Idle;
+ break;
+ }
+
+ return controlmode;
+}
+
// Function for Chart: '/Decoding Logic'
static uint16_T can_decoder_merge_2bytes_unsigned(uint16_T bl, uint16_T bh)
{
@@ -165,7 +188,7 @@ void can_decoder_DecodingLogic_Init(DW_DecodingLogic_can_decoder_T *localDW)
// Output and update for atomic system: '/Decoding Logic'
void can_decoder_DecodingLogic(boolean_T rtu_pck_available, const
- BUS_CAN_PACKET_RX *rtu_pck_input, const ConfigurationParameters
+ BUS_CAN_PACKET_RX *rtu_pck_input, const ActuatorConfiguration
*rtu_ConfigurationParameters, uint8_T rtu_CAN_ID_DST, uint8_T
rtu_CAN_VOLT_REF_SHIFT, real32_T rtu_CAN_VOLT_REF_GAIN,
B_DecodingLogic_can_decoder_T *localB, DW_DecodingLogic_can_decoder_T *localDW)
@@ -207,14 +230,14 @@ void can_decoder_DecodingLogic(boolean_T rtu_pck_available, const
if (rtu_pck_input->PAYLOAD.LEN >= 2) {
if (can_decoder_is_controlmode_recognized(static_cast
(rtu_pck_input->PAYLOAD.ARG[1]))) {
- localB->msg_set_control_mode.motor =
- rtu_pck_input->PAYLOAD.CMD.M;
- localB->msg_set_control_mode.mode = static_cast
+ // msg_set_control_mode.motor = pck_input.PAYLOAD.CMD.M;
+ localB->msg_set_control_mode = can_decoder_convertMode(
+ static_cast
(can_decoder_safe_cast_to_MCControlModes
- (rtu_pck_input->PAYLOAD.ARG[1]));
+ (rtu_pck_input->PAYLOAD.ARG[1])));
localDW->cmd_processed = static_cast
(localDW->cmd_processed + 1);
- localDW->ev_set_control_modeEventCounter++;
+ localB->event_type = SupervisorEvents_SetControlMode;
} else {
localDW->sfEvent = can_decoder_event_ev_error_mode_unrecognized;
if (localDW->is_active_ERROR_HANDLING != 0U) {
@@ -264,17 +287,17 @@ void can_decoder_DecodingLogic(boolean_T rtu_pck_available, const
tmp_merged = can_decoder_merge_2bytes_signed(static_cast
(rtu_pck_input->PAYLOAD.ARG[idx]), static_cast
(rtu_pck_input->PAYLOAD.ARG[idx + 1]));
- localB->msg_desired_targets.current = 0.001F * static_cast
+ localB->msg_desired_targets.motorcurrent = 0.001F * static_cast
(tmp_merged);
- localB->msg_desired_targets.voltage = static_cast
- (static_cast(tmp_merged >> (rtu_CAN_VOLT_REF_SHIFT -
- rtu_ConfigurationParameters->CurLoopPID.shift_factor))) /
+ localB->msg_desired_targets.motorvoltage = static_cast(
+ static_cast(tmp_merged >> (rtu_CAN_VOLT_REF_SHIFT -
+ rtu_ConfigurationParameters->pids.currentPID.shift_factor))) /
rtu_CAN_VOLT_REF_GAIN;
- localB->msg_desired_targets.velocity = 1000.0F * static_cast
- (tmp_merged) * CAN_ANGLE_ICUB2DEG;
+ localB->msg_desired_targets.jointvelocities = 1000.0F *
+ static_cast(tmp_merged) * CAN_ANGLE_ICUB2DEG;
localDW->cmd_processed = static_cast(localDW->cmd_processed +
1);
- localDW->ev_desired_targetsEventCounter++;
+ localB->event_type = SupervisorEvents_SetTarget;
} else {
localDW->sfEvent = can_decoder_event_ev_error_pck_malformed;
if (localDW->is_active_ERROR_HANDLING != 0U) {
@@ -294,7 +317,7 @@ void can_decoder_DecodingLogic(boolean_T rtu_pck_available, const
if (rtu_pck_input->PAYLOAD.CMD.OPC == static_cast
(MCOPC_Set_Current_Limit)) {
if (rtu_pck_input->PAYLOAD.LEN == 8) {
- localB->msg_set_current_limit.motor = rtu_pck_input->PAYLOAD.CMD.M;
+ // msg_set_current_limit.motor = pck_input.PAYLOAD.CMD.M;
localB->msg_set_current_limit.nominal = 0.001F *
static_cast(can_decoder_merge_2bytes_signed(
static_cast(rtu_pck_input->PAYLOAD.ARG[2]),
@@ -309,7 +332,7 @@ void can_decoder_DecodingLogic(boolean_T rtu_pck_available, const
static_cast(rtu_pck_input->PAYLOAD.ARG[7])));
localDW->cmd_processed = static_cast
(localDW->cmd_processed + 1);
- localDW->ev_set_current_limitEventCounter++;
+ localB->event_type = SupervisorEvents_SetLimit;
} else {
guard1 = true;
}
@@ -318,19 +341,20 @@ void can_decoder_DecodingLogic(boolean_T rtu_pck_available, const
(rtu_pck_input->PAYLOAD.CMD.OPC == static_cast
(MCOPC_Set_Velocity_PID))) {
if (rtu_pck_input->PAYLOAD.LEN == 8) {
- localB->msg_set_pid.motor = rtu_pck_input->PAYLOAD.CMD.M;
- localB->msg_set_pid.Ks = rtu_pck_input->PAYLOAD.ARG[7];
- c = static_cast(0x01 << (15 - localB->msg_set_pid.Ks)) /
- 32768.0F;
- localB->msg_set_pid.Kp = c * static_cast
+ // msg_set_pid.motor = pck_input.PAYLOAD.CMD.M;
+ localB->msg_set_pid.shift_factor = rtu_pck_input->PAYLOAD.ARG[7];
+ localB->msg_set_pid.type = ControlModes_Current;
+ c = static_cast(0x01 << (15 -
+ localB->msg_set_pid.shift_factor)) / 32768.0F;
+ localB->msg_set_pid.P = c * static_cast
(can_decoder_merge_2bytes_signed(static_cast
(rtu_pck_input->PAYLOAD.ARG[1]), static_cast
(rtu_pck_input->PAYLOAD.ARG[2])));
- localB->msg_set_pid.Ki = c * static_cast
+ localB->msg_set_pid.I = c * static_cast
(can_decoder_merge_2bytes_signed(static_cast
(rtu_pck_input->PAYLOAD.ARG[3]), static_cast
(rtu_pck_input->PAYLOAD.ARG[4])));
- localB->msg_set_pid.Kd = c * static_cast
+ localB->msg_set_pid.D = c * static_cast
(can_decoder_merge_2bytes_signed(static_cast
(rtu_pck_input->PAYLOAD.ARG[5]), static_cast