mirror of
https://github.com/rene-dev/stmbl.git
synced 2026-02-06 02:02:34 +08:00
curpid fix, make fix, ls fix, hal nan error, hal stop fix
This commit is contained in:
@@ -189,10 +189,10 @@ showsize: build
|
||||
|
||||
# Flash the device
|
||||
#
|
||||
btburn: build showsize $(TARGET).dfu
|
||||
btburn: $(TARGET).dfu
|
||||
@tools/bootloader.py
|
||||
@sleep 1
|
||||
@dfu-util -d 0483:df11 -a 0 -s 0x08010000:leave -D $(TARGET).dfu
|
||||
@dfu-util -d 0483:df11 -a 0 -s 0x08000000:leave -D $(TARGET).dfu
|
||||
|
||||
flash: $(TARGET).bin
|
||||
st-flash --reset write $(TARGET).bin 0x08000000
|
||||
|
||||
@@ -183,6 +183,7 @@ void hal_stop(){
|
||||
hal_stop_rt();
|
||||
hal_disable_frt();
|
||||
hal_disable_rt();
|
||||
hal.hal_state = HAL2_OK;
|
||||
for(; hal.rt_deinit_func_count > 0; hal.rt_deinit_func_count--){
|
||||
hal.rt_deinit[hal.rt_deinit_func_count - 1]();
|
||||
}
|
||||
|
||||
@@ -97,6 +97,7 @@ typedef struct{
|
||||
MEM_ERROR,
|
||||
CONFIG_LOAD_ERROR,
|
||||
CONFIG_ERROR,
|
||||
NAN_ERROR,
|
||||
HAL2_OK
|
||||
} hal_state;
|
||||
|
||||
|
||||
@@ -18,6 +18,8 @@ HAL_PIN(tim_oc) = 0.0;
|
||||
MEM(int lastq) = 0;// last quadrant
|
||||
MEM(int abspos) = 0;// multiturn position
|
||||
|
||||
// TODO: in hal stop, reset adc dma
|
||||
|
||||
RT_INIT(
|
||||
//timer init for v4, v3 uses slave timer
|
||||
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM4, ENABLE);
|
||||
|
||||
@@ -157,7 +157,12 @@ void DMA2_Stream0_IRQHandler(void){
|
||||
PIN(rt_time) = ((float)(start - end)) / hal_get_systick_freq();
|
||||
PIN(rt_period_time) = period;
|
||||
|
||||
hal.rt_state = RT_SLEEP;
|
||||
if(hal.hal_state != HAL2_OK){
|
||||
hal.rt_state = RT_STOP;
|
||||
}
|
||||
else{
|
||||
hal.rt_state = RT_SLEEP;
|
||||
}
|
||||
}
|
||||
|
||||
int main(void)
|
||||
|
||||
@@ -47,9 +47,9 @@ RT(
|
||||
|
||||
float ff = PIN(ff);
|
||||
float kind = PIN(kind);
|
||||
float kpd = ld * PIN(kp) / period;
|
||||
float kpd = ld * PIN(kp) / period / 2.0;
|
||||
float kid = rd * PIN(ki) / ld;
|
||||
float kpq = lq * PIN(kp) / period;
|
||||
float kpq = lq * PIN(kp) / period / 2.0;
|
||||
float kiq = rq * PIN(ki) / lq;
|
||||
|
||||
//TODO curpid: sqrt(di^2+qi^2) auf max_ac_cur clampen
|
||||
|
||||
@@ -122,16 +122,15 @@ RT(
|
||||
|
||||
// TODO: sin = 0.5
|
||||
if(config.pins.mode == 0){// 90°
|
||||
packet_from_hv.data.pwm_volt = PIN(dc_volt) / M_SQRT2 * 0.95;
|
||||
PIN(pwm_volt) = PIN(dc_volt) / M_SQRT2 * 0.95;
|
||||
}else if(config.pins.mode == 1){// 120°
|
||||
packet_from_hv.data.pwm_volt = PIN(dc_volt) / M_SQRT3 * 0.95;
|
||||
PIN(pwm_volt) = PIN(dc_volt) / M_SQRT3 * 0.95;
|
||||
}else if(config.pins.mode == 2){// 180°
|
||||
packet_from_hv.data.pwm_volt = PIN(dc_volt) * 0.95;
|
||||
PIN(pwm_volt) = PIN(dc_volt) * 0.95;
|
||||
}else{
|
||||
packet_from_hv.data.pwm_volt = 0.0;
|
||||
PIN(pwm_volt) = 0.0;
|
||||
}
|
||||
PIN(pwm_volt) = packet_from_hv.data.pwm_volt;
|
||||
|
||||
|
||||
state.pins.u_fb = PIN(u_fb);
|
||||
state.pins.v_fb = PIN(v_fb);
|
||||
state.pins.w_fb = PIN(w_fb);
|
||||
@@ -147,6 +146,7 @@ RT(
|
||||
datapos = 0;
|
||||
((uint8_t*)&packet_to_hv)[datapos++] = (uint8_t)buf;
|
||||
packet_from_hv.data.dc_volt = PIN(dc_volt);
|
||||
packet_from_hv.data.pwm_volt = PIN(pwm_volt);
|
||||
packet_from_hv.data.d_fb = PIN(d_fb);
|
||||
packet_from_hv.data.q_fb = PIN(q_fb);
|
||||
packet_from_hv.data.addr = addr;
|
||||
|
||||
Reference in New Issue
Block a user