mirror of
https://github.com/rene-dev/stmbl.git
synced 2026-08-18 01:18:58 +08:00
id
This commit is contained in:
@@ -4,11 +4,10 @@ iddc0.rt_prio = 4
|
||||
|
||||
iddc0.en = fault0.en_out
|
||||
fault0.pos_error = 0
|
||||
pid0.enable = 0
|
||||
pid0.en = 0
|
||||
hv0.en = iddc0.en_out
|
||||
hv0.cur_bw = iddc0.cur_bw
|
||||
hv0.cmd_mode = iddc0.cmd_mode
|
||||
hv0.d_cmd = iddc0.d_cmd
|
||||
hv0.q_cmd = iddc0.q_cmd
|
||||
hv0.pos = iddc0.com_pos
|
||||
hv0.rev = iddc0.out_rev
|
||||
@@ -25,4 +24,6 @@ iddc0.pos_fb = fb_switch0.pos_fb
|
||||
iddc0.vel_fb = vel1.vel
|
||||
|
||||
vel0.pos_in = fb_switch0.pos_fb
|
||||
iddc0.vel_fb = vel1.vel
|
||||
iddc0.vel_fb = vel1.vel
|
||||
|
||||
iddc0.test_cur = conf0.max_ac_cur
|
||||
@@ -25,4 +25,6 @@ idpmsm0.pos_fb = fb_switch0.mot_abs_fb_no_offset
|
||||
idpmsm0.vel_fb = vel1.vel
|
||||
|
||||
vel0.pos_in = fb_switch0.pos_fb
|
||||
idpmsm0.vel_fb = vel1.vel
|
||||
idpmsm0.vel_fb = vel1.vel
|
||||
|
||||
idpmsm0.test_cur = conf0.max_ac_cur
|
||||
+19
-28
@@ -5,16 +5,13 @@
|
||||
|
||||
HAL_COMP(iddc);
|
||||
|
||||
HAL_PIN(d_cmd);
|
||||
HAL_PIN(q_cmd);
|
||||
HAL_PIN(com_pos);
|
||||
HAL_PIN(cmd_mode);
|
||||
HAL_PIN(en);
|
||||
HAL_PIN(en_out);
|
||||
|
||||
HAL_PIN(id_fb);
|
||||
HAL_PIN(iq_fb);
|
||||
HAL_PIN(ud_fb);
|
||||
HAL_PIN(uq_fb);
|
||||
HAL_PIN(pos_fb);
|
||||
HAL_PIN(vel_fb);
|
||||
@@ -54,7 +51,7 @@ static void nrt_init(void *ctx_ptr, hal_pin_inst_t *pin_ptr) {
|
||||
struct iddc_pin_ctx_t *pins = (struct iddc_pin_ctx_t *)pin_ptr;
|
||||
PIN(test_cur) = 4.0;
|
||||
PIN(test_vel) = 50.0;
|
||||
PIN(ki) = 1.0;
|
||||
PIN(ki) = 2.0;
|
||||
PIN(pi) = 1.0;
|
||||
PIN(vel_bw) = 20.0;
|
||||
PIN(cur_bw) = 1.0;
|
||||
@@ -78,14 +75,13 @@ static void nrt(void *ctx_ptr, hal_pin_inst_t *pin_ptr) {
|
||||
case 10: // r
|
||||
PIN(state) = 1.1;
|
||||
PIN(timer) = 0.0;
|
||||
PIN(d_cmd) = 0.0;
|
||||
PIN(q_cmd) = 0.0;
|
||||
PIN(com_pos) = 0.0;
|
||||
PIN(cmd_mode) = 0.0;
|
||||
|
||||
printf("Measure r, l\n");
|
||||
printf("<font color='green'>block the rotor</font>\n");
|
||||
printf("id0.state = 1.2 <font color='green'>to start</font>\n");
|
||||
printf("iddc0.state = 1.2 <font color='green'>to start</font>\n");
|
||||
break;
|
||||
|
||||
case 14:
|
||||
@@ -97,7 +93,6 @@ static void nrt(void *ctx_ptr, hal_pin_inst_t *pin_ptr) {
|
||||
case 20:
|
||||
PIN(state) = 3.1;
|
||||
PIN(timer) = 0.0;
|
||||
PIN(d_cmd) = 0.0;
|
||||
PIN(q_cmd) = 0.0;
|
||||
PIN(cur_sum) = 0.0;
|
||||
PIN(cmd_mode) = 0.0;
|
||||
@@ -106,7 +101,7 @@ static void nrt(void *ctx_ptr, hal_pin_inst_t *pin_ptr) {
|
||||
printf("Measure torque constant\n");
|
||||
printf("<font color='green'>unblock the rotor</font>\n");
|
||||
printf("the motor will move\n");
|
||||
printf("id0.state = 2.2 <font color='green'>to start</font>\n");
|
||||
printf("iddc0.state = 2.2 <font color='green'>to start</font>\n");
|
||||
break;
|
||||
|
||||
case 23:
|
||||
@@ -135,9 +130,8 @@ static void rt_func(float period, void *ctx_ptr, hal_pin_inst_t *pin_ptr) {
|
||||
PIN(en_out) = 0.0;
|
||||
PIN(cmd_mode) = 0.0;
|
||||
PIN(timer) = 0.0;
|
||||
PIN(d_cmd) = 0.0;
|
||||
PIN(q_cmd) = 0.0;
|
||||
PIN(cur_bw) = 1.0;
|
||||
PIN(cur_bw) = 10.0;
|
||||
|
||||
if(PIN(en) > 0.0){
|
||||
PIN(state) = 1.0;
|
||||
@@ -147,19 +141,17 @@ static void rt_func(float period, void *ctx_ptr, hal_pin_inst_t *pin_ptr) {
|
||||
case 12: // r
|
||||
PIN(en_out) = 1.0;
|
||||
PIN(cmd_mode) = 1.0;
|
||||
PIN(cur_bw) = 1.0;
|
||||
PIN(q_cmd) = 0.0;
|
||||
PIN(cur_bw) = 10.0;
|
||||
PIN(com_pos) = 0.0;
|
||||
|
||||
PIN(d_cmd) = PIN(test_cur);
|
||||
PIN(q_cmd) = PIN(test_cur);
|
||||
|
||||
PIN(r) = PIN(r) * 0.99 + PIN(ud_fb) / MAX(PIN(id_fb), 0.01) * 0.01;
|
||||
PIN(r) = PIN(r) * 0.99 + PIN(uq_fb) / MAX(PIN(iq_fb), 0.01) * 0.01;
|
||||
|
||||
PIN(timer) += period;
|
||||
if(PIN(timer) >= 2.0){
|
||||
PIN(timer) = 0.0;
|
||||
PIN(state) = 1.3;
|
||||
PIN(d_cmd) = 0.0;
|
||||
PIN(en_out) = 0.0;
|
||||
PIN(tmp0) = 0.0;
|
||||
PIN(tmp1) = 0.0;
|
||||
@@ -172,19 +164,18 @@ static void rt_func(float period, void *ctx_ptr, hal_pin_inst_t *pin_ptr) {
|
||||
case 13: // l
|
||||
PIN(en_out) = 1.0;
|
||||
PIN(cmd_mode) = 0.0;
|
||||
PIN(q_cmd) = 0.0;
|
||||
PIN(cur_bw) = 1.0;
|
||||
PIN(cur_bw) = 10.0;
|
||||
|
||||
//PIN(l) = PIN(l) * 0.995 + ABS(PIN(ud_fb) - avg_test_volt / 2.0) / MAX(ABS(PIN(id_fb) - PIN(test_cur)), 0.001) * period * 0.005;
|
||||
if(PIN(d_cmd) < PIN(avg_test_volt)){
|
||||
PIN(tmp0) = PIN(tmp0) * 0.99 + PIN(id_fb) * 0.01;
|
||||
PIN(tmp1) = PIN(tmp1) * 0.99 + PIN(ud_fb) * 0.01;
|
||||
PIN(d_cmd) = PIN(avg_test_volt) * 1.5;
|
||||
//PIN(l) = PIN(l) * 0.995 + ABS(PIN(uq_fb) - avg_test_volt / 2.0) / MAX(ABS(PIN(iq_fb) - PIN(test_cur)), 0.001) * period * 0.005;
|
||||
if(PIN(q_cmd) < PIN(avg_test_volt)){
|
||||
PIN(tmp0) = PIN(tmp0) * 0.99 + PIN(iq_fb) * 0.01;
|
||||
PIN(tmp1) = PIN(tmp1) * 0.99 + PIN(uq_fb) * 0.01;
|
||||
PIN(q_cmd) = PIN(avg_test_volt) * 1.5;
|
||||
}
|
||||
else{
|
||||
PIN(tmp2) = PIN(tmp2) * 0.99 + PIN(id_fb) * 0.01;
|
||||
PIN(tmp3) = PIN(tmp3) * 0.99 + PIN(ud_fb) * 0.01;
|
||||
PIN(d_cmd) = PIN(avg_test_volt) * 0.5;
|
||||
PIN(tmp2) = PIN(tmp2) * 0.99 + PIN(iq_fb) * 0.01;
|
||||
PIN(tmp3) = PIN(tmp3) * 0.99 + PIN(uq_fb) * 0.01;
|
||||
PIN(q_cmd) = PIN(avg_test_volt) * 0.5;
|
||||
}
|
||||
|
||||
PIN(timer) += period;
|
||||
@@ -192,7 +183,7 @@ static void rt_func(float period, void *ctx_ptr, hal_pin_inst_t *pin_ptr) {
|
||||
PIN(l) = ABS(PIN(tmp1) - PIN(tmp3)) / ABS(PIN(tmp0) - PIN(tmp2)) * period;
|
||||
PIN(timer) = 0.0;
|
||||
PIN(state) = 1.4;
|
||||
PIN(d_cmd) = PIN(avg_test_volt);
|
||||
PIN(q_cmd) = PIN(avg_test_volt);
|
||||
PIN(en_out) = 0.0;
|
||||
// PIN(tmp0) = 0.0;
|
||||
// PIN(tmp1) = 0.0;
|
||||
@@ -203,9 +194,10 @@ static void rt_func(float period, void *ctx_ptr, hal_pin_inst_t *pin_ptr) {
|
||||
PIN(en_out) = 1.0;
|
||||
PIN(cmd_mode) = 1.0;
|
||||
PIN(cur_bw) = 250.0;
|
||||
PIN(d_cmd) = 0.0;
|
||||
|
||||
float vel_error = PIN(test_vel) - ABS(PIN(vel_fb));
|
||||
vel_error = LIMIT(vel_error, PIN(test_vel) / 10.0);
|
||||
|
||||
PIN(cur_sum) += PIN(ki) * vel_error * period;
|
||||
|
||||
PIN(q_cmd) = PIN(vel_bw) * period * vel_error + PIN(cur_sum);
|
||||
@@ -226,7 +218,6 @@ static void rt_func(float period, void *ctx_ptr, hal_pin_inst_t *pin_ptr) {
|
||||
|
||||
PIN(timer) = 0.0;
|
||||
PIN(en_out) = 0.0;
|
||||
PIN(d_cmd) = 0.0;
|
||||
PIN(q_cmd) = 0.0;
|
||||
PIN(cur_sum) = 0.0;
|
||||
PIN(cmd_mode) = 0.0;
|
||||
|
||||
+1
-1
@@ -84,7 +84,7 @@ static void nrt(void *ctx_ptr, hal_pin_inst_t *pin_ptr) {
|
||||
else{
|
||||
printf("Measure friction, damping and inertia\n");
|
||||
printf("the motor will move\n");
|
||||
printf("id0.state = 1.2 <font color='green'>to start</font>\n");
|
||||
printf("idm0.state = 1.2 <font color='green'>to start</font>\n");
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ static void nrt(void *ctx_ptr, hal_pin_inst_t *pin_ptr) {
|
||||
else{
|
||||
printf("Measure r, l\n");
|
||||
printf("the motor can move a bit\n");
|
||||
printf("id0.state = 1.2 <font color='green'>to start</font>\n");
|
||||
printf("idpmsm0.state = 1.2 <font color='green'>to start</font>\n");
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -115,7 +115,7 @@ static void nrt(void *ctx_ptr, hal_pin_inst_t *pin_ptr) {
|
||||
else{
|
||||
printf("Measure com_offset, polepairs, out_rev\n");
|
||||
printf("the motor will move\n");
|
||||
printf("id0.state = 2.2 <font color='green'>to start</font>\n");
|
||||
printf("idpmsm0.state = 2.2 <font color='green'>to start</font>\n");
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user