The 25MHz clock couples through the floating phase filter capacitor opendrain output on 1 phase. Which appears as a voltage offset and screws up flux linkage measurements at lower voltages. By oversampling, this offset is removed and flux linkage measurements now work properly at all voltages.
This update corrects the shunt resistance.
Adds generic calibration values for the current.
Adds 6 sample filtering for current (takes 6 current samples each pwm cycle and averages them to reduce noise)
Reduced max pwm in foc to 45khz
Disabled offset calibration on boot to speed up boot time. (Boots in under 2s now)
Removed a bunch of ifdefs by making is_second_motor = 0 when not using dual motors.
Fixed a bug in hw.h where it wrongly defined GET_CURRENT3 when inverted shunts was selected. GET_CURRENT3 will now always be 0 by default, removing the need for a few ifdefs in the foc code.
Hw_conf can define CURRENT_CAL1,2,3 to set individual calibrations for each current sensor.
By default no calibration is used. (x1.0)
For example this is used on the A50S by looping a calibrated current using a power supply through each phase. Then the correction is saved in external eeprom to persist across firmware updates.
Tested on FOC, DC and BLDC modes.
cmd[0] = [force] // 0=normal, 1=force (allow while motor is spinning)
cmd[1] = [restart] // 0=shutdown, 1=restart
Obviously, shutdown only works for hardware with shutdown support
Signed-off-by: Dado Mista <dadomista@gmail.com>
Hidden variant added (won't be part of build-all) defining "ALWAYS_ON"
With ALWAYS_ON defined hw_sample_shutdown always returns false.
Signed-off-by: Dado Mista <dadomista@gmail.com>