Skip to content

Commit

Permalink
Merge pull request #92 from AxxAxx/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
AxxAxx authored Dec 26, 2024
2 parents f08617a + 93642cb commit e5e5e4f
Show file tree
Hide file tree
Showing 9 changed files with 185 additions and 161 deletions.
4 changes: 2 additions & 2 deletions AxxSolder_firmware/Core/Inc/buzzer.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
/* TypeDefs ------------------------------------------------------------------*/

/* Function prototypes -------------------------------------------------------*/
void beep(double buzzer_enabled);
void beep_startup(double buzzer_enabled);
void beep(float buzzer_enabled);
void beep_startup(float buzzer_enabled);

#endif /* INC_BUZZER_H_ */
6 changes: 3 additions & 3 deletions AxxSolder_firmware/Core/Inc/hysteresis.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

/* TypeDefs ------------------------------------------------------------------*/
typedef struct{
double previous_value; // previous value
double hysteresis; // hysteresis
float previous_value; // previous value
float hysteresis; // hysteresis
}Hysteresis_FilterTypeDef;

/* Function prototypes -------------------------------------------------------*/
void Hysteresis_Init(Hysteresis_FilterTypeDef* hysteresis_struct, float hysteresis);
double Hysteresis_Add(double new_value, Hysteresis_FilterTypeDef* hysteresis_struct);
float Hysteresis_Add(float new_value, Hysteresis_FilterTypeDef* hysteresis_struct);

