Compare commits

..

No commits in common. "bee70b76b9f9bfe02bba05d0554d2b13b69a9767" and "17c021a2a4ea54a3881ec5467f08f6c855d33147" have entirely different histories.

2 changed files with 8 additions and 18 deletions

View File

@ -27,17 +27,13 @@
#define NTC_ADC_CHANNEL ANALOG_2 // PA2 #define NTC_ADC_CHANNEL ANALOG_2 // PA2
#define TEMP_ADC_CHANNEL ANALOG_3 // PA3 #define TEMP_ADC_CHANNEL ANALOG_3 // PA3
#define ENCODER_INV true #define ENCODER_DEBOUNCE 6000
#define ENCODER_FAST 3
#define MAX_BOARD_TEMP 50 #define MAX_BOARD_TEMP 50
#define MAX_TIP_TEMP 500 #define MAX_TIP_TEMP 500
#define TURN_OFF_DELAY 3 #define TURN_OFF_DELAY 3
#define CYCLES_PER_MEASURE 2 #define CYCLES_PER_MEASURE 2
#define BOARD_MAX_VOLTAGE 28000 #define BOARD_MAX_VOLTAGE 28000
#define MIN_TIP_SET_TEMP 100
#define MAX_TIP_SET_TEMP 420
#endif // _FUNCONFIG_H #endif // _FUNCONFIG_H

View File

@ -107,14 +107,8 @@ void update_encoder(void)
// Find the movement direction based on transition // Find the movement direction based on transition
count += state_table[last_state][current_state]; count += state_table[last_state][current_state];
#if ENCODER_INV
if (count == 4) encoder--, count = 0;
if (count == -4) encoder++, count = 0;
#else
if (count == 4) encoder++, count = 0; if (count == 4) encoder++, count = 0;
if (count == -4) encoder--, count = 0; if (count == -4) encoder--, count = 0;
#endif
// Save current state for the next interrupt // Save current state for the next interrupt
last_state = current_state; last_state = current_state;
@ -397,7 +391,7 @@ uint16_t pid(int16_t delta, int16_t max_duty)
// TODO: use a back calculation anti windup strategy // TODO: use a back calculation anti windup strategy
// only integrate if the output is less then max // only integrate if the output is less then max
if (e < i2fp(100) && e > 0) { if (e < i2fp(100)) {
intgrt = fp_add(intgrt, err_i); intgrt = fp_add(intgrt, err_i);
} }
@ -495,7 +489,6 @@ __attribute__((noreturn)) int main(void)
MIN(pd_profile.set_power, pd_profile.power_avail)*pd_profile.tip_r)/1000) * 1000) / pd_profile.voltage MIN(pd_profile.set_power, pd_profile.power_avail)*pd_profile.tip_r)/1000) * 1000) / pd_profile.voltage
, 100); , 100);
#if 0
u8g2_ClearBuffer(u8g2); u8g2_ClearBuffer(u8g2);
u8g2_SetFont(u8g2, u8g2_font_5x8_tr); u8g2_SetFont(u8g2, u8g2_font_5x8_tr);
// Display tip temperature // Display tip temperature
@ -511,8 +504,7 @@ __attribute__((noreturn)) int main(void)
u8g2_DrawStr(u8g2, x_off+45, y_off+15, "D:"); u8g2_DrawStr(u8g2, x_off+45, y_off+15, "D:");
u8g2_DrawStr(u8g2, x_off+55, y_off+15, u8g2_u16toa(pd_profile.max_duty, 3)); u8g2_DrawStr(u8g2, x_off+55, y_off+15, u8g2_u16toa(pd_profile.max_duty, 3));
u8g2_SendBuffer(u8g2); u8g2_SendBuffer(u8g2);
Delay_Ms(5000); // Delay_Ms(5000);
#endif
} }
@ -567,10 +559,12 @@ __attribute__((noreturn)) int main(void)
u8g2_DrawStr(u8g2, x_off+25, y_off+7, u8g2_u16toa(pd_profile.set_temp, 4)); u8g2_DrawStr(u8g2, x_off+25, y_off+7, u8g2_u16toa(pd_profile.set_temp, 4));
if (encoder != 0) { if (encoder != 0) {
pd_profile.set_temp += encoder >= ENCODER_FAST ? 20 : encoder; pd_profile.set_temp += encoder;
encoder = 0; encoder = 0;
if (pd_profile.set_temp < MIN_TIP_SET_TEMP) pd_profile.set_temp = MIN_TIP_SET_TEMP; #define MIN_TEMP 100
if (pd_profile.set_temp > MAX_TIP_SET_TEMP) pd_profile.set_temp = MAX_TIP_SET_TEMP; #define MAX_TEMP 360
if (pd_profile.set_temp < MIN_TEMP) pd_profile.set_temp = MIN_TEMP;
if (pd_profile.set_temp > MAX_TEMP) pd_profile.set_temp = MAX_TEMP;
} }
if (btn == 0 && prev_btn == 1) { if (btn == 0 && prev_btn == 1) {