Skip to content

Commit

Permalink
Added freewheeling option in forced control.
Browse files Browse the repository at this point in the history
  • Loading branch information
rombrew committed Feb 25, 2024
1 parent 127c187 commit a5ddebc
Show file tree
Hide file tree
Showing 20 changed files with 285 additions and 207 deletions.
34 changes: 30 additions & 4 deletions bench/tsfunc.c
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ void ts_script_test()
m.Udc = 48.;
m.Rdc = 0.1;
m.Zp = 5;
m.lambda = blm_Kv_lambda(&m, 525.);
m.lambda = blm_Kv_lambda(&m, 525.);
m.Jm = 2.E-4;

ts_script_default();
Expand All @@ -695,7 +695,7 @@ void ts_script_test()
blm_restart(&m);

/*ts_script_hfi();
blm_restart(&m);*/
blm_restart(&m);*/

printf("\n---- Turnigy RotoMax 1.20 ----\n");

Expand All @@ -707,7 +707,7 @@ void ts_script_test()
m.Udc = 22.;
m.Rdc = 0.1;
m.Zp = 14;
m.lambda = blm_Kv_lambda(&m, 270.);
m.lambda = blm_Kv_lambda(&m, 270.);
m.Jm = 3.E-4;

ts_script_default();
Expand Down Expand Up @@ -736,7 +736,7 @@ void ts_script_test()
m.Udc = 48.;
m.Rdc = 0.5;
m.Zp = 15;
m.lambda = blm_Kv_lambda(&m, 15.7);
m.lambda = blm_Kv_lambda(&m, 15.);
m.Jm = 6.E-3;

ts_script_default();
Expand All @@ -751,5 +751,31 @@ void ts_script_test()

ts_script_hall();
blm_restart(&m);

printf("\n---- QS 138 (3000W) ----\n");

tlm_restart();

m.Rs = 4.E-3;
m.Ld = 31.E-6;
m.Lq = 44.E-6;
m.Udc = 48.;
m.Rdc = 0.1;
m.Zp = 5;
m.lambda = blm_Kv_lambda(&m, 58.);
m.Jm = 4.E-3;

ts_script_default();
ts_script_base();
blm_restart(&m);

ts_script_speed();
blm_restart(&m);

/*ts_script_weakening();
blm_restart(&m);*/

ts_script_hall();
blm_restart(&m);
}

2 changes: 1 addition & 1 deletion doc/HardwareVESC.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This page gives you an overview of VESC hardware supported by PMC.
| Item | HWREV | Notes |
|:--------------------------------------|:-----------:|:------------------|
| FLIPSKY FSESC 6.7 | FSESC67 | Bad PCB design |
| FLIPSKY MINI FSESC 6.7 PRO | FSESC67PRO | Low side shunts |
| FLIPSKY MINI FSESC 6.7 PRO | FSESC67MINI | Low side shunts |
| FLIPSKY 75100 V202 ESC | FSESC75100 | Low side shunts |
| Makerbase VESC 75200 V2 84V 200A | FSESC75100 | Low side shunts |
| Holybro Mini FOC ESC Based on VESC6 | HBESC6FOC | |
Expand Down
8 changes: 4 additions & 4 deletions doc/InputAnalogKnob.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,14 @@ Now you are ready to enable the analog knob interface.

To stop the control we check if machine is run or setpoint is high. If setpoint
is out of input range and machine does not make full turns for
`ap.idle_timeout` seconds the shutdown is requested.
`ap.timeout_IDLE` seconds the shutdown is requested.

(pmc) reg ap.idle_timeout <s>
(pmc) reg ap.timeout_IDLE <s>

# Disarm timeout

To ensure a safe startup it is required to hold low `ANG` signal for
`ap.disarm_timeout` seconds until disarmed state was reset.
`ap.timeout_DISARM` seconds until disarmed state was reset.

(pmc) reg ap.disarm_timeout <s>
(pmc) reg ap.timeout_DISARM <s>

9 changes: 3 additions & 6 deletions phobia/link.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ link_fetch_network(struct link_pmc *lp)

if (strstr(lbuf, "(pmc)") == lbuf) {

sprintf(lp->network, "local");
sprintf(lp->network, "SERIAL");

rc = 1;
}
Expand All @@ -201,7 +201,7 @@ link_fetch_network(struct link_pmc *lp)

