Compare commits
3 Commits
a7d3ceaffe
...
b4086ddea0
| Author | SHA1 | Date | |
|---|---|---|---|
| b4086ddea0 | |||
| ccdf7e9981 | |||
| d875568d9a |
11
fw/main.c
11
fw/main.c
@ -353,7 +353,7 @@ uint16_t pid(int16_t delta, int16_t max_duty)
|
|||||||
// PID coefficients
|
// PID coefficients
|
||||||
const fp16_t Kp = num2fp( 1, 1700, 4);
|
const fp16_t Kp = num2fp( 1, 1700, 4);
|
||||||
const fp16_t Ti = num2fp(10, 0000, 4);
|
const fp16_t Ti = num2fp(10, 0000, 4);
|
||||||
const fp16_t Td = num2fp( 0, 700, 4);
|
const fp16_t Td = num2fp( 0, 1500, 4);
|
||||||
|
|
||||||
static fp16_t err_p, err_i, intgrt, err_d, dt, prev_err;
|
static fp16_t err_p, err_i, intgrt, err_d, dt, prev_err;
|
||||||
static u32 t, prev_t;
|
static u32 t, prev_t;
|
||||||
@ -361,6 +361,9 @@ uint16_t pid(int16_t delta, int16_t max_duty)
|
|||||||
t = funSysTick32();
|
t = funSysTick32();
|
||||||
dt = fp_div(i2fp((t-prev_t)/DELAY_MS_TIME), i2fp(1000));
|
dt = fp_div(i2fp((t-prev_t)/DELAY_MS_TIME), i2fp(1000));
|
||||||
|
|
||||||
|
// if pid was paused, reset the integrator
|
||||||
|
if (dt > num2fp(0, 2, 1)) intgrt = 0;
|
||||||
|
|
||||||
fp16_t err = i2fp(delta); // temperature delta as fixed point number
|
fp16_t err = i2fp(delta); // temperature delta as fixed point number
|
||||||
|
|
||||||
err_p = err;
|
err_p = err;
|
||||||
@ -460,6 +463,8 @@ static inline void setup(void)
|
|||||||
|
|
||||||
__attribute__((noreturn)) int main(void)
|
__attribute__((noreturn)) int main(void)
|
||||||
{
|
{
|
||||||
|
setup();
|
||||||
|
|
||||||
u8g2_ClearBuffer(u8g2);
|
u8g2_ClearBuffer(u8g2);
|
||||||
u8g2_SetFont(u8g2, u8g2_font_5x8_tr);
|
u8g2_SetFont(u8g2, u8g2_font_5x8_tr);
|
||||||
u8g2_DrawStr(u8g2, x_off+0, y_off+7, "Negotiating...");
|
u8g2_DrawStr(u8g2, x_off+0, y_off+7, "Negotiating...");
|
||||||
@ -480,11 +485,11 @@ __attribute__((noreturn)) int main(void)
|
|||||||
Delay_Ms(100);
|
Delay_Ms(100);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
pd_get_profile(&pd_profile, 60);
|
pd_get_profile(&pd_profile, 100);
|
||||||
|
|
||||||
// TODO: let the user decide the power profile
|
// TODO: let the user decide the power profile
|
||||||
pd_profile.set_temp = 200;
|
pd_profile.set_temp = 200;
|
||||||
pd_profile.set_power = 60; // Slightly below max power to avoid overloading
|
pd_profile.set_power = 95; // Slightly below max power to avoid overloading
|
||||||
pd_profile.tip_r = 2500; // TODO: tip check and resistance calculator
|
pd_profile.tip_r = 2500; // TODO: tip check and resistance calculator
|
||||||
pd_profile.max_duty = MIN(
|
pd_profile.max_duty = MIN(
|
||||||
(100*(u32)isqrt((
|
(100*(u32)isqrt((
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user