Skip to content

Commit

Permalink
Experimental torque-only high-RPM hack
Browse files Browse the repository at this point in the history
  • Loading branch information
rnovikov authored and rnovikov committed Apr 3, 2020
1 parent 6664e21 commit 27b03c3
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 1,371 deletions.
1 change: 1 addition & 0 deletions src/controller/TSDZ2_controller.cflags
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-std=c17
2 changes: 2 additions & 0 deletions src/controller/TSDZ2_controller.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Add predefined macros for your project here. For example:
// #define THE_ANSWER 42
1 change: 1 addition & 0 deletions src/controller/TSDZ2_controller.creator
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[General]
1 change: 1 addition & 0 deletions src/controller/TSDZ2_controller.cxxflags
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-std=c++17
31 changes: 31 additions & 0 deletions src/controller/TSDZ2_controller.files
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
adc.c
adc.h
brake.c
brake.h
config.h
ebike_app.c
ebike_app.h
interrupts.h
lights.c
lights.h
main.c
main.h
motor.c
motor.h
pas.c
pas.h
pins.h
pwm.c
pwm.h
timers.c
timers.h
torque_sensor.c
torque_sensor.h
uart.c
uart.h
utils.c
utils.h
watchdog.c
watchdog.h
wheel_speed_sensor.c
wheel_speed_sensor.h
4 changes: 4 additions & 0 deletions src/controller/TSDZ2_controller.includes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.
..
/usr/local/Cellar/sdcc/3.9.0/share/sdcc/include/
../common/STM8S_StdPeriph_Lib/inc
17 changes: 6 additions & 11 deletions src/controller/ebike_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,17 +225,9 @@ static void ebike_control_motor(void)
{
ui32_assist_level_factor_x1000 = (uint32_t) m_config_vars.ui16_assist_level_factor_x1000;
// force a min of 10 RPM cadence
ui32_pedal_power_no_cadence_x10 = (((uint32_t) ui16_m_pedal_torque_x100 * 10) / (uint32_t) 96);
ui32_pedal_power_no_cadence_x10 = (((uint32_t) ui16_m_pedal_torque_x100 * 10) / 50U);

if (m_config_vars.ui8_motor_assistance_startup_without_pedal_rotation == 0 ||
ui8_pas_cadence_rpm)
{
ui32_current_amps_x10 = ((uint32_t) ui16_m_pedal_power_x10 * ui32_assist_level_factor_x1000) / 1000;
}
else
{
ui32_current_amps_x10 = (ui32_pedal_power_no_cadence_x10 * ui32_assist_level_factor_x1000) / 1000;
}
ui32_current_amps_x10 = (ui32_pedal_power_no_cadence_x10 * ui32_assist_level_factor_x1000) / 1000;

// 6.410 = 1 / 0.156 (each ADC step for current)
// 6.410 * 8 = ~51
Expand All @@ -252,6 +244,7 @@ static void ebike_control_motor(void)
ui16_m_adc_target_current = ui16_adc_current;

// now calculate the current for BOOST
/* we don't need the BOOST anymore
if (m_config_vars.ui16_startup_motor_power_boost_assist_level > 0)
{
ui32_current_amps_x10 = (ui32_pedal_power_no_cadence_x10 * (uint32_t) m_config_vars.ui16_startup_motor_power_boost_assist_level) / 100;
Expand All @@ -270,6 +263,7 @@ static void ebike_control_motor(void)
ui16_adc_max_current_boost_state = ui16_adc_current;
}
*/
}
else
{
Expand Down Expand Up @@ -682,7 +676,8 @@ static void communications_process_packages(uint8_t ui8_frame_type)
}

// calculate current step for ramp up
ui32_temp = ((uint32_t) 24375) / ((uint32_t) m_config_vars.ui8_ramp_up_amps_per_second_x10); // see note below
// ui32_temp = ((uint32_t) 24375) / ((uint32_t) m_config_vars.ui8_ramp_up_amps_per_second_x10); // see note below
ui32_temp = ((uint32_t) 10000) / ((uint32_t) m_config_vars.ui8_ramp_up_amps_per_second_x10); // see note below
ui16_g_current_ramp_up_inverse_step = (uint16_t) ui32_temp;

/*---------------------------------------------------------
Expand Down
Binary file removed src/controller/main.bin
Binary file not shown.
Loading

0 comments on commit 27b03c3

Please sign in to comment.