@Pedrodemio
I think I know why the VESC has poor tracking at low speeds.
So at low speeds, obviously the BEMF is very weak and small compared to sources of noise.
I realize now that in the VESC designs there is actually quite a bit of crosstalk between the current sensing section and power stage, so what is happening, is the sine waves that the VESC is applying to the motor is also showing up in the current sensing that the VESC then measures. The result is this crosstalk skews the estimated BEMF and causes the estimated BEMF to either lag or lead the actual BEMF. The strength of this crosstalk noise is proportional the to applied motor current, while the strength of the BEMF is proportional to speed.
This is explains why the tracking improves as speed increases, and also why torque appears to drop off as more current is applied, and why I can actually get my VESCs to cog at very high currents.
The solution to this is careful PCB layout and component selection to minimize and filter this crosstalk.
I recommend using current sense amplifiers such as the INA240A1, which has significantly better common mode rejection than the AD8418. Placing the amplifiers right next to or very close to the MCU will allow for the output signal from the amplifiers to be mostly unaffected by noise from the power stage. This means the current shunt kelvin connections will have to be routed through the power stage, this will cause the crosstalk to appear as a common mode signal in the differential current sense traces. Keep these traces straight and as short as possible and try to sandwich them between ground layers in order to minimize crosstalk, which the INA240’s common mode rejection will then filter out.
The INA240 costs the same amount as the AD8418, but has way better electrical characteristics. 30 dB better CMRR at DC, 20 dB better CMRR above 1kHz, much lower input offset voltage, gain error, and temperature drift.
It is also a drop-in replacement.
Why new VESC6s don’t use the INA240, or at least test with them, is beyond me.