if (lk_stoi(&n, lbuf + 5) != NULL) {

sprintf(lp->network, "remote/%i", n);
sprintf(lp->network, "REMOTE/%i", n);
}
else {
lp->network[0] = 0;
Expand Down Expand Up @@ -370,10 +370,7 @@ link_fetch_hwinfo(struct link_pmc *lp)

tok = lk_token(&sp);

if (strcmp(tok, "OK") != 0) {

sprintf(priv->hw_crc32 + strlen(priv->hw_crc32), " (%.16s)", tok);
}
sprintf(priv->hw_crc32 + strlen(priv->hw_crc32), " (%.16s)", tok);

sprintf(lp->hwinfo, "%.16s / %.16s / %.36s", priv->hw_revision,
priv->hw_build, priv->hw_crc32);
Expand Down
63 changes: 47 additions & 16 deletions phobia/phobia.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ pub_primal_reg(struct public *pub, const struct link_reg *reg)
{
const char *primal_map[] = {

"pm.scale_uS0",
"pm.scale_uS1",
"pm.probe_current_hold",
"pm.probe_current_weak",
"pm.probe_current_sine",
Expand Down Expand Up @@ -2812,6 +2814,12 @@ page_diagnose(struct public *pub)
nk_layout_row_dynamic(ctx, 0, 1);
nk_spacer(ctx);

reg_float(pub, "pm.scale_uS0", "DC link voltage offset");
reg_float(pub, "pm.scale_uS1", "DC link voltage scale");

nk_layout_row_dynamic(ctx, 0, 1);
nk_spacer(ctx);

reg_enum_toggle(pub, "pm.tvm_ACTIVE", "TVM is active");
reg_float(pub, "pm.tvm_FIR_A_tau", "A voltage FIR tau");
reg_float(pub, "pm.tvm_FIR_B_tau", "B voltage FIR tau");
Expand Down Expand Up @@ -3649,8 +3657,8 @@ page_in_pwm(struct public *pub)
nk_layout_row_dynamic(ctx, 0, 1);
nk_spacer(ctx);

reg_float(pub, "ap.idle_timeout", "IDLE timeout");
reg_float(pub, "ap.disarm_timeout", "DISARM timeout");
reg_float(pub, "ap.timeout_DISARM", "Timeout DISARM ");
reg_float(pub, "ap.timeout_IDLE", "Timeout IDLE");

nk_layout_row_dynamic(ctx, 0, 1);
nk_spacer(ctx);
Expand Down Expand Up @@ -3727,8 +3735,8 @@ page_in_knob(struct public *pub)
nk_layout_row_dynamic(ctx, 0, 1);
nk_spacer(ctx);

reg_float(pub, "ap.idle_timeout", "IDLE timeout");
reg_float(pub, "ap.disarm_timeout", "DISARM timeout");
reg_float(pub, "ap.timeout_DISARM", "Timeout DISARM");
reg_float(pub, "ap.timeout_IDLE", "Timeout IDLE");

nk_layout_row_dynamic(ctx, 0, 1);
nk_spacer(ctx);
Expand All @@ -3739,27 +3747,49 @@ static void
page_application(struct public *pub)
{
struct nk_sdl *nk = pub->nk;
struct link_pmc *lp = pub->lp;
struct nk_context *ctx = &nk->ctx;
struct link_reg *reg;

nk_layout_row_dynamic(ctx, 0, 1);
nk_spacer(ctx);

reg_enum_toggle(pub, "ap.task_AUTOSTART", "Startup automatic");

reg = link_reg_lookup(lp, "ap.task_AUTOSTART");

if ( reg != NULL
&& reg->lval != 0) {

nk_layout_row_dynamic(ctx, 0, 1);
nk_spacer(ctx);

reg_float(pub, "ap.auto_reg_DATA", "Auto register DATA");
reg_linked(pub, "ap.auto_reg_ID", "Auto register ID");

nk_layout_row_dynamic(ctx, 0, 1);
nk_spacer(ctx);
}

reg_enum_toggle(pub, "ap.task_BUTTON", "Button control");
reg_enum_toggle(pub, "ap.task_AS5047", "AS5047 magnetic encoder");
reg_enum_toggle(pub, "ap.task_HX711", "HX711 load cell ADC");
reg_enum_toggle(pub, "ap.task_MPU6050", "MPU6050 inertial unit");

nk_layout_row_dynamic(ctx, 0, 1);
nk_spacer(ctx);
reg = link_reg_lookup(lp, "ap.task_HX711");

reg_float(pub, "ap.auto_reg_DATA", "Auto register DATA");
reg_linked(pub, "ap.auto_reg_ID", "Auto register ID");
if ( reg != NULL
&& reg->lval != 0) {

nk_layout_row_dynamic(ctx, 0, 1);
nk_spacer(ctx);
nk_layout_row_dynamic(ctx, 0, 1);
nk_spacer(ctx);

reg_float(pub, "ap.load_HX711", "HX711 measurement");

nk_layout_row_dynamic(ctx, 0, 1);
nk_spacer(ctx);
}

reg_float(pub, "ap.load_HX711", "HX711 measurement");
reg_enum_toggle(pub, "ap.task_MPU6050", "MPU6050 inertial unit");

nk_layout_row_dynamic(ctx, 0, 1);
nk_spacer(ctx);
Expand Down Expand Up @@ -3827,8 +3857,8 @@ page_thermal(struct public *pub)
reg_float(pub, "ap.heat_PCB_temp_derate", "PCB derate threshold");
reg_float(pub, "ap.heat_PCB_temp_FAN", "PCB fan ON threshold");
reg_float(pub, "ap.heat_EXT_temp_derate", "EXT derate threshold");
reg_float(pub, "ap.heat_derated_PCB", "PCB derated current");
reg_float(pub, "ap.heat_derated_EXT", "EXT derated current");
reg_float(pub, "ap.heat_maximal_PCB", "PCB maximal current");
reg_float(pub, "ap.heat_maximal_EXT", "EXT maximal current");
reg_float(pub, "ap.heat_temp_recovery", "Recovery hysteresis");

nk_layout_row_dynamic(ctx, 0, 1);
Expand Down Expand Up @@ -3901,6 +3931,7 @@ page_config(struct public *pub)
nk_spacer(ctx);

reg_enum_toggle(pub, "pm.config_LU_FORCED", "Forced control");
reg_enum_toggle(pub, "pm.config_LU_FREEWHEEL", "Allow freewheeling");
reg_enum_combo(pub, "pm.config_LU_ESTIMATE", "Sensorless estimate", 1);
reg_enum_combo(pub, "pm.config_LU_SENSOR", "Position sensor type", 1);
reg_enum_combo(pub, "pm.config_LU_LOCATION", "Servo location source", 1);
Expand All @@ -3914,8 +3945,8 @@ page_config(struct public *pub)
reg_enum_toggle(pub, "pm.config_RELUCTANCE", "Reluctance MTPA control");
reg_enum_toggle(pub, "pm.config_WEAKENING", "Flux weakening control");

reg_enum_toggle(pub, "pm.config_REVERSE_BRAKE", "Reverse brake");
reg_enum_toggle(pub, "pm.config_SPEED_MAXIMAL", "Speed constraints");
reg_enum_toggle(pub, "pm.config_REVERSE_BRAKE", "Reverse brake function");
reg_enum_toggle(pub, "pm.config_SPEED_MAXIMAL", "Speed maximal function");

reg_enum_combo(pub, "pm.config_EABI_FRONTEND", "EABI frontend", 0);
reg_enum_combo(pub, "pm.config_SINCOS_FRONTEND", "SINCOS frontend", 0);
Expand Down
3 changes: 2 additions & 1 deletion src/app/autostart.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ LD_TASK void app_AUTOSTART(void *pData)
do {
vTaskDelay((TickType_t) 100);

if (pm.lu_MODE == PM_LU_DISABLED) {
if ( pm.lu_MODE == PM_LU_DISABLED
&& pm.const_fb_U > pm.watt_uDC_minimal) {

pm.fsm_req = PM_STATE_LU_STARTUP;

Expand Down
9 changes: 8 additions & 1 deletion src/app/mpu6050.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@

LD_TASK void app_MPU6050(void *pData)
{
/* TODO */
volatile int *knob = (volatile int *) pData;

do {
/* TODO */
}
while (*knob != 0);

vTaskDelete(NULL);
}

3 changes: 1 addition & 2 deletions src/epcan.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ EPCAN_pipe_message_IN(const CAN_msg_t *msg)
ep->tx_N = 0;

if ( ep->ACTIVE == PM_ENABLED
&& pm.fsm_errno != PM_OK) {
&& pm.lu_MODE == PM_LU_DISABLED) {

ep->ACTIVE = PM_DISABLED;
}
Expand All @@ -164,7 +164,6 @@ EPCAN_pipe_message_IN(const CAN_msg_t *msg)
&& ep->ACTIVE != PM_ENABLED
&& pm.lu_MODE == PM_LU_DISABLED) {

pm.fsm_errno = PM_OK;
pm.fsm_req = PM_STATE_LU_STARTUP;

ep->ACTIVE = PM_ENABLED;
Expand Down
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit a5ddebc

Please sign in to comment.