Hi everyone, i'm looking for pointers on how to debug some annoying and apparently random issues plaguing this range extender I made with a weed whacker engine and a VESC. It uses software running on the scooters MCU talking to the VESC (a Flipsky mini fsesc6.7) to actuate the throttle valve via the vesc servo output, and vary the braking load.

Basically, everything works absolutely perfect for anywhere from several seconds to several hours, after which the VESC reboots. According to the terminal, this is nearly always a WATCHDOG_RESET error, though I have seen UNBALANCED_CURRENT a few times too.
What I have tried so far, with no change in behaviour:
Here are some samples recorded from when it is running.
Engine running, no command for vesc:

Engine running while loaded. The slow pulses aren't because of motor control, but the reactions to the single cylinder engine's power stroke.

The biggest lead I have is the unbalanced currents thing. There does seem to be some bias to the phase currents, phase 2 getting higher positive values and phase 3 higher negative ones. Even in idle, they average 0 but each has a value other than that. But shouldnt any offset be calibrated out at start by the firmware? Or does it only zero out the summed current? And if this was a hardware fault, what are the chances of two different vescs having the exact same fault? In the BEMF plot the phases seem to be quite equal, on the other hand:

As some extra info, neither motor I tried has any issue passing detection, they work on this vesc with much higher currents without issues than used with the generator. I had modified the VESC firmware to include CAN messages for setting power limits, but I have switched back to the stock firmware to debug, though there is no difference in behaviour.
Does anyone have ideas how to figure out what's going wrong here?

Basically, everything works absolutely perfect for anywhere from several seconds to several hours, after which the VESC reboots. According to the terminal, this is nearly always a WATCHDOG_RESET error, though I have seen UNBALANCED_CURRENT a few times too.
What I have tried so far, with no change in behaviour:
- Try another VESC in case of broken HW
- Change control mode from FOC to BLDC
- Rise and lower switching frequency
- Make the control logic extremely sloppy to avoid fast transients
- Tweak flux linkage and observer gain
- Try different FW versions (6.02, 6.05)
- Try different motor (freerchobby 6384 190kv and a Maytech 6374 190kv)
- Doesnt seem like the usual loss of tracking that causes ABS_OVERCURRENT
- Quite low powers and currents are involved, max ~700W or so, on a 12S pack
- Data looks fine, voltage is stable even with max power so should not be an obvious bad connection
- Cannot use triggered sampling on error as the mcu reboot
Here are some samples recorded from when it is running.
Engine running, no command for vesc:

Engine running while loaded. The slow pulses aren't because of motor control, but the reactions to the single cylinder engine's power stroke.

The biggest lead I have is the unbalanced currents thing. There does seem to be some bias to the phase currents, phase 2 getting higher positive values and phase 3 higher negative ones. Even in idle, they average 0 but each has a value other than that. But shouldnt any offset be calibrated out at start by the firmware? Or does it only zero out the summed current? And if this was a hardware fault, what are the chances of two different vescs having the exact same fault? In the BEMF plot the phases seem to be quite equal, on the other hand:

As some extra info, neither motor I tried has any issue passing detection, they work on this vesc with much higher currents without issues than used with the generator. I had modified the VESC firmware to include CAN messages for setting power limits, but I have switched back to the stock firmware to debug, though there is no difference in behaviour.
Does anyone have ideas how to figure out what's going wrong here?
