// Considering the follow voltage values for each li-ion battery cell
// State of charge | voltage
#define LI_ION_CELL_VOLTS_MAX 4.25
#define LI_ION_CELL_VOLTS_100 4.20
#define LI_ION_CELL_VOLTS_80 4.02
#define LI_ION_CELL_VOLTS_60 3.87
#define LI_ION_CELL_VOLTS_40 3.80
#define LI_ION_CELL_VOLTS_20 3.73
#define LI_ION_CELL_VOLTS_10 3.69
#define LI_ION_CELL_VOLTS_0 3.27
#define LI_ION_CELL_VOLTS_MIN 3.10
#define BATTERY_PACK_VOLTS_100 ((float) LI_ION_CELL_VOLTS_100 * (BATTERY_LI_ION_CELLS_NUMBER << 8))
#define BATTERY_PACK_VOLTS_80 ((float) LI_ION_CELL_VOLTS_80 * (BATTERY_LI_ION_CELLS_NUMBER << 8))
#define BATTERY_PACK_VOLTS_60 ((float) LI_ION_CELL_VOLTS_60 * (BATTERY_LI_ION_CELLS_NUMBER << 8))
#define BATTERY_PACK_VOLTS_40 ((float) LI_ION_CELL_VOLTS_40 * (BATTERY_LI_ION_CELLS_NUMBER << 8))
#define BATTERY_PACK_VOLTS_20 ((float) LI_ION_CELL_VOLTS_20 * (BATTERY_LI_ION_CELLS_NUMBER << 8))
#define BATTERY_PACK_VOLTS_10 ((float) LI_ION_CELL_VOLTS_10 * (BATTERY_LI_ION_CELLS_NUMBER << 8))
#define BATTERY_PACK_VOLTS_0 ((float) LI_ION_CELL_VOLTS_0 * (BATTERY_LI_ION_CELLS_NUMBER << 8))
// calc battery pack state of charge (SOC)
ui16_battery_volts = ((uint16_t) ebike_app_get_ADC_battery_voltage_filtered ()) * ((uint16_t) ADC_BATTERY_VOLTAGE_K);
if (ui16_battery_volts > ((uint16_t) BATTERY_PACK_VOLTS_80)) { ui8_battery_soc = 16; } // 4 bars | full
else if (ui16_battery_volts > ((uint16_t) BATTERY_PACK_VOLTS_60)) { ui8_battery_soc = 12; } // 3 bars
else if (ui16_battery_volts > ((uint16_t) BATTERY_PACK_VOLTS_40)) { ui8_battery_soc = 8; } // 2 bars
else if (ui16_battery_volts > ((uint16_t) BATTERY_PACK_VOLTS_20)) { ui8_battery_soc = 4; } // 1 bar
else if (ui16_battery_volts > ((uint16_t) BATTERY_PACK_VOLTS_10)) { ui8_battery_soc = 3; } // empty
else { ui8_battery_soc = 1; } // flashing
casainho said:The Eclipse version I use do show me as I expect...
Can you quick try with #error? That is a safe why to see.stancecoke said:casainho said:The Eclipse version I use do show me as I expect...
Obviously there are more differences between the toolchain in linux and the toolchain in windows. Perhaps geofft or d can crosscheck my findings in a windows system...
stancecoke said:casainho said:The Eclipse version I use do show me as I expect...
Obviously there are more differences between the toolchain in linux and the toolchain in windows. Perhaps geofft or honya96 can crosscheck my findings in a windows system, for me the errors were reproducable on two different laptops...
casainho said:Can you quick try with #error? That is a safe why to see.
During build time. If you put #error on a line that is built, you will get the error.stancecoke said:casainho said:Can you quick try with #error? That is a safe why to see.
Where is the message shown?
#if (EBIKE_THROTTLE_TYPE == EBIKE_THROTTLE_TYPE_THROTTLE_PAS)
ebike_throttle_type_throttle_pas ();
#error "Throttle"
#elif (EBIKE_THROTTLE_TYPE == EBIKE_THROTTLE_TYPE_TORQUE_SENSOR)
ebike_throttle_type_torque_sensor ();
#error "Torquesensor"
#else
#error "not defined"
#endif
ebike_app.c:153:2: error: #error "Torquesensor"
So it seems to be working as supposed as on config.h file you should have other define:stancecoke said:And I can confirm: If the lines in the main.h are not commented out, the error "Torquesensor" occurs.
Code:#if (EBIKE_THROTTLE_TYPE == EBIKE_THROTTLE_TYPE_THROTTLE_PAS) ebike_throttle_type_throttle_pas (); #error "Throttle" #elif (EBIKE_THROTTLE_TYPE == EBIKE_THROTTLE_TYPE_TORQUE_SENSOR) ebike_throttle_type_torque_sensor (); #error "Torquesensor" #else #error "not defined" #endif
Code:ebike_app.c:153:2: error: #error "Torquesensor"
#define EBIKE_THROTTLE_TYPE EBIKE_THROTTLE_TYPE_TORQUE_SENSOR
casainho said:So it seems to be working as supposed as on config.h file you should have other define:
Code:#define EBIKE_THROTTLE_TYPE EBIKE_THROTTLE_TYPE_TORQUE_SENSOR
/*
* config.h
*
* Automatically created by Flexible OpenSource firmware - Configuration tool
* Author: stancecoke
* Author: casainho
*/
#ifndef CONFIG_H_
#define CONFIG_H_
//#define EBIKE_THROTTLE_TYPE EBIKE_THROTTLE_TYPE_TORQUE_SENSOR
#define EBIKE_THROTTLE_TYPE EBIKE_THROTTLE_TYPE_THROTTLE_PAS
#define EBIKE_THROTTLE_TYPE_THROTTLE_PAS_CURRENT_SPEED
#define EBIKE_THROTTLE_TYPE_THROTTLE_PAS_ASSIST_LEVEL_PAS_ONLY
#define PAS_NUMBER_MAGNETS 12
#define PAS_MAX_CADENCE_RPM 80
#define PAS_DIRECTION PAS_DIRECTION_RIGHT
#define ASSIST_LEVEL_0 0.0
#define ASSIST_LEVEL_1 0.2
#define ASSIST_LEVEL_2 0.4
#define ASSIST_LEVEL_3 0.6
#define ASSIST_LEVEL_4 0.8
#define ASSIST_LEVEL_5 1.0
#define BATTERY_LI_ION_CELLS_NUMBER 13
#define ADC_BATTERY_CURRENT_MAX 35
#define ADC_BATTERY_REGEN_CURRENT_MAX 35
#define MOTOR_ROTOR_OFFSET_ANGLE 210 // 210 adjusted as a good value for Q11 direct drive motor
#define FOC_READ_ID_CURRENT_ANGLE_ADJUST 115
#define FOC_READ_ID_CURRENT_ANGLE_ADJUST_INVERT 242
#define MOTOR_ROTOR_ERPS_START_INTERPOLATION_60_DEGREES 10
#define ADC_MOTOR_CURRENT_MAX 120
#define ADC_MOTOR_REGEN_CURRENT_MAX 66
#define PWM_DUTY_CYCLE_RAMP_UP_INVERSE_STEP 10
#define PWM_DUTY_CYCLE_RAMP_DOWN_INVERSE_STEP 10
#define EBIKE_REGEN_EBRAKE_LIKE_COAST_BRAKES
#endif /* CONFIG_H_ */
Wait! So if we do not use that 2 lines, everything works as expected, right??stancecoke said:And I can confirm: If the lines in the main.h are not commented out, the error "Torquesensor" occurs.
stancecoke said:casainho said:Please update your master branch as I just update it with my most recent code.
The recent master branch throws an error while compiling with windows.![]()
Code:ebike_app.asm:366: Error: <a> machine specific addressing or addressing mode error ebike_app.asm:403: Error: <a> machine specific addressing or addressing mode error
Can you fix that? Otherwise I have to start from an earlier commit...
regards
stancecoke
geofft said:Edit: Crossed posts with casainho, looks like he might now be sorting this?
Something tells me this one will be hard.stancecoke said:the one with the errors while compiling (not solved yet)....
eyebyesickle said:Yes, from what I can tell, all 6 pin controllers are the same, and all 8 pin controllers are the same, you can just program them as needed. The 36v and 48v motors are different however, with slightly different winds.casainho said:Thank you for your help. And about the voltages, do you think they can also be configured? like the 52V motor controller be configured to work at 48V and 36V?eyebyesickle said:Take note, alot of resellers claim 18a, but almost no one actually knows or sets it at that. FutureBike Italy is on top of his stuff, so he probably does have the 18a, but I know EVERY other company I contact doesn't even really know. If you scroll way back in this thread, you will see where I opened some '18a' motors, and they had a 15a controller inside. Furthermore, the 15a controllers usually are only set to 13a!, so take note...casainho said:Nice to know that this controllers can hold 18A, this means 48V version can hold 864W (900W considering a full charged battery) with and not can the 720W (advertised 750W, considering battery will hold a bit higher voltage when charged) of 48V * 15A controller. I think 15A controller is just a configured parameter on the firmware and not the controller max current limit, that should be at least that 18A!!
18a is the highest I recommend though, FYI....
If I comment the 2 lines at main.h:stancecoke said:geofft said:Edit: Crossed posts with casainho, looks like he might now be sorting this?
Thank you for the fast testing! We have two different topics. The one with the #defines (solved now) and the one with the errors while compiling (not solved yet)....
//#define EBIKE_THROTTLE_TYPE_THROTTLE_PAS 1
//#define EBIKE_THROTTLE_TYPE_TORQUE_SENSOR 2
casainho said:Between sun and rain, today I did a good ride of 1h30 betweem home and near beachs.
The firmware was built with SDCC 3.7.0.
The version I am using is on master branch of github. I just updated the compiler version to 3.7.0 and I found that the compiled firmware was about 40% smaller but still works the same.geofft said:casainho said:Between sun and rain, today I did a good ride of 1h30 betweem home and near beachs.
The firmware was built with SDCC 3.7.0.
Will you be making this latest version be available on github sometime? I just wondered if it may have any effect on the (windows users) compiling issue?
casainho said:The version I am using is on master branch of github. I just updated the compiler version to 3.7.0 and I found that the compiled firmware was about 40% smaller but still works the same.geofft said:Will you be making this latest version be available on github sometime? I just wondered if it may have any effect on the (windows users) compiling issue?
The issue is thay the SDCC developers didn't put online a Windows version for 3.7.0 unlike on version 3.6.0. On Linux, I had to compile/build the version 3.7.0 but it is a regular way of doing it, we are used already to compile some of the software, mainly when we want the latest versions.
Please search on Google, maybe some one already compiled SDCC 3.7.0 and is sharing the executables.