Commit Graph

120 Commits

Author SHA1 Message Date
Benjamin Vedder 6ff6a99885 Magic number no longer needed after HFI update 2024-07-21 10:36:21 +02:00
Benjamin Vedder ea01a6a620
Merge pull request #748 from ElwinBoots/master
Correction of inductance measurement.
2024-07-21 09:02:31 +02:00
Benjamin Vedder 27cb0ca0c3 Disable foc_short_ls_on_zero_duty during HFI modulation 2024-07-21 09:00:54 +02:00
ElwinBoots f891bbcc12
Merge branch 'vedderb:master' into master 2024-07-20 21:23:09 +02:00
Benjamin Vedder 0bf6b0652d Added option to short all phases on full brake 2024-07-20 13:40:58 +02:00
ElwinBoots 067393c226 Correction of inductance measurement. Should only impact motors with high LdLq difference.
motor->m_hfi.buffer now contains inverse of inductance
Rotating HFI starts rotating from alpha direction
2024-07-19 22:14:20 +02:00
Benjamin Vedder be0fef9a9e Restored most of the 6.02 hall sensor interpolation, the sensorless blend is still there 2024-05-16 15:45:56 +02:00
Benjamin Vedder 4499982f99 Added hall sensor rate limiter again, now based on the hall toggle rate as in 6.02 2024-05-15 13:24:04 +02:00
Benjamin Vedder 2490f78230 Added BMS cell voltage limits 2024-05-15 11:09:36 +02:00
Benjamin Vedder 36b8a063c5 Removed hall sensor rate limiter as it could get stuck in certain conditions 2024-05-08 12:31:08 +02:00
Benjamin Vedder 2717df8441 Added support for getting individual samples 2024-04-14 09:12:53 +02:00
Benjamin Vedder e39cebe51c Refactor 2024-04-09 10:20:11 +02:00
Benjamin Vedder ebb0b339bb Use size-optimization on more files where performance is less important 2024-04-01 10:25:56 +02:00
Benjamin Vedder 73c32d7962 Removed GPDRIVE 2024-04-01 00:09:32 +02:00
Euan b3b047809a Refactor to allow custom voltage measurement
Allows the hw conf to control voltage measurement for foc, useful for adding oversampling.
2024-02-23 23:06:08 +00:00
Benjamin Vedder 5b6148dd1e Updated comment 2024-02-23 08:17:25 +01:00
Benjamin Vedder 5fd5dfe086 Made HFI error truncation configurable 2024-02-23 08:13:56 +01:00
Benjamin Vedder a50829f55a Style tweaks 2024-02-23 07:22:06 +01:00
Benjamin Vedder 1e8e494c61
Merge pull request #709 from ljungholm/limit_pid_set_rpm
FOC speed control: Limit m_speed_pid_set_rpm to achievable RPM when ramp rate is non-zero
2024-02-23 07:01:49 +01:00
Benjamin Vedder 9499e56348
Merge pull request #705 from TechAUmNu/Calibrated-currents
Add ability to calibrate current sensors, simplify ifdefs in foc, higher resolution sampled current
2024-02-23 06:52:49 +01:00
Benjamin Vedder d61bde5841 Truncate HFI error to reject noise 2024-02-21 17:21:20 +01:00
Carl Ljungholm 84f2253f98 Limit m_speed_pid_set_rpm to achievable RPM.
If m_speed_pid_set_rpm is allowed to exceed foc_openloop_rpm before index is found,
then there will be a jump in torque when index is found.
If m_speed_pid_set_rpm is allowed to exceed [l_min_erpm, l_max_erpm] then there is
a wind up effect since it will take time for m_speed_pid_set_rpm to return to valid
range due to ramp limit.
2024-02-20 11:29:59 +01:00
Euan 5e66bb4387 Scale sampled data properly
Needs to be rescaled back to int for storage, 8* higher resolution so the hw can use oversampling.

