diff --git a/2_Motor_Master/Motor_Master/Motor_Master/bldc.c b/2_Motor_Master/Motor_Master/Motor_Master/bldc.c
index 267ed03..3ca9616 100644
--- a/2_Motor_Master/Motor_Master/Motor_Master/bldc.c
+++ b/2_Motor_Master/Motor_Master/Motor_Master/bldc.c
@@ -381,7 +381,9 @@ void BLDC_runCurrentCntl(BLDCMotor_t *motor, const float32_t curfbk, const float
}
volatile float32_t duty_pu = f_abs((motor->controllers.Pi_Idc.Out_pu * motor->VoneByDcBus_pu));
- motor->motor_status.duty_cycle = (uint16_t)f_clamp(duty_pu * (float32_t)MAX_PWM, 0.0f, (float32_t)MAX_PWM);
+ //motor->motor_status.duty_cycle = (uint16_t)f_clamp(duty_pu * (float32_t)MAX_PWM, 0.0f, (float32_t)MAX_PWM);
+ //motor->motor_status.duty_cycle = (uint16_t)f_clamp(duty_pu * (float32_t)MAX_PWM, 0.0f, (float32_t)MAX_PWM);
+ motor->motor_status.duty_cycle = (uint16_t)f_clamp(duty_pu * motor->motor_param->motor_MaxPWM, 0.0f, (float32_t)MAX_PWM);
// Remove Low duty cycle values
//if(duty_cycle < 80.0) motor->duty_cycle = (uint16_t)0;
//else motor->duty_cycle = (uint16_t)duty_cycle;
diff --git a/2_Motor_Master/Motor_Master/Motor_Master/bldc.h b/2_Motor_Master/Motor_Master/Motor_Master/bldc.h
index c07cdb6..55b82cc 100644
--- a/2_Motor_Master/Motor_Master/Motor_Master/bldc.h
+++ b/2_Motor_Master/Motor_Master/Motor_Master/bldc.h
@@ -17,7 +17,7 @@
#include "statemachine.h"
#define PWM_TOP (1000)
-#define MAX_PWM (300)
+#define MAX_PWM (800)
//#define MAX_VEL 3800
#define CW (0) //CBA
diff --git a/2_Motor_Master/Motor_Master/Motor_Master/main.c b/2_Motor_Master/Motor_Master/Motor_Master/main.c
index c5f6c91..606f240 100644
--- a/2_Motor_Master/Motor_Master/Motor_Master/main.c
+++ b/2_Motor_Master/Motor_Master/Motor_Master/main.c
@@ -153,7 +153,9 @@ int main(void)
/* BLDC INIT */
BldcInitStruct(&Motor1, &FH_22mm24BXTR);
- BldcInitStruct(&Motor2, &FH_32mm24BXTR);
+ BldcInitStruct(&Motor2, &FH_32mm12BXTR);
+ //Motor2.VdcBus_pu = 12.0;
+ //Motor2.VoneByDcBus_pu = 1.0/Motor2.VdcBus_pu;
Motor1.readHall = &readHallSensorM1;
Motor2.readHall = &readHallSensorM2;
@@ -175,13 +177,13 @@ int main(void)
custom_logic_enable();
angle_sensor_init();
- initialize_ads();
+ //initialize_ads();
/* External IRQ Config */
__enable_irq();
enable_NVIC_IRQ();
- ext_irq_register(GPIO_PIN(ADS_DATA_RDY), ADS1299_dataReadyISR);
- ADS1299_START();
+ //ext_irq_register(GPIO_PIN(ADS_DATA_RDY), ADS1299_dataReadyISR);
+ //ADS1299_START();
/* Replace with your application code */
while (1) {
@@ -212,14 +214,14 @@ int main(void)
if (Motor1.timerflags.current_loop_tic) {
Motor1.timerflags.current_loop_tic = false;
- APPLICATION_StateMachine();
- exec_commutation(&Motor1);
- exec_commutation(&Motor2);
+ //APPLICATION_StateMachine();
+ //exec_commutation(&Motor1);
+ //exec_commutation(&Motor2);
}
if (ADS1299.data_ReadyFlag){
ADS1299.data_ReadyFlag = false;
- ADS1299_UPDATECHANNELDATA();
+ //ADS1299_UPDATECHANNELDATA();
}
if (run_ECAT) {ECAT_STATE_MACHINE();}
diff --git a/2_Motor_Master/Motor_Master/Motor_Master/motorparameters.h b/2_Motor_Master/Motor_Master/Motor_Master/motorparameters.h
index 1aed905..7eb31f4 100644
--- a/2_Motor_Master/Motor_Master/Motor_Master/motorparameters.h
+++ b/2_Motor_Master/Motor_Master/Motor_Master/motorparameters.h
@@ -133,6 +133,7 @@ typedef struct
const float32_t motor_Max_Spd_ELEC;
const float32_t motor_Max_Current_IDC_A;
MOTOR_Control_Structs controller_param;
+ float32_t motor_MaxPWM;
} BLDCMotor_param_t;
//static BLDCMotor_param_t FH_22mm24BXTR;
@@ -158,6 +159,34 @@ const static BLDCMotor_param_t FH_22mm24BXTR = {
//.controller_param.Pid_Speed.Ki = 0.0000001f,
.controller_param.Pi_Pos.Kp = 50.0f,
.controller_param.Pi_Pos.Ki = 0.0f,
+ .motor_MaxPWM = 800.0,
+};
+
+
+/* Big Motor - 3216W012BXTR */
+const static BLDCMotor_param_t FH_32mm12BXTR = {
+ .pwm_desc = &PWM_1,
+ .speedtimer_hw = TC4,
+ .motor_Poles = 14,
+ .motor_polePairs = 7,
+ .motor_commutationStates = 42, //polePairs * 6
+ .motor_RS_Ohm = 0.88,
+ .motor_LD_H = 0.000331,
+ .motor_LQ_H = 0.000331,
+ .motor_Flux_WB = 0.0063879968,
+ .motor_Max_Spd_RPM = 3000,
+ .motor_MeasureRange_RPM = 3200, //(1.2f * MOTOR_MAX_SPD_RPM)f // give 20% headroom
+ .motor_Max_Spd_ELEC = 12000, //(MOTOR_MAX_SPD_RPM/60)*MOTOR_POLEPAIRS
+ .motor_Max_Current_IDC_A = (1.6),
+ .controller_param.Pid_Speed.Kp = 0.0004f,
+ .controller_param.Pid_Speed.Ki = 0.0000001f,
+ .controller_param.Pi_Pos.Kp = 50.0f,
+ .controller_param.Pi_Pos.Ki = 0.000f,
+ //.controller_param.Pid_Speed.Kp = 0.00002f,
+ //.controller_param.Pid_Speed.Ki = 0.0f,
+ //.controller_param.Pi_Pos.Kp = 4.0f,
+ //.controller_param.Pi_Pos.Ki = 0.0f,
+ .motor_MaxPWM = 300.0,
};
/* Big Motor - 3216W024BXTR */
@@ -179,6 +208,7 @@ const static BLDCMotor_param_t FH_32mm24BXTR = {
.controller_param.Pid_Speed.Ki = 0.0000001f,
.controller_param.Pi_Pos.Kp = 40.0f,
.controller_param.Pi_Pos.Ki = 0.0f,
+ .motor_MaxPWM = 800.0,
//.controller_param.Pid_Speed.Kp = 0.00002f,
//.controller_param.Pid_Speed.Ki = 0.0f,
//.controller_param.Pi_Pos.Kp = 4.0f,
diff --git a/Twincat/MotorData/.vs/MotorData/v15/.suo b/Twincat/MotorData/.vs/MotorData/v15/.suo
index 3ea1b8b..9598978 100644
Binary files a/Twincat/MotorData/.vs/MotorData/v15/.suo and b/Twincat/MotorData/.vs/MotorData/v15/.suo differ
diff --git a/Twincat/MotorData/Scope Project1.svdx b/Twincat/MotorData/Scope Project1.svdx
index f17bfa1..eb98517 100644
Binary files a/Twincat/MotorData/Scope Project1.svdx and b/Twincat/MotorData/Scope Project1.svdx differ
diff --git a/Twincat/MotorData/TwinCAT Measurement Project1/Scope Project1.tcscopex b/Twincat/MotorData/TwinCAT Measurement Project1/Scope Project1.tcscopex
index 19e4ea7..0739907 100644
--- a/Twincat/MotorData/TwinCAT Measurement Project1/Scope Project1.tcscopex
+++ b/Twincat/MotorData/TwinCAT Measurement Project1/Scope Project1.tcscopex
@@ -15,11 +15,11 @@
false
<?xml version="1.0" encoding="utf-16"?>
<Layout>
- <Window Guid="17812b7c-7d18-4668-ae12-d2633798b279" LastFocused="132742705121217503" DockedSize="200" PopupSize="0" FloatingLocation="-1, -1" FloatingSize="550, 400" LastOpenDockSituation="Document" LastFixedDockSituation="Document" LastFixedDockLocation="Right" LastFloatingWindowGuid="00000000-0000-0000-0000-000000000000" LastDockContainerCount="0" LastDockContainerIndex="0" DockedWorkingSize="250, 400" DockedWindowGroupGuid="00000000-0000-0000-0000-000000000000" DockedIndexInWindowGroup="0" DockedSplitPath="0" DocumentWorkingSize="250, 400" DocumentWindowGroupGuid="a5d32a52-1886-4ce8-9970-731db69737a6" DocumentIndexInWindowGroup="1" DocumentSplitPath="0" FloatingWorkingSize="250, 400" FloatingWindowGroupGuid="00000000-0000-0000-0000-000000000000" FloatingIndexInWindowGroup="0" FloatingSplitPath="0" />
- <Window Guid="8766837b-106b-4ca8-84ce-2fbbc3ef10f3" LastFocused="132742702609850464" DockedSize="200" PopupSize="0" FloatingLocation="-1, -1" FloatingSize="550, 400" LastOpenDockSituation="Document" LastFixedDockSituation="Document" LastFixedDockLocation="Right" LastFloatingWindowGuid="00000000-0000-0000-0000-000000000000" LastDockContainerCount="0" LastDockContainerIndex="0" DockedWorkingSize="250, 400" DockedWindowGroupGuid="00000000-0000-0000-0000-000000000000" DockedIndexInWindowGroup="0" DockedSplitPath="0" DocumentWorkingSize="250, 400" DocumentWindowGroupGuid="a5d32a52-1886-4ce8-9970-731db69737a6" DocumentIndexInWindowGroup="0" DocumentSplitPath="0" FloatingWorkingSize="250, 400" FloatingWindowGroupGuid="00000000-0000-0000-0000-000000000000" FloatingIndexInWindowGroup="0" FloatingSplitPath="0" />
+ <Window Guid="8766837b-106b-4ca8-84ce-2fbbc3ef10f3" LastFocused="132742840704085058" DockedSize="200" PopupSize="0" FloatingLocation="-1, -1" FloatingSize="550, 400" LastOpenDockSituation="Document" LastFixedDockSituation="Document" LastFixedDockLocation="Right" LastFloatingWindowGuid="00000000-0000-0000-0000-000000000000" LastDockContainerCount="0" LastDockContainerIndex="0" DockedWorkingSize="250, 400" DockedWindowGroupGuid="00000000-0000-0000-0000-000000000000" DockedIndexInWindowGroup="0" DockedSplitPath="0" DocumentWorkingSize="250, 400" DocumentWindowGroupGuid="a5d32a52-1886-4ce8-9970-731db69737a6" DocumentIndexInWindowGroup="0" DocumentSplitPath="0" FloatingWorkingSize="250, 400" FloatingWindowGroupGuid="00000000-0000-0000-0000-000000000000" FloatingIndexInWindowGroup="0" FloatingSplitPath="0" />
+ <Window Guid="17812b7c-7d18-4668-ae12-d2633798b279" LastFocused="132742810664328077" DockedSize="200" PopupSize="0" FloatingLocation="-1, -1" FloatingSize="550, 400" LastOpenDockSituation="Document" LastFixedDockSituation="Document" LastFixedDockLocation="Right" LastFloatingWindowGuid="00000000-0000-0000-0000-000000000000" LastDockContainerCount="0" LastDockContainerIndex="0" DockedWorkingSize="250, 400" DockedWindowGroupGuid="00000000-0000-0000-0000-000000000000" DockedIndexInWindowGroup="0" DockedSplitPath="0" DocumentWorkingSize="250, 400" DocumentWindowGroupGuid="a5d32a52-1886-4ce8-9970-731db69737a6" DocumentIndexInWindowGroup="1" DocumentSplitPath="0" FloatingWorkingSize="250, 400" FloatingWindowGroupGuid="00000000-0000-0000-0000-000000000000" FloatingIndexInWindowGroup="0" FloatingSplitPath="0" />
<DocumentContainer Dock="5">
<SplitLayoutSystem WorkingSize="250, 400" SplitMode="0">
- <ControlLayoutSystem WorkingSize="250, 400" Guid="a5d32a52-1886-4ce8-9970-731db69737a6" Collapsed="0" SelectedControl="17812b7c-7d18-4668-ae12-d2633798b279">
+ <ControlLayoutSystem WorkingSize="250, 400" Guid="a5d32a52-1886-4ce8-9970-731db69737a6" Collapsed="0" SelectedControl="8766837b-106b-4ca8-84ce-2fbbc3ef10f3">
<Controls>
<Control Guid="8766837b-106b-4ca8-84ce-2fbbc3ef10f3" />
<Control Guid="17812b7c-7d18-4668-ae12-d2633798b279" />
@@ -1014,6 +1014,168 @@
true
2
+
+ 192.168.61.1.1.1
+ Input
+ 0
+ 10000
+
+
+ 0
+
+
+ TwinCAT
+ ADS
+ TcBinary
+ Present
+
+ 0
+ 0
+
+
+
+ INT16
+ Black
+ true
+ 13
+ false
+ 00293ced-5f18-4418-aa61-3cce818122c1
+ 61472
+ 385108
+ false
+ false
+ M1_Motor_dutyCycle
+ 0
+
+
+ 0
+ None
+ 1
+ none
+
+ 1
+
+ 0
+
+
+
+ 0
+
+ 0
+ none
+ (None)
+ 1
+
+
+ 0
+ 1
+
+ UnitOfOne
+
+ 0
+ None
+
+ 0
+ none
+ 1
+
+ none
+
+
+ 0
+ 10
+
+ .svacq
+ true
+ GVL_motor_data.M1_Motor_dutyCycle
+ 851
+ 0
+ AdsAcquisition_77
+ true
+ true
+ 2
+
+
+ 192.168.61.1.1.1
+ Input
+ 0
+ 10000
+
+
+ 0
+
+
+ TwinCAT
+ ADS
+ TcBinary
+ Present
+
+ 0
+ 0
+
+
+
+ INT16
+ Black
+ true
+ 14
+ false
+ da0d5fd3-5da6-475d-bd83-771d47fa228f
+ 61472
+ 385128
+ false
+ false
+ M2_Motor_dutyCycle
+ 0
+
+
+ 0
+ None
+ 1
+ none
+
+ 1
+
+ 0
+
+
+
+ 0
+
+ 0
+ none
+ (None)
+ 1
+
+
+ 0
+ 1
+
+ UnitOfOne
+
+ 0
+ None
+
+ 0
+ none
+ 1
+
+ none
+
+
+ 0
+ 10
+
+ .svacq
+ true
+ GVL_motor_data.M2_Motor_dutyCycle
+ 851
+ 0
+ AdsAcquisition_77
+ true
+ true
+ 2
+
.svdp
DataPool_85
@@ -1163,7 +1325,7 @@
-0.5
Value Axis (3)
Y
- AutoGrowOnly
+ AutoGrowNShrink
100
@@ -1345,7 +1507,7 @@
-0.5
Value Axis
Y
- AutoGrowOnly
+ AutoGrowNShrink
100
@@ -1527,7 +1689,7 @@
-0.5
Value Axis (1)
Y
- AutoGrowOnly
+ AutoGrowNShrink
100
@@ -1709,7 +1871,7 @@
-0.5
Value Axis (2)
Y
- AutoGrowOnly
+ AutoGrowNShrink
100
@@ -2008,7 +2170,7 @@
-0.5
Value Axis (4)
Y
- AutoGrowOnly
+ AutoGrowNShrink
100
@@ -2284,6 +2446,125 @@
.svchannel
Channel_100
+
+
+ -4419697
+ true
+ 043fe743-9162-4cdc-9236-aa6517a30dcb
+ false
+ M1_Motor_dutyCycle
+ 12
+
+
+ 00293ced-5f18-4418-aa61-3cce818122c1
+ 18446744073709551615
+
+ Black
+ 99154ed7-1550-403c-8812-56461e7031c1
+ false
+ Y: M1_Motor_dutyCycle
+ 0
+
+
+ 0
+ None
+ 1
+ none
+
+ 1
+
+ 0
+
+
+
+ 0
+
+ 0
+ none
+ (None)
+ 1
+
+
+ 0
+ 1
+
+ UnitOfOne
+
+ 0
+ None
+
+ 0
+ none
+ 1
+
+ none
+
+
+ 1
+ 2
+
+ .svai
+ AcquisitionInterpreter_102
+ Y
+
+
+
+ Black
+ 226a0f1f-4c57-4714-9664-e6d7ac1d088d
+ false
+ Channel Style (12)
+ 100
+
+
+ true
+
+ Plum
+ 851218319
+ None
+ 5485538d-a250-41d4-8fb9-58ba197ed321
+ false
+ 1
+ -4419697
+ 2
+ Auto
+ Series Style (12)
+ Line
+ 100
+ .svstyle
+ SeriesStyle_112
+
+
+
+ Black
+ 8228517d-e45d-4e93-a643-8f4275a08b69
+ false
+ Min/Max Style (12)
+ false
+ false
+ 100
+ .svstyle
+ MinMaxStyle_1802
+
+
+
+ Black
+ f239b504-9009-4f99-ad99-0c515110c830
+ false
+ TimeShiftStyle_1803
+ 100
+ .svtss
+ 0
+ TimeShiftStyle_1803
+
+
+ .svstyle
+ ChannelStyle_110
+ true
+
+
+ .svchannel
+ Channel_100
+
.svagroup
AxisGroup_90
@@ -2309,7 +2590,7 @@
-0.5
Value Axis (5)
Y
- AutoGrowOnly
+ AutoGrowNShrink
100
@@ -2585,6 +2866,125 @@
.svchannel
Channel_100
+
+
+ -16728065
+ true
+ d383b860-26d6-406b-ad52-6854127f67c5
+ false
+ M2_Motor_dutyCycle
+ 12
+
+
+ da0d5fd3-5da6-475d-bd83-771d47fa228f
+ 18446744073709551615
+
+ Black
+ 0ac6fbf5-d9b8-44c3-b04e-be3b6a43f340
+ false
+ Y: M2_Motor_dutyCycle
+ 0
+
+
+ 0
+ None
+ 1
+ none
+
+ 1
+
+ 0
+
+
+
+ 0
+
+ 0
+ none
+ (None)
+ 1
+
+
+ 0
+ 1
+
+ UnitOfOne
+
+ 0
+ None
+
+ 0
+ none
+ 1
+
+ none
+
+
+ 1
+ 2
+
+ .svai
+ AcquisitionInterpreter_102
+ Y
+
+
+
+ Black
+ 0e93d793-ac0c-404c-bdef-d6e6a0c325fe
+ false
+ Channel Style (13)
+ 100
+
+
+ true
+
+ Plum
+ 838909951
+ None
+ 801898f3-5bb6-410b-8bdc-91eb16a36a26
+ false
+ 1
+ -16728065
+ 2
+ Auto
+ Series Style (13)
+ Line
+ 100
+ .svstyle
+ SeriesStyle_112
+
+
+
+ Black
+ 392d1450-e1b4-4270-9c9f-e0c6a824f1ac
+ false
+ Min/Max Style (13)
+ false
+ false
+ 100
+ .svstyle
+ MinMaxStyle_1975
+
+
+
+ Black
+ d6194688-cb08-4994-ae6f-d43032ff0f8f
+ false
+ TimeShiftStyle_1976
+ 100
+ .svtss
+ 0
+ TimeShiftStyle_1976
+
+
+ .svstyle
+ ChannelStyle_110
+ true
+
+
+ .svchannel
+ Channel_100
+
.svagroup
AxisGroup_90
@@ -2610,7 +3010,7 @@
-0.5
Value Axis (6)
Y
- AutoGrowOnly
+ AutoGrowNShrink
100
@@ -2911,7 +3311,7 @@
-0.5
Value Axis (7)
Y
- AutoGrowOnly
+ AutoGrowNShrink
100