Skip to content

Change the project to STM32CubeIDE 1.16+ and recent gcc. #44

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
273 changes: 141 additions & 132 deletions .cproject

Large diffs are not rendered by default.

248 changes: 248 additions & 0 deletions .cproject_org

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ Debug
/JavaConfigurator/dist/
/Release/
/build/
experimental settings/
9 changes: 3 additions & 6 deletions .project
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>LishuiFOC_01</name>
<comment />
<comment></comment>
<projects>
</projects>
<buildSpec>
Expand All @@ -20,11 +20,8 @@
</buildSpec>
<natures>
<nature>org.eclipse.cdt.core.cnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
<nature>fr.ac6.mcu.ide.core.MCUProjectNature</nature>
<nature>com.st.stm32cube.ide.mcu.MCUSW4STM32ConvertedProjectNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
</natures>
<linkedResources>

</linkedResources>
</projectDescription>
30 changes: 30 additions & 0 deletions .project_org
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>LishuiFOC_01</name>
<comment />
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>clean,full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.cdt.core.cnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
<nature>fr.ac6.mcu.ide.core.MCUProjectNature</nature>
</natures>
<linkedResources>

</linkedResources>
</projectDescription>
10 changes: 5 additions & 5 deletions .settings/language.settings.xml
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project>
<configuration id="fr.ac6.managedbuild.config.gnu.cross.exe.debug.167643868" name="Debug">
<configuration id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.964865682" name="Debug">
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider class="fr.ac6.mcu.ide.build.CrossBuiltinSpecsDetector" console="false" env-hash="482849276983345380" id="fr.ac6.mcu.ide.build.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="Ac6 SW4 STM32 MCU Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="690716002991941334" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
</extension>
</configuration>
<configuration id="fr.ac6.managedbuild.config.gnu.cross.exe.release.444937816" name="Release">
<configuration id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.release.1432686742" name="Release">
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider class="fr.ac6.mcu.ide.build.CrossBuiltinSpecsDetector" console="false" env-hash="482849276983345380" id="fr.ac6.mcu.ide.build.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="Ac6 SW4 STM32 MCU Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="690716002991941334" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
</extension>
</configuration>
</project>
</project>
133 changes: 48 additions & 85 deletions Inc/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,109 +8,72 @@
#ifndef CONFIG_H_
#define CONFIG_H_
#include "stdint.h"

// System constants, don't touch!
#define DISPLAY_TYPE_DEBUG (1<<0) // For ASCII-Output in Debug mode);
#define DISPLAY_TYPE_KUNTENG (1<<1) // For Kunteng display
#define DISPLAY_TYPE_BAFANG_LCD (1<<2) // For 'Blaupunkt' Display of Prophete Entdecker
#define DISPLAY_TYPE_BAFANG_850_860 (1<<3) // Bafang 850/860. Can do 9k6 baud, also compatible with 1200 baud detection at startup
#define DISPLAY_TYPE_KINGMETER_618U (1<<4) // King-Meter 618U protocol ( J-LCD)
#define DISPLAY_TYPE_KINGMETER_901U (1<<5) // King-Meter 901U protocol (KM5s)
#define DISPLAY_TYPE_EBiCS (1<<6) // Protocol using the ANT+ LEV logic
#define DISPLAY_TYPE_NO2 (1<<7) // For China Protokoll "No_2" S866 display for example
#define DISPLAY_TYPE_BAFANG (DISPLAY_TYPE_BAFANG_LCD|DISPLAY_TYPE_BAFANG_850_860)
#define DISPLAY_TYPE_KINGMETER (DISPLAY_TYPE_KINGMETER_618U|DISPLAY_TYPE_KINGMETER_901U)
#define DISPLAY_TYPE_DEBUG (1 << 0) // For ASCII-Output in Debug mode);
#define DISPLAY_TYPE_KUNTENG (1 << 1) // For Kunteng display
#define DISPLAY_TYPE_BAFANG_LCD (1 << 2) // For 'Blaupunkt' Display of Prophete Entdecker
#define DISPLAY_TYPE_BAFANG_850_860 (1 << 3) // Bafang 850/860. Can do 9k6 baud, also compatible with 1200 baud detection at startup
#define DISPLAY_TYPE_KINGMETER_618U (1 << 4) // King-Meter 618U protocol ( J-LCD)
#define DISPLAY_TYPE_KINGMETER_901U (1 << 5) // King-Meter 901U protocol (KM5s)
#define DISPLAY_TYPE_EBiCS (1 << 6) // Protocol using the ANT+ LEV logic
#define DISPLAY_TYPE_NO2 (1 << 7) // For China Protokoll "No_2" S866 display for example
#define DISPLAY_TYPE_BAFANG (DISPLAY_TYPE_BAFANG_LCD | DISPLAY_TYPE_BAFANG_850_860)
#define DISPLAY_TYPE_KINGMETER (DISPLAY_TYPE_KINGMETER_618U | DISPLAY_TYPE_KINGMETER_901U)
#define EXTERNAL 1
#define INTERNAL 0
//----------------------------------------------------------------------
// advanced setting, don't touch, if you don't know what you are doing!
// #define LEGALFLAG