#endif
45 changes: 23 additions & 22 deletions AxxSolder_firmware/Core/Inc/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,28 +33,29 @@ extern "C" {
/* USER CODE BEGIN Includes */
/* Struct to hold flash_data values */
typedef struct{
double startup_temperature;
double temperature_offset;
double standby_temp;
double standby_time;
double emergency_time;
double buzzer_enabled;
double preset_temp_1;
double preset_temp_2;
double GPIO4_ON_at_run;
double screen_rotation;
double power_limit;
double current_measurement;
double startup_beep;
double deg_celsius;
double temp_cal_100;
double temp_cal_200;
double temp_cal_300;
double temp_cal_350;
double temp_cal_400;
double temp_cal_450;
double serial_debug_print;
double displayed_temp_filter;
float startup_temperature;
float temperature_offset;
float standby_temp;
float standby_time;
float emergency_time;
float buzzer_enabled;
float preset_temp_1;
float preset_temp_2;
float GPIO4_ON_at_run;
float screen_rotation;
float power_limit;
float current_measurement;
float startup_beep;
float deg_celsius;
float temp_cal_100;
float temp_cal_200;
float temp_cal_300;
float temp_cal_350;
float temp_cal_400;
float temp_cal_450;
float serial_debug_print;
float displayed_temp_filter;
float startup_temp_is_previous_temp;
}Flash_values;

/* USER CODE END Includes */
Expand Down
70 changes: 35 additions & 35 deletions AxxSolder_firmware/Core/Inc/pid.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,66 +34,66 @@ typedef struct{

uint32_t updateOnEveryCall;

double DispKp;
double DispKi;
double DispKd;
float DispKp;
float DispKi;
float DispKd;

double Kp;
double Ki;
double Kd;
float Kp;
float Ki;
float Kd;

double DispKp_part;
double DispKi_part;
double DispKd_part;
float DispKp_part;
float DispKi_part;
float DispKd_part;

double *MyInput;
double *MyOutput;
double *MySetpoint;
float *MyInput;
float *MyOutput;
float *MySetpoint;

double OutputSum;
double LastInput;
float OutputSum;
float LastInput;

double OutMin;
double OutMax;
float OutMin;
float OutMax;

double IMin;
double IMax;
float IMin;
float IMax;

double IminError;
float IminError;

double NegativeErrorIgainMultiplier;
double NegativeErrorIgainBias;
float NegativeErrorIgainMultiplier;
float NegativeErrorIgainBias;

}PID_TypeDef;

/* Init */
void PID_Init(PID_TypeDef *uPID);

void PID(PID_TypeDef *uPID, double *Input, double *Output, double *Setpoint, double Kp, double Ki, double Kd, PIDCD_TypeDef ControllerDirection);
void PID(PID_TypeDef *uPID, float *Input, float *Output, float *Setpoint, float Kp, float Ki, float Kd, PIDCD_TypeDef ControllerDirection);

/* Function to clamp d between the limits min and max */
double double_clamp(double d, double min, double max);
float float_clamp(float d, float min, float max);

/* Function to check if clamping will occur */
uint8_t check_clamping(double d, double min, double max);
uint8_t check_clamping(float d, float min, float max);

/* Computing */
uint8_t PID_Compute(PID_TypeDef *uPID);

/* PID Limits */
void PID_SetOutputLimits(PID_TypeDef *uPID, double Min, double Max);
void PID_SetOutputLimits(PID_TypeDef *uPID, float Min, float Max);

/* PID I-windup Limits */
void PID_SetILimits(PID_TypeDef *uPID, double Min, double Max);
void PID_SetILimits(PID_TypeDef *uPID, float Min, float Max);

/* Minimum error where I is added */
void PID_SetIminError(PID_TypeDef *uPID, double IminError);
void PID_SetIminError(PID_TypeDef *uPID, float IminError);

/* Set the I gain multiplier for negative error*/
void PID_SetNegativeErrorIgainMult(PID_TypeDef *uPID, double NegativeErrorIgainMultiplier, double NegativeErrorIgainBias);
void PID_SetNegativeErrorIgainMult(PID_TypeDef *uPID, float NegativeErrorIgainMultiplier, float NegativeErrorIgainBias);

/* PID Tunings */
void PID_SetTunings(PID_TypeDef *uPID, double Kp, double Ki, double Kd);
void PID_SetTunings(PID_TypeDef *uPID, float Kp, float Ki, float Kd);

/* PID Direction */
void PID_SetControllerDirection(PID_TypeDef *uPID, PIDCD_TypeDef Direction);
Expand All @@ -105,13 +105,13 @@ void PID_SetSampleTime(PID_TypeDef *uPID, int32_t NewSampleTime, int32_t updateO
void PID_SetMode(PID_TypeDef *uPID, PIDMode_TypeDef Mode);

/* Get Tunings Param */
double PID_GetKp(PID_TypeDef *uPID);
double PID_GetKi(PID_TypeDef *uPID);
double PID_GetKd(PID_TypeDef *uPID);
float PID_GetKp(PID_TypeDef *uPID);
float PID_GetKi(PID_TypeDef *uPID);
float PID_GetKd(PID_TypeDef *uPID);

/* Get current contributions */
double PID_GetPpart(PID_TypeDef *uPID);
double PID_GetIpart(PID_TypeDef *uPID);
double PID_GetDpart(PID_TypeDef *uPID);
float PID_GetPpart(PID_TypeDef *uPID);
float PID_GetIpart(PID_TypeDef *uPID);
float PID_GetDpart(PID_TypeDef *uPID);

#endif
4 changes: 2 additions & 2 deletions AxxSolder_firmware/Core/Src/buzzer.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ extern TIM_HandleTypeDef htim4;
extern TIM_HandleTypeDef htim17;

/* Beep the beeper */
void beep(double buzzer_enabled){
void beep(float buzzer_enabled){
if(buzzer_enabled == 1){
HAL_TIM_PWM_Start_IT(&htim4, TIM_CHANNEL_2);
HAL_TIM_Base_Start_IT(&htim17);
}
}

/* Beep the beeper twice*/
void beep_startup(double buzzer_enabled){
void beep_startup(float buzzer_enabled){
beep(buzzer_enabled);
HAL_Delay(100);
beep(buzzer_enabled);
Expand Down
2 changes: 1 addition & 1 deletion AxxSolder_firmware/Core/Src/hysteresis.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ void Hysteresis_Init(Hysteresis_FilterTypeDef* hysteresis_struct, float hysteres
hysteresis_struct->previous_value = 0;
}

double Hysteresis_Add(double new_value, Hysteresis_FilterTypeDef* hysteresis_struct){
float Hysteresis_Add(float new_value, Hysteresis_FilterTypeDef* hysteresis_struct){
if((new_value >= hysteresis_struct->previous_value + hysteresis_struct->hysteresis) || (new_value <= hysteresis_struct->previous_value - hysteresis_struct->hysteresis)){
hysteresis_struct->previous_value = new_value;
return new_value;
Expand Down
Loading

0 comments on commit e5e5e4f

Please sign in to comment.