Skip to content

Commit c8393c8

Browse files
author
Bjoern Schmidt
committed
cal_a changed 1->10!
tq calib changable via app app version in prefs
1 parent d840018 commit c8393c8

File tree

8 files changed

+19
-6
lines changed

8 files changed

+19
-6
lines changed

ACAcontrollerState.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ void controllerstate_init(void) {
158158
if (eepromVal > 0) ui8_throttle_max_range = eepromVal;
159159
eepromVal = eeprom_read(OFFSET_PAS_TRESHOLD);
160160
if (eepromVal > 0) flt_s_pas_threshold = int2float(eepromVal, 4.0);
161+
eepromVal = eeprom_read(OFFSET_TQ_CALIB);
162+
if (eepromVal > 0) flt_torquesensorCalibration = int2float(eepromVal, 8000.0);
161163
eepromVal = eeprom_read(OFFSET_PID_GAIN_P);
162164
if (eepromVal > 0) flt_s_pid_gain_p = int2float(eepromVal, 2.0);
163165
eepromVal = eeprom_read(OFFSET_PID_GAIN_I);

ACAeeprom.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ typedef enum {
4747
OFFSET_CURRENT_CAL_A = ((uint8_t) 0x11),
4848

4949
OFFSET_ACA_FLAGS_HIGH_BYTE = ((uint8_t) 0x12),
50-
OFFSET_ACA_FLAGS = ((uint8_t) 0x13)
50+
OFFSET_ACA_FLAGS = ((uint8_t) 0x13),
51+
52+
OFFSET_TQ_CALIB = ((uint8_t) 0x14)
5153

5254
} BO_EEPROM_OFFSETS;
5355

BOdisplay.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,13 @@ void addConfigStateInfos(void) {
114114
addPayload(CODE_PAS_TRESHOLD, float2int(flt_s_pas_threshold, 4.0));
115115
addPayload(CODE_PID_GAIN_P, float2int(flt_s_pid_gain_p, 2.0));
116116
addPayload(CODE_PID_GAIN_I, float2int(flt_s_pid_gain_i, 2.0));
117+
addPayload(CODE_TQ_CALIB, float2int(flt_torquesensorCalibration, 8000.0));
117118
addPayload(CODE_RAMP_END, ui16_s_ramp_end >> 5);
118119
addPayload(CODE_RAMP_START, ui16_s_ramp_start >> 6);
119120
addPayload(CODE_MAX_BAT_CURRENT_HIGH_BYTE, ui16_battery_current_max_value >> 8);
120121
addPayload(CODE_MAX_BAT_CURRENT, ui16_battery_current_max_value);
121122
addPayload(CODE_MAX_REGEN_CURRENT, ui16_regen_current_max_value);
122-
// 1 more elements left/avail (max22)
123+
// 0 more elements left/avail (max22)
123124

124125
}
125126

@@ -320,6 +321,13 @@ void digestConfigRequest(uint8_t configAddress, uint8_t requestedCodeLowByte, ui
320321
}
321322
addPayload(requestedCodeLowByte, ui16_s_ramp_end >> 5);
322323
break;
324+
case CODE_TQ_CALIB:
325+
flt_torquesensorCalibration = int2float(requestedValue, 8000.0);
326+
if (configAddress == EEPROM_ADDRESS) {
327+
eeprom_write(OFFSET_TQ_CALIB, requestedValue);
328+
}
329+
addPayload(requestedCodeLowByte, float2int(flt_torquesensorCalibration, 8000.0));
330+
break;
323331
case CODE_RAMP_START:
324332
ui16_s_ramp_start = requestedValue << 6;
325333
if (configAddress == EEPROM_ADDRESS) {

BOdisplay.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ typedef enum {
104104
CODE_PID_GAIN_I = ((uint8_t) 0x8C),
105105
CODE_RAMP_END = ((uint8_t) 0x8D),
106106
CODE_RAMP_START = ((uint8_t) 0x8E),
107+
CODE_TQ_CALIB = ((uint8_t) 0x8F),
107108

108109
CODE_ACTUAL_MAX_SPEED = ((uint8_t) 0x90),
109110
CODE_MAX_SPEED_WITHOUT_PAS = ((uint8_t) 0x91),

BluOsec-release.apk

604 Bytes
Binary file not shown.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ The tool is started by double-clicking on "OSEC Parameter Configurator. jar" in
154154

155155
* **Motor specific angle**: with this value the timing of the motor control can be changed. As a result, manufacturing inaccuracies of the Hall sensor positions in the motor can be compensated. Only change if the motor starts badly.
156156

157-
* **Battery Current cal a**: Factor a in the calibration function Current in ampere = a * ADC value Required for internal calculation of the current from the 10bit ADC value. Only needs to be changed if the calibration obviously does not fit with the preset values.
157+
* **Battery Current cal a**: Factor a in the calibration function. 1A = a/10 * ADC value. Required for internal calculation of the current from the 10bit ADC value. Only needs to be changed if the calibration obviously does not fit with the preset values.
158158

159159
* **Temperature cal a**: Factor a in the calibration function temperature in °C = a * ADC value + b. For temperature calculation from external sensor connected to pad X4 and GND. Temperature is shown in the LCD3 but not processed to reduce power if temperature is getting to high actually.
160160

display.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ void send_message() {
137137
// each unit of B8 = 0.25A
138138

139139

140-
ui8_tx_buffer [8] = (uint8_t) (((ui16_BatteryCurrent - ui16_current_cal_b + 1) << 2) / ui8_current_cal_a);
140+
ui8_tx_buffer [8] = (uint8_t) ((((ui16_BatteryCurrent - ui16_current_cal_b + 1) << 2)*10) / ui8_current_cal_a);
141141
// B9: motor temperature
142142
ui8_tx_buffer [9] = i8_motor_temperature - 15; //according to documentation at endless sphere
143143
// B10 and B11: 0

display_kingmeter.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,8 +432,8 @@ void kingmeter_update(void) {
432432

433433
KM.Tx.Error = KM_ERROR_NONE;
434434

435-
if (((ui8_current_cal_a * ui16_BatteryCurrent) / 10 - ui16_current_cal_b) != 0x99) {
436-
KM.Tx.Current_x10 = (ui8_current_cal_a * ui16_BatteryCurrent) / 10 - ui16_current_cal_b; //calculate Amps out of 10bit ADC value
435+
if (((ui8_current_cal_a * ui16_BatteryCurrent) / 100 - ui16_current_cal_b) != 0x99) {
436+
KM.Tx.Current_x10 = (ui8_current_cal_a * ui16_BatteryCurrent) / 100 - ui16_current_cal_b; //calculate Amps out of 10bit ADC value
437437
}
438438

439439
/* Receive Rx parameters/settings and send Tx parameters */

0 commit comments

Comments
 (0)