Skip to content

Commit

Permalink
Added command waiting indication in PGUI.
Browse files Browse the repository at this point in the history
  • Loading branch information
rombrew committed Sep 8, 2024
1 parent 17f58d2 commit 1522380
Show file tree
Hide file tree
Showing 23 changed files with 479 additions and 261 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ There are a few videos about PMC on [youtube](https://www.youtube.com/@romblv).

- Automated machine parameters identification:
- Stator DC resistance (Rs).
- Stator AC impedance in DQ frame (Ld, Lq, R).
- Stator AC impedance in DQ frame (Ld, Lq, Rz).
- Rotor flux linkage constant (lambda).
- Mechanical moment of inertia (Ja).

Expand Down
2 changes: 1 addition & 1 deletion bench/tsfunc.c
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ void ts_script_test()

tlm_restart();

m.Rs = 7.E-3;
m.Rs = 8.E-3;
m.Ld = 3.E-6;
m.Lq = 5.E-6;
m.Udc = 48.;
Expand Down
5 changes: 2 additions & 3 deletions doc/GettingStarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ GDB as in previous case but we are only concerned with using `st-flash` util.

USART interface with ST embedded bootloader using
[stm32flash](https://sourceforge.net/projects/stm32flash/). You should have a
serial port connected to the board TX and RX pins and BOOT pin shorted to the
+3.3v.
serial port connected to the board TX and RX pins and BOOT pin shorted to the +3.3v.

$ make HWREV=PHOBIA_rev5 flash

Expand Down Expand Up @@ -137,7 +136,7 @@ Read the following documentation for setting PMC up.
## Feedback and support

Yuo can contact me on [sourceforge](https://sourceforge.net/projects/phobia/)
[github](https://github.com/rombrew/phobia) or by email.
or [github](https://github.com/rombrew/phobia) as well as by email.

Roman Belov <[email protected]>

16 changes: 8 additions & 8 deletions doc/HardwareDesign.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ PWM scheme as shown in the diagram.
```

Each half-bridge consists of two MOSFETs controlled by a gate drivers with a
specified dead-time `ZT`. Depending on the direction of the current flow during
specified dead-time `DT`. Depending on the direction of the current flow during
the dead-time the actual voltage on half-bridge may be different. The amount of
uncertainty in the output voltage `dU` expressed as follows:
uncertainty in the output voltage `DTu` expressed as follows:

```
2 * ZT * DC_link_voltage
dU = ---------------------------
dT
DT * DC_link_voltage
DTu = ----------------------
dT
|
|
Expand All @@ -69,7 +69,7 @@ uncertainty in the output voltage `dU` expressed as follows:
|| | --- | |
|--+ | | |
| | | |
+------+ --->| <--- ZT |
+------+ --->| <--- DT |
| | |
+---< Terminal | |
| | |
Expand All @@ -95,8 +95,8 @@ linear region. You can skip the terminal voltage sensing if you do not need
related features but supply voltage measuring is mandatory.

To get acceptable accuracy you need to make sure that the RC scheme time
constant is comparable to dT. Also make sure that your capacitors are stable
over whole temperature and voltage range.
constant is comparable to the typical `dT` value. Also make sure that your
capacitors are stable over whole temperature and voltage range.

```
+------< REF
Expand Down
5 changes: 0 additions & 5 deletions doc/HardwareVESC.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,3 @@ firmware to MCU.
VESC does not have voltage dividers on ADC pins. You should use external
dividers or specify 3.3v levels on analog knob range configuration.

## Terminal voltages

VESC does not have required RC filters on the terminal voltage measurement
circuits. So you are not able to use dead-time distortion compensation.

6 changes: 3 additions & 3 deletions doc/IntegritySelfTest.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ This adjustment does the following steps in this order:

- Get current sensors zero drift and check it is within the acceptable range.
- Adjust the voltage measurement channels relatively to DC link voltage.
- Adjust dead-time distortion compensation (**OPTIONAL**).
- Adjust the current measurement channels pairwise.
- Adjust dead-time distortion compensation (DTC).

Note that in step 4 you need to connect the machine (or test coil) to let the
current flow in phase circuits.
Note that in last two steps you need to connect the machine (or test coil) to
let the current flow in phase circuits.

## See also

Expand Down
18 changes: 9 additions & 9 deletions doc/MachineTuning.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ at low speed range.
## Current loop

You can automatically tune current loop PI regulator gains based on damping
percentage. Reasonable values are from 50 to 150.
percentage. Reasonable values are from 20 to 200.

(pmc) reg pm.i_damping <pc>

Expand Down Expand Up @@ -90,7 +90,7 @@ transient rate and noise level.
## Speed loop

You can automatically tune speed loop PID regulator gains based on damping
percentage. Reasonable values are from 50 to 200.
percentage. Reasonable values are from 40 to 400.

(pmc) reg pm.s_damping <pc>

Expand All @@ -109,14 +109,14 @@ to increase the default acceleration value.
It should be noted that above constraints are used differently depending on
selected control loop. In case of speed control above constraints are applied
to speed setpoint to get trackpoint `pm.s_track`. In other words we do not
limits actual parameters but limit input setpoint to comply it with
limits actual parameters but limit the input setpoint to comply it with
constraints.

Quite different in the case of current control. You should enable
`SPEED_MAXIMAL` feature to apply above speed loop constraints to actual speed
`CC_SPEED_TRACK` feature to apply above speed loop constraints to actual speed
and acceleration.

(pmc) reg pm.config_SPEED_MAXIMAL 1
(pmc) reg pm.config_CC_SPEED_TRACK 1

Here trackpoint is driven by actual speed estimate with acceleration
constraint. For system stability we have introduced a linear regulation region
Expand All @@ -132,12 +132,12 @@ Also you can tune PID regulator and load torque gains manually.

## Brake function

If you need a reverse brake function in combination with current control then
enable `REVERSE_BRAKE` feature. It is activated when current setpoint is
negative. Brake current is limited by absolute value of setpoint so brake is
If you need a brake function without a reverse in combination with current
control then enable `CC_BRAKE` feature. It is activated when current setpoint
is negative. Brake current is limited by absolute value of setpoint so brake is
proportional.

(pmc) reg pm.config_REVERSE_BRAKE 1
(pmc) reg pm.config_CC_BRAKE 1

Note that speed control loop should be fine tuned to use this feature.

Expand Down
36 changes: 27 additions & 9 deletions pgui/link.c
Original file line number Diff line number Diff line change
Expand Up @@ -678,9 +678,9 @@ int link_fetch(struct link_pmc *lp, int clock)
{ "flash_info", LINK_MODE_FLASH_MAP },
{ "flash_prog", LINK_MODE_UNABLE_WARNING },
{ "flash_wipe", LINK_MODE_UNABLE_WARNING },
{ "pm_self", LINK_MODE_UNABLE_WARNING },
{ "pm_probe", LINK_MODE_UNABLE_WARNING },
{ "pm_adjust", LINK_MODE_UNABLE_WARNING },
{ "pm_self_", LINK_MODE_UNABLE_WARNING },
{ "pm_probe_", LINK_MODE_UNABLE_WARNING },
{ "pm_adjust_", LINK_MODE_UNABLE_WARNING },
{ "tlm_flush_sync", LINK_MODE_DATA_GRAB },
{ "tlm_live_sync", LINK_MODE_DATA_GRAB },
{ "net_survey", LINK_MODE_EPCAN_MAP },
Expand Down Expand Up @@ -710,6 +710,12 @@ int link_fetch(struct link_pmc *lp, int clock)

if (rc_local != 0) {

if ( lp->command_state == LINK_COMMAND_RUNING
|| lp->command_state == LINK_COMMAND_WAITING) {

lp->command_state = LINK_COMMAND_NONE;
}

if (priv->link_mode == LINK_MODE_DATA_GRAB) {

link_grab_file_close(lp);
Expand Down Expand Up @@ -741,11 +747,21 @@ int link_fetch(struct link_pmc *lp, int clock)
mp++;
}

if (priv->link_mode == LINK_MODE_FLASH_MAP)
if (priv->link_mode == LINK_MODE_FLASH_MAP) {

memset(lp->flash, 0, sizeof(lp->flash));
else if (priv->link_mode == LINK_MODE_EPCAN_MAP)
}
else if (priv->link_mode == LINK_MODE_EPCAN_MAP) {

memset(lp->epcan, 0, sizeof(lp->epcan));
}
else if (priv->link_mode == LINK_MODE_UNABLE_WARNING) {

if (lp->command_state == LINK_COMMAND_PENDING) {

lp->command_state = LINK_COMMAND_RUNING;
}
}
break;

case LINK_MODE_HWINFO:
Expand Down Expand Up @@ -790,13 +806,15 @@ int link_fetch(struct link_pmc *lp, int clock)
if (lp->active + 12000 < lp->clock) {

link_close(lp);

return N;
}
else {
sprintf(priv->lbuf, "ap_time" LINK_EOL);
serial_fputs(priv->fd, priv->lbuf);
}

lp->keep = lp->clock;
lp->keep = lp->clock;
}
}
}
else {
Expand Down Expand Up @@ -908,7 +926,7 @@ int link_command(struct link_pmc *lp, const char *command)
if (lp->linked == 0)
return 0;

if (lp->locked > lp->clock + 50)
if (lp->locked > lp->clock + 100)
return 0;

sprintf(priv->lbuf, "%.90s" LINK_EOL, command);
Expand All @@ -917,7 +935,7 @@ int link_command(struct link_pmc *lp, const char *command)

pushed = 1;

lp->locked = lp->clock + 100;
lp->locked = lp->clock + 200;
}

return pushed;
Expand Down
9 changes: 9 additions & 0 deletions pgui/link.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ enum {
LINK_PRIMAL_ENABLED
};

enum {
LINK_COMMAND_NONE = 0,
LINK_COMMAND_PENDING,
LINK_COMMAND_RUNING,
LINK_COMMAND_WAITING
};

struct link_priv;

struct link_reg {
Expand Down Expand Up @@ -97,6 +104,8 @@ struct link_pmc {
char unable_warning[LINK_MESSAGE_MAX];
int uptime_warning;

int command_state;

int line_N;
int grab_N;

Expand Down
Loading

0 comments on commit 1522380

Please sign in to comment.