#define TRIGGER_OFFSET_ADC 50
#define TRIGGER_DEFAULT 2020
#define _T 2028
#define CAL_BAT_V 256
#define CAL_V 25
#define CAL_I 38LL<<8
#define CAL_I 48LL << 8
#define INDUCTANCE 6LL
#define RESISTANCE 40LL
#define FLUX_LINKAGE 1200LL
#define GAMMA 9LL
//#define FAST_LOOP_LOG
//#define DISABLE_DYNAMIC_ADC
//#define INDIVIDUAL_MODES
//#define SPEEDTHROTTLE
#define SIXSTEPTHRESHOLD 20000
#define SPEED_PLL 0 //1 for using PLL, 0 for angle extrapolation
#define P_FACTOR_PLL 10
#define I_FACTOR_PLL 10

//----------------------------------------------------------------------
//Battery bar settings for Kunteng and Bafang Display
#define BATTERY_LEVEL_1 323000
#define BATTERY_LEVEL_2 329000
#define BATTERY_LEVEL_3 344000
#define BATTERY_LEVEL_4 368000
#define BATTERY_LEVEL_5 380000

//----------------------------------------------------------------------
//PI-control factor settings
#define P_FACTOR_I_Q 50
#define I_FACTOR_I_Q 2
#define P_FACTOR_I_D 50
#define I_FACTOR_I_D 2
#define P_FACTOR_SPEED 1
#define BATTERY_LEVEL_1 430000LL
#define BATTERY_LEVEL_2 450000LL
#define BATTERY_LEVEL_3 470000LL
#define BATTERY_LEVEL_4 490000LL
#define BATTERY_LEVEL_5 510000LL
#define P_FACTOR_I_Q 500
#define I_FACTOR_I_Q 20
#define P_FACTOR_I_D 500
#define I_FACTOR_I_D 20
#define P_FACTOR_PLL 5
#define I_FACTOR_PLL 11
#define P_FACTOR_SPEED 100
#define I_FACTOR_SPEED 10

//----------------------------------------------------------------------
//PAS mode settings
//#define DIRDET
#define FRAC_HIGH 30
#define FRAC_LOW 15
#define SPDSHFT 0
#define SPEEDFILTER 1
#define SIXSTEPTHRESHOLD 20000
#define TS_COEF 35000
#define PAS_TIMEOUT 3000
#define RAMP_END 1200
#define PAS_IMP_PER_TURN 32

//---------------------------------------------------------------------
//Throttle settings
#define THROTTLE_OFFSET 1250 //only default value, throttle offset is set at startup automatically
#define FRAC_HIGH 30
#define FRAC_LOW 15
#define THROTTLE_OFFSET 1250
#define THROTTLE_MAX 2850
#define THROTTLE_OVERRIDE

//--------------------------------------------------------------------
//Speed settings
#define PUSHASSIST_CURRENT 8000
#define WHEEL_CIRCUMFERENCE 2200
#define GEAR_RATIO 11 //11 for BionX IGH3
#define SPEEDLIMIT 25
#define PULSES_PER_REVOLUTION 1
#define SPEEDSOURCE INTERNAL
#define SPEEDFILTER 1
#define SPDSHFT 0

//---------------------------------------------------------------------
//power settings
#define PH_CURRENT_MAX 1200
#define BATTERYCURRENT_MAX 14000
#define REVERSE 1 //1 for normal direction, -1 for reverse
#define PUSHASSIST_CURRENT 300
#define VOLTAGE_MIN 1320 //33V

//---------------------------------------------------------------------
//torquesensor settings
#define TS_COEF 2400
#define GEAR_RATIO 88
#define SPEEDLIMIT 99
#define PULSES_PER_REVOLUTION 6
#define PH_CURRENT_MAX 500
#define BATTERYCURRENT_MAX 17000
#define REGEN_CURRENT 20
#define REGEN_CURRENT_MAX 5000
#define VOLTAGE_MIN 1400
#define VOLTAGE_MAX 2200
#define SPEC_ANGLE -715827882
#define TS_MODE
//#define TQONAD1