BLDC can use floats for these variables, since they get changed to floats later anyway. Might as well do it earlier to make the code simpler.
2024-02-07 22:27:36 +00:00
Euan 1f3667018f Fix compiler errors. 2024-02-07 01:05:35 +00:00
Euan 7628667458 Refactor raw sampling to improve readability
Cleaned up the sensor picking, my brain is happy now!
2024-02-07 00:04:15 +00:00
Euan 5b3906f9d8 Simplify mcpwm calibration. Make current samples correctly scaled. 2024-02-06 22:51:19 +00:00
Euan c2878474a1 Refactor mcpwm_foc and fix bug in hw.h
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.
2024-02-06 21:53:03 +00:00
Euan 8580ec8c77 Fix typo 2024-02-06 00:14:54 +00:00
Euan af65f521de Add support for calibrating current sensors
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.
2024-02-05 23:55:42 +00:00
Benjamin Vedder a9a1faf317 Do not allow sampled playback during faults 2023-12-31 19:37:15 +01:00
Benjamin Vedder a207d75a69 Added foc-play-samples 2023-12-31 17:26:15 +01:00
Benjamin Vedder f9d5ee138d Added support for playing up to 3 audio channels while the motor is running 2023-12-26 22:37:41 +01:00
Benjamin Vedder 058abe4d79 Use braking current limit in duty mode when braking 2023-10-16 13:37:15 +02:00
Benjamin Vedder 5070ba34ad Avoid briefly entering duty-mode just when starting to brake 2023-10-16 12:00:41 +02:00
Benjamin Vedder c7591716a2 Added more current get extensions 2023-10-15 20:56:49 +02:00
Benjamin Vedder 004af85dc1 Take both current override limits into account in the relative current mode 2023-10-13 13:56:03 +02:00
Benjamin Vedder 00724ebd4f Use all currents in sampled data 2023-09-29 13:50:50 +02:00
Euan 31f238849c Add support for A200S V4.1, add alternative DC Cal, expose I2C for LSM6DS3
Adds support for A200S V4.1
Move A200S V4 to its own folder.
Expose I2C for LSM6DS3 to allow other devices on the same I2C bus. (It is now setup the same as the other IMUs)

Add alternative DC Calibration routine for Low side shunt hardware with very high mosfet output capacitance. The usual calibration routine causes an offset in the current calibration at high voltage from the capacitance discharging through the motor inductance when the single phase goes low. The alternative routine switches all phases at 50% to give a clean V0 state. This routine should not be run while the motor is spinning, so automatic calibration on startup is disabled when this routine is selected.
2023-09-26 10:07:06 +01:00
Benjamin Vedder f9adcfb6dc Add current off delay on relative current functions to make the rpm-limit more smooth on the apps 2023-09-25 21:27:36 +02:00
Benjamin Vedder c67946039b Normalize angle after interpolation 2023-09-25 13:43:43 +02:00
Benjamin Vedder 79c86db6e6 New current sampling modes, FOC interpolation support 2023-09-23 14:45:00 +02:00
Benjamin Vedder fd80107522 More hall sensor tweaks 2023-08-08 19:56:48 +02:00
Benjamin Vedder cba6f32b92 Simplified hall sensor code 2023-08-08 15:02:52 +02:00
Benjamin Vedder 14eaf5d4eb Allow more flux linkage tracker range 2023-08-03 09:53:14 +02:00
Benjamin Vedder 76aedf16ac BLDC and DC motor support for one motor on dual motor hardware 2023-07-27 18:01:16 +02:00
Benjamin Vedder 1fee16de47 Hall sensor bug fix and tweaks 2023-07-16 16:00:41 +02:00
Benjamin Vedder 54bf4c272e Minor fix 2023-07-07 14:07:18 +02:00
Benjamin Vedder 9eb978ef15 Added option to select PID speed controller source, some cleanup 2023-07-01 14:51:08 +02:00
Benjamin Vedder e3d7e8624c Added filter for the mapped input current limit 2023-06-23 11:10:37 +02:00
Benjamin Vedder 3c3cf2fb99 Updated comment 2023-06-16 20:37:18 +02:00