Skip to content

Commit 793192d

Browse files
committed
inverter test torque command test upload
1 parent 526dfab commit 793192d

File tree

222 files changed

+128618
-2799
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

222 files changed

+128618
-2799
lines changed

calibration_inverter/Core/Src/gpio.c

+4-33
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ extern bool precharge_io;
2727
extern bool reset_io;
2828
extern bool rtd_start;
2929
extern bool clear_fault_io;
30+
extern bool enable;
3031
/* USER CODE END 0 */
3132

3233
/*----------------------------------------------------------------------------*/
@@ -120,41 +121,11 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
120121
*/
121122
if (GPIO_Pin==readyToDrive_SW_Pin){
122123
//ready to drive trigger
123-
if((HAL_GPIO_ReadPin(readyToDrive_SW_GPIO_Port,readyToDrive_SW_Pin)==GPIO_PIN_RESET)&&reset_io==1&&precharge_io==1){
124-
rtd_start=1;
124+
if((HAL_GPIO_ReadPin(readyToDrive_SW_GPIO_Port,readyToDrive_SW_Pin)==GPIO_PIN_RESET)){
125+
enable=1;
125126
}else{
126-
rtd_start=0;
127+
enable=0;
127128
}
128-
}else if(GPIO_Pin==reset_SW_Pin){
129-
//reset pin trigger
130-
if(HAL_GPIO_ReadPin(reset_SW_GPIO_Port,reset_SW_Pin)==GPIO_PIN_RESET){
131-
reset_io=1;
132-
}else{
133-
reset_io=0;
134-
rtd_io=0;
135-
rtd_start=0;
136-
HAL_GPIO_WritePin(readyToDrive_LED_GPIO_Port,readyToDrive_LED_Pin,GPIO_PIN_RESET);
137-
}
138-
}else if(GPIO_Pin==precharge_SW_Pin){
139-
//precharge pin trigger
140-
if(HAL_GPIO_ReadPin(precharge_SW_GPIO_Port,precharge_SW_Pin)==GPIO_PIN_SET){
141-
precharge_io=1;
142-
HAL_GPIO_WritePin(precharge_LED_GPIO_Port,precharge_LED_Pin,GPIO_PIN_SET);
143-
//HAL_GPIO_WritePin(CAN_fault_LED_GPIO_Port,CAN_fault_LED_Pin,GPIO_PIN_SET);
144-
}else{
145-
precharge_io=0;
146-
rtd_io=0;
147-
rtd_start=0;
148-
HAL_GPIO_WritePin(readyToDrive_LED_GPIO_Port,readyToDrive_LED_Pin,GPIO_PIN_RESET);
149-
HAL_GPIO_WritePin(precharge_LED_GPIO_Port,precharge_LED_Pin,GPIO_PIN_RESET);
150-
//HAL_GPIO_WritePin(CAN_fault_LED_GPIO_Port,CAN_fault_LED_Pin,GPIO_PIN_RESET);
151-
}
152-
}else if(GPIO_Pin==clear_fault_SW_Pin){
153-
//inverter clear fault PIN
154-
if(HAL_GPIO_ReadPin(clear_fault_SW_GPIO_Port,clear_fault_SW_Pin)==GPIO_PIN_RESET){
155-
clear_fault_io=1;
156-
}else{
157-
}
158129
}
159130
}
160131
/* USER CODE END 2 */

calibration_inverter/Core/Src/main.c

+12-44
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@
8888
/* Private variables ---------------------------------------------------------*/
8989

9090
/* USER CODE BEGIN PV */
91+
bool enable = 0;
92+
9193
uint16_t adcArr[5];
9294
static CAN_TxHeaderTypeDef TxMessage_right;
9395
static CAN_TxHeaderTypeDef TxMessage_left;
@@ -425,58 +427,24 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
425427
/* NOTE : This function should not be modified, when the callback is needed,
426428
the HAL_TIM_PeriodElapsedCallback could be implemented in the user file
427429
*/
428-
a11_var=a11();
429-
a12_var=a12();
430-
a21_var=a21();
431-
a22_var=a22();
432-
b11_var=b11();
433-
b12_var=b12();
434-
//speed_map=1;
435-
//steer_map=0.0872664626;
436-
speed_map=map_double((double)adcArr[4],0.0,4095.0,-20.0,20.0);
437-
steer_map=map_double((double)adcArr[3],0.0,4095.0,-30*RAD_REC,30*RAD_REC);
438-
beta_diff_cur=beta_diff();
439-
gamma_diff_cur = gamma_diff();
440-
counter_cur=HAL_GetTick();
441-
period = counter_cur-counter_pre;
442-
beta+=period*beta_diff()/1000;
443-
gamma+=period*gamma_diff()/1000;
444-
counter_pre=counter_cur;
445-
if((cycle % 30 ) == 0){
446-
//Gyro read
447-
adxl_read(0x32);
448-
x = ((data_rec[1] << 8) | data_rec[0]);
449-
y = ((data_rec[3] << 8) | data_rec[2]);
450-
z = ((data_rec[5] << 8) | data_rec[4]);
451-
452-
xg = x * 0.0078;
453-
yg = y * 0.0078;
454-
zg = z * 0.0078;
455-
}
430+
456431
if((cycle%20) == 0){
457432
//CAN transmit
458-
if(clear_fault_io){
459-
HAL_CAN_AddTxMessage(&hcan1,&TxMessage_R_clear,TxData_clear,&TxMailbox);
460-
HAL_CAN_AddTxMessage(&hcan1,&TxMessage_L_clear,TxData_clear,&TxMailbox);
461-
clear_fault_io=0;
462-
}
463-
torque_to_can();
433+
464434
HAL_CAN_AddTxMessage(&hcan1,&TxMessage_right,TxData_R,&TxMailbox);
465435
HAL_CAN_AddTxMessage(&hcan1,&TxMessage_left ,TxData_L,&TxMailbox);
466436
HAL_IWDG_Refresh(&hiwdg);
467437
HAL_GPIO_TogglePin(GPIOA,GPIO_PIN_1);
468438
}
469439

470-
//check apps sensor range
471-
if(!rtd_io){
472-
errorNumber = check_safety();
473-
if(!(errorNumber == 0 || errorNumber == 5)){
474-
error = 1;
475-
HAL_GPIO_WritePin(fault_LED_GPIO_Port,fault_LED_Pin,GPIO_PIN_SET);
476-
}else{
477-
error = 0;
478-
HAL_GPIO_WritePin(fault_LED_GPIO_Port,fault_LED_Pin,GPIO_PIN_RESET);
479-
}
440+
if(enable) {
441+
TxData_L[3] = 5;
442+
TxData_L[2] = 220;
443+
TxData_L[5] = 5;
444+
}else{
445+
TxData_L[3] = 0;
446+
TxData_L[2] = 0;
447+
TxData_L[5] = 0;
480448
}
481449
++cycle;
482450
}

calibration_inverter/MDK-ARM/controlBroad_program.uvguix.bob90

+45-45
Large diffs are not rendered by default.

calibration_inverter/MDK-ARM/controlBroad_program.uvoptx

+5
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,11 @@
180180
<WinNumber>1</WinNumber>
181181
<ItemText>errorNumber,0x0A</ItemText>
182182
</Ww>
183+
<Ww>
184+
<count>6</count>
185+
<WinNumber>1</WinNumber>
186+
<ItemText>enable,0x0A</ItemText>
187+
</Ww>
183188
</WatchWindow1>
184189
<Tracepoint>
185190
<THDelay>0</THDelay>
Binary file not shown.

calibration_inverter/MDK-ARM/controlBroad_program/controlBroad_program.build_log.htm

+19-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,24 @@ <h2>Project:</h2>
2727
<h2>Output:</h2>
2828
*** Using Compiler 'V5.06 update 7 (build 960)', folder: 'C:\Keil_v5\ARM\ARMCC\Bin'
2929
Build target 'controlBroad_program'
30-
"controlBroad_program\controlBroad_program.axf" - 0 Error(s), 0 Warning(s).
30+
compiling main.c...
31+
../Core/Src/main.c(211): warning: #1295-D: Deprecated declaration adxl_init - give arg types
32+
void adxl_init();
33+
../Core/Src/main.c(616): warning: #186-D: pointless comparison of unsigned integer with zero
34+
else if(APPSR>APPSRUPPEST || APPSL>APPSLUPPEST || BPPS>BPPSUPPEST||APPSR<APPSRLOWEST || APPSL<APPSLLOWEST ||BPPS<BPPSLOWEST){
35+
../Core/Src/main.c(616): warning: #186-D: pointless comparison of unsigned integer with zero
36+
else if(APPSR>APPSRUPPEST || APPSL>APPSLUPPEST || BPPS>BPPSUPPEST||APPSR<APPSRLOWEST || APPSL<APPSLLOWEST ||BPPS<BPPSLOWEST){
37+
../Core/Src/main.c(616): warning: #186-D: pointless comparison of unsigned integer with zero
38+
else if(APPSR>APPSRUPPEST || APPSL>APPSLUPPEST || BPPS>BPPSUPPEST||APPSR<APPSRLOWEST || APPSL<APPSLLOWEST ||BPPS<BPPSLOWEST){
39+
../Core/Src/main.c(96): warning: #550-D: variable "TxMessage_R_clear" was set but never used
40+
static CAN_TxHeaderTypeDef TxMessage_R_clear;
41+
../Core/Src/main.c(97): warning: #550-D: variable "TxMessage_L_clear" was set but never used
42+
static CAN_TxHeaderTypeDef TxMessage_L_clear;
43+
../Core/Src/main.c: 6 warnings, 0 errors
44+
linking...
45+
Program Size: Code=15104 RO-data=456 RW-data=160 ZI-data=1760
46+
FromELF: creating hex file...
47+
"controlBroad_program\controlBroad_program.axf" - 0 Error(s), 6 Warning(s).
3148

3249
<h2>Software Packages used:</h2>
3350

@@ -51,7 +68,7 @@ <h2>Collection of Component Files used:</h2>
5168

5269
* Component: ARM::CMSIS:CORE:5.4.0
5370
Include file: CMSIS\Core\Include\tz_context.h
54-
Build Time Elapsed: 00:00:00
71+
Build Time Elapsed: 00:00:02
5572
</pre>
5673
</body>
5774
</html>

0 commit comments

Comments
 (0)