This commit is contained in:
andrea
2026-05-14 19:44:46 +02:00
parent e38f1455ef
commit 4d139b6fcf
110 changed files with 50494 additions and 66484 deletions

View File

@@ -1,6 +1,7 @@
#include <stdio.h>
#include <string.h>
#include "eeprom.h"
#include "pwm.h"
extern UART_HandleTypeDef huart1;
/*
* Record format (4 bytes):
@@ -37,6 +38,7 @@ extern uint16_t m1pwmMan;
extern uint16_t m2pwmMan;
extern uint16_t m3pwmMan;
extern uint16_t m4pwmMan;
extern uint16_t mrampstart[];
extern uint16_t apM1start;
@@ -432,6 +434,13 @@ void loadEE(void){
EEW_Read(M3PWMCH, &m3pwmch);
EEW_Read(M4PWMAP, &m4pwmap);
EEW_Read(M4PWMCH, &m4pwmch);
EEW_Read(M1RAMPSTART, &mrampstart[M1-1]);
EEW_Read(M2RAMPSTART, &mrampstart[M2-1]);
EEW_Read(M3RAMPSTART, &mrampstart[M3-1]);
EEW_Read(M4RAMPSTART, &mrampstart[M4-1]);
EEW_Read(M1TIMEOUTMAN, &m1TimeoutMan);
EEW_Read(M2TIMEOUTMAN, &m2TimeoutMan);
EEW_Read(M3TIMEOUTMAN, &m3TimeoutMan);

View File

@@ -366,7 +366,7 @@ motMov_st m4ch(void){
SetMotPerc(M4,FW,0);
SetMotPerc(M4,BW,0);
if(rtCiclo>=chM4start){
(void)ramp(M4,FW,mrampstart[M4-1],m2pwmch,tramp,RAMPINIT);
(void)ramp(M4,FW,mrampstart[M4-1],m4pwmch,tramp,RAMPINIT);
m4st=motStartRamp;
}
break;

View File

@@ -5,7 +5,8 @@
* Author: user
*/
#include <stdio.h>
#include <string.h>
#include "stm32f1xx_hal.h"
#include "main.h"
#include "pwm.h"
@@ -14,8 +15,10 @@ extern TIM_HandleTypeDef htim1;
extern TIM_HandleTypeDef htim2;
extern TIM_HandleTypeDef htim3;
extern TIM_HandleTypeDef htim4;
extern volatile uint8_t rtramp[4];
extern uint8_t mrampstart[4];
extern volatile uint16_t rtramp[4];
extern uint16_t mrampstart[4];
extern UART_HandleTypeDef huart1;
bool IsPwmRunning(TIM_HandleTypeDef *htim, uint32_t Channel)
{
HAL_TIM_ChannelStateTypeDef chState = HAL_TIM_GetChannelState(htim, Channel);
@@ -246,27 +249,30 @@ void SetMotPerc(uint8_t mot,uint8_t dir,uint8_t perc){
uint8_t ramp(uint8_t mot,uint8_t dir,uint8_t percStart,uint8_t percEnd,uint8_t tr,uint8_t mode){
static uint8_t memrtramp[4];
// char s[10];
uint16_t delta;
switch(mode){
case RAMPINIT:
memrtramp[mot-1]=percStart=tr;
SetMotPerc(mot,dir,mrampstart[mot-1]);
memrtramp[mot-1]=rtramp[mot-1]=tr;
SetMotPerc(mot,dir,percStart);
return DONE;
case RAMPRUN:
if(memrtramp[mot-1]!=rtramp[mot-1]){
memrtramp[mot-1]=rtramp[mot-1];
if(rtramp[mot-1]){
if(mrampstart[mot-1]>percEnd){
delta=mrampstart[mot-1]-percEnd;
if(percStart>percEnd){
delta=percStart-percEnd;
delta=delta*(uint16_t)(tr-rtramp[mot-1]);
delta=delta/tr;
SetMotPerc(mot,dir,mrampstart[mot-1]-delta);
SetMotPerc(mot,dir,percStart-delta);
return RUNNING;
}else if(mrampstart[mot-1]<percEnd){
delta=percEnd-mrampstart[mot-1];
}else if(percStart<percEnd){
delta=percEnd-percStart;
delta=delta*(uint16_t)(tr-rtramp[mot-1]);
delta=delta/tr;
SetMotPerc(mot,dir,mrampstart[mot-1]+delta);
SetMotPerc(mot,dir,percStart+delta);
// sprintf((char*)s,"\n%d",percStart+delta);
// HAL_UART_Transmit(&huart1,(uint8_t*) s, strlen(s), HAL_MAX_DELAY);
return RUNNING;
}else{
SetMotPerc(mot,dir,percEnd);

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,13 +1,13 @@
../Core/Src/eeprom.h:121:24:EEW_Read 1
../Core/Src/eeprom.c:160:17:EE_GetPageStatus 1
../Core/Src/eeprom.c:165:26:EE_FlashProgramHalfWord 1
../Core/Src/eeprom.c:176:26:EE_FlashErasePage 1
../Core/Src/eeprom.c:195:17:EE_FindFreeAddress 3
../Core/Src/eeprom.c:217:18:EE_FindInPage 6
../Core/Src/eeprom.c:257:18:EE_Format 4
../Core/Src/eeprom.c:275:17:EE_GetOtherPageBase 2
../Core/Src/eeprom.c:281:18:EE_PageTransfer 11
../Core/Src/eeprom.c:354:10:EE_Init 7
../Core/Src/eeprom.c:385:10:EE_ReadVariable 2
../Core/Src/eeprom.c:402:10:EE_WriteVariable 4
../Core/Src/eeprom.c:425:6:loadEE 1
../Core/Src/eeprom.c:162:17:EE_GetPageStatus 1
../Core/Src/eeprom.c:167:26:EE_FlashProgramHalfWord 1
../Core/Src/eeprom.c:178:26:EE_FlashErasePage 1
../Core/Src/eeprom.c:197:17:EE_FindFreeAddress 3
../Core/Src/eeprom.c:219:18:EE_FindInPage 6
../Core/Src/eeprom.c:259:18:EE_Format 4
../Core/Src/eeprom.c:277:17:EE_GetOtherPageBase 2
../Core/Src/eeprom.c:283:18:EE_PageTransfer 11
../Core/Src/eeprom.c:356:10:EE_Init 7
../Core/Src/eeprom.c:387:10:EE_ReadVariable 2
../Core/Src/eeprom.c:404:10:EE_WriteVariable 4
../Core/Src/eeprom.c:427:6:loadEE 1

View File

@@ -28,7 +28,8 @@ Core/Src/eeprom.o: ../Core/Src/eeprom.c ../Core/Src/eeprom.h \
../Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_uart.h \
../Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_pcd.h \
../Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_usb.h \
../Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_pcd_ex.h
../Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_pcd_ex.h \
../Core/Inc/pwm.h
../Core/Src/eeprom.h:
../Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal.h:
../Core/Inc/stm32f1xx_hal_conf.h:
@@ -60,3 +61,4 @@ Core/Src/eeprom.o: ../Core/Src/eeprom.c ../Core/Src/eeprom.h \
../Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_pcd.h:
../Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_usb.h:
../Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_pcd_ex.h:
../Core/Inc/pwm.h:

View File

@@ -1,13 +1,13 @@
../Core/Src/eeprom.h:121:24:EEW_Read 16 static
../Core/Src/eeprom.c:160:17:EE_GetPageStatus 16 static
../Core/Src/eeprom.c:165:26:EE_FlashProgramHalfWord 32 static
../Core/Src/eeprom.c:176:26:EE_FlashErasePage 40 static
../Core/Src/eeprom.c:195:17:EE_FindFreeAddress 32 static
../Core/Src/eeprom.c:217:18:EE_FindInPage 40 static
../Core/Src/eeprom.c:257:18:EE_Format 8 static
../Core/Src/eeprom.c:275:17:EE_GetOtherPageBase 16 static
../Core/Src/eeprom.c:281:18:EE_PageTransfer 40 static
../Core/Src/eeprom.c:354:10:EE_Init 16 static
../Core/Src/eeprom.c:385:10:EE_ReadVariable 24 static
../Core/Src/eeprom.c:402:10:EE_WriteVariable 24 static
../Core/Src/eeprom.c:425:6:loadEE 248 static
../Core/Src/eeprom.c:162:17:EE_GetPageStatus 16 static
../Core/Src/eeprom.c:167:26:EE_FlashProgramHalfWord 32 static
../Core/Src/eeprom.c:178:26:EE_FlashErasePage 40 static
../Core/Src/eeprom.c:197:17:EE_FindFreeAddress 32 static
../Core/Src/eeprom.c:219:18:EE_FindInPage 40 static
../Core/Src/eeprom.c:259:18:EE_Format 8 static
../Core/Src/eeprom.c:277:17:EE_GetOtherPageBase 16 static
../Core/Src/eeprom.c:283:18:EE_PageTransfer 40 static
../Core/Src/eeprom.c:356:10:EE_Init 16 static
../Core/Src/eeprom.c:387:10:EE_ReadVariable 24 static
../Core/Src/eeprom.c:404:10:EE_WriteVariable 24 static
../Core/Src/eeprom.c:427:6:loadEE 248 static

View File

@@ -1,7 +1,7 @@
../Core/Src/pwm.c:19:6:IsPwmRunning 1
../Core/Src/pwm.c:26:6:StopMot 1
../Core/Src/pwm.c:30:6:StartMot 4
../Core/Src/pwm.c:35:6:SetMotPwm 4
../Core/Src/pwm.c:39:6:SetMot 25
../Core/Src/pwm.c:140:6:SetMotPerc 25
../Core/Src/pwm.c:247:9:ramp 7
../Core/Src/pwm.c:22:6:IsPwmRunning 1
../Core/Src/pwm.c:29:6:StopMot 1
../Core/Src/pwm.c:33:6:StartMot 4
../Core/Src/pwm.c:38:6:SetMotPwm 4
../Core/Src/pwm.c:42:6:SetMot 25
../Core/Src/pwm.c:143:6:SetMotPerc 25
../Core/Src/pwm.c:250:9:ramp 7

View File

@@ -1,7 +1,7 @@
../Core/Src/pwm.c:19:6:IsPwmRunning 24 static
../Core/Src/pwm.c:26:6:StopMot 16 static
../Core/Src/pwm.c:30:6:StartMot 24 static
../Core/Src/pwm.c:35:6:SetMotPwm 24 static
../Core/Src/pwm.c:39:6:SetMot 16 static
../Core/Src/pwm.c:140:6:SetMotPerc 24 static
../Core/Src/pwm.c:247:9:ramp 32 static
../Core/Src/pwm.c:22:6:IsPwmRunning 24 static
../Core/Src/pwm.c:29:6:StopMot 16 static
../Core/Src/pwm.c:33:6:StartMot 24 static
../Core/Src/pwm.c:38:6:SetMotPwm 24 static
../Core/Src/pwm.c:42:6:SetMot 16 static
../Core/Src/pwm.c:143:6:SetMotPerc 24 static
../Core/Src/pwm.c:250:9:ramp 32 static