//---------------------------------------------------------------------
//Display settings
#define DISPLAY_TYPE DISPLAY_TYPE_KINGMETER_901U

//---------------------------------------------------------------------
//Regen settings

#define REGEN_CURRENT 800
#define REGEN_CURRENT_MAX 10000
//#define ADC_BRAKE

//---------------------------------------------------------------------
#define TQONAD1
#define DISPLAY_TYPE DISPLAY_TYPE_KUNTENG
#define SPEED_PLL 0
#define SPEEDSOURCE EXTERNAL
#define AUTODETECT 0
#define REVERSE 1

#endif /* CONFIG_H_ */
22 changes: 11 additions & 11 deletions Inc/display_kunteng.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
#include "config.h"

void kunteng_init();
void display_update(MotorState_t* MS_U);
void check_message(MotorState_t* MS_D, MotorParams_t* MP_D);
void display_update(MotorState_t *MS_U);
void check_message(MotorState_t *MS_D, MotorParams_t *MP_D);

typedef struct _lcd_configuration_variables
{
Expand All @@ -37,7 +37,7 @@ typedef struct _lcd_configuration_variables
uint8_t ui8_c14;
} struc_lcd_configuration_variables;

#define COMMUNICATIONS_BATTERY_VOLTAGE (BATTERY_LI_ION_CELLS_NUMBER * 3.45) // example: 7S battery, should be = 24
#define COMMUNICATIONS_BATTERY_VOLTAGE (BATTERY_LI_ION_CELLS_NUMBER * 3.45) // example: 7S battery, should be = 24

// Considering the follow voltage values for each li-ion battery cell
// State of charge | voltage
Expand All @@ -47,17 +47,17 @@ typedef struct _lcd_configuration_variables
#define LI_ION_CELL_VOLTS_60 3.68 // 3.87
#define LI_ION_CELL_VOLTS_40 3.46 // 3.80
#define LI_ION_CELL_VOLTS_20 3.28 // 3.73
#define LI_ION_CELL_VOLTS_0 3.10 // 3.27
#define LI_ION_CELL_VOLTS_0 3.10 // 3.27
#define LI_ION_CELL_VOLTS_MIN 3.10

#define BATTERY_PACK_VOLTS_100 (LI_ION_CELL_VOLTS_100 * BATTERY_LI_ION_CELLS_NUMBER) * 256
#define BATTERY_PACK_VOLTS_80 (LI_ION_CELL_VOLTS_80 * BATTERY_LI_ION_CELLS_NUMBER) * 256
#define BATTERY_PACK_VOLTS_60 (LI_ION_CELL_VOLTS_60 * BATTERY_LI_ION_CELLS_NUMBER) * 256
#define BATTERY_PACK_VOLTS_40 (LI_ION_CELL_VOLTS_40 * BATTERY_LI_ION_CELLS_NUMBER) * 256
#define BATTERY_PACK_VOLTS_20 (LI_ION_CELL_VOLTS_20 * BATTERY_LI_ION_CELLS_NUMBER) * 256
#define BATTERY_PACK_VOLTS_0 (LI_ION_CELL_VOLTS_0 * BATTERY_LI_ION_CELLS_NUMBER) * 256
#define BATTERY_PACK_VOLTS_100 (LI_ION_CELL_VOLTS_100 * BATTERY_LI_ION_CELLS_NUMBER) * 256
#define BATTERY_PACK_VOLTS_80 (LI_ION_CELL_VOLTS_80 * BATTERY_LI_ION_CELLS_NUMBER) * 256
#define BATTERY_PACK_VOLTS_60 (LI_ION_CELL_VOLTS_60 * BATTERY_LI_ION_CELLS_NUMBER) * 256
#define BATTERY_PACK_VOLTS_40 (LI_ION_CELL_VOLTS_40 * BATTERY_LI_ION_CELLS_NUMBER) * 256
#define BATTERY_PACK_VOLTS_20 (LI_ION_CELL_VOLTS_20 * BATTERY_LI_ION_CELLS_NUMBER) * 256
#define BATTERY_PACK_VOLTS_0 (LI_ION_CELL_VOLTS_0 * BATTERY_LI_ION_CELLS_NUMBER) * 256

#define ADC_BATTERY_VOLTAGE_K 73 // 0.272 << 8
#define BATTERY_LI_ION_CELLS_NUMBER 10
#define BATTERY_LI_ION_CELLS_NUMBER 13

#endif /* DISPLAY_KUNTENG_H_ */
Loading