Skip to content

Commit ee019f1

Browse files
committed
Preliminary testing of new power algo.
Commented out ANTIBACKWARDS in attempt to solve panic / load error during testing
1 parent a80e631 commit ee019f1

4 files changed

Lines changed: 94 additions & 17 deletions

File tree

include/LoadConfig.hpp

Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -189,16 +189,23 @@ namespace LOAD {
189189
static_assert(NUM_COMBINATIONS == (1u << NUM_PINS),
190190
"NUM_COMBINATIONS must be 2^NUM_PINS");
191191

192-
constexpr uint_fast8_t VOLT_LIMIT_SIZE = 20; // CONFIG
192+
constexpr uint_fast8_t VOLT_LIMIT_SIZE = 46; // CONFIG
193+
// etl::array<uint_fast16_t, VOLT_LIMIT_SIZE> VOLT_LIMITS_TABLE_mV = {
194+
// #include "triggerVoltages_mV.csv"
195+
// };
193196
etl::array<uint_fast16_t, VOLT_LIMIT_SIZE> VOLT_LIMITS_TABLE_mV = {
194-
20'000, 19'500, 19'375, 19'250, 19'125, // 4
195-
19'000, 18'500, 18'000, 17'500, 17'000, // 3
196-
16'000, 00'000, 15'000, 14'600, 14'200, // 2
197-
13'800, 13'400, 13'000, 12'000, 11'000//, // 1
198-
// 10'000 // 0
199-
};
200-
201-
constexpr uint_fast8_t RES_INDEX_SIZE = 45; // CONFIG
197+
25000, 24000, 23660, 23330, 23000, // 9
198+
22660, 22330, 22000, 21815, 21630, // 8
199+
21444, 21259, 21074, 20889, 20704, // 7
200+
20519, 20333, 20148, 19963, 19778, // 6
201+
19593, 19407, 19222, 19037, 18852, // 5
202+
18667, 18481, 18296, 18111, 17926, // 4
203+
17741, 17556, 17370, 17185, 17000, // 3
204+
16750, 16500, 16250, 16000, 15750, // 2
205+
15500, 15250, 15000, 14750, 14500, // 1
206+
14250}; // 0, enable at 14000
207+
208+
constexpr uint_fast8_t RES_INDEX_SIZE = 46; // CONFIG
202209
etl::array<uint_fast8_t, RES_INDEX_SIZE> RES_INDEX_TABLE = {
203210
0, 1, 2, 4, 3, // 9
204211
8, 5, 6, 9, 12, // 8
@@ -208,9 +215,32 @@ namespace LOAD {
208215
31, 33, 35, 36, 40, // 4
209216
37, 41, 39, 44, 48, // 3
210217
45, 46, 50, 47, 51, // 2
211-
56, 53, 54, 57, 55//, // 1
212-
// 60 // 0
218+
56, 53, 54, 57, 55, // 1
219+
60 // 0, 63 default
213220
};
221+
222+
// etl::array<uint_fast16_t, VOLT_LIMIT_SIZE> VOLT_LIMITS_TABLE_mV = {
223+
// 20'000, 19'500, 19'375, 19'250, 19'125, // 4
224+
// 19'000, 18'500, 18'000, 17'500, 17'000, // 3
225+
// 16'000, 00'000, 15'000, 14'600, 14'200, // 2
226+
// 13'800, 13'400, 13'000, 12'000, 11'000//, // 1
227+
// // 10'000 // 0
228+
// };
229+
230+
// constexpr uint_fast8_t RES_INDEX_SIZE = 45; // CONFIG
231+
// etl::array<uint_fast8_t, RES_INDEX_SIZE> RES_INDEX_TABLE = {
232+
// 0, 1, 2, 4, 3, // 9
233+
// 8, 5, 6, 9, 12, // 8
234+
// 16, 11, 7, 14, 13, // 7
235+
// 15, 19, 24, 21, 22, // 6
236+
// 25, 23, 28, 29, 32, // 5
237+
// 31, 33, 35, 36, 40, // 4
238+
// 37, 41, 39, 44, 48, // 3
239+
// 45, 46, 50, 47, 51, // 2
240+
// 56, 53, 54, 57, 55//, // 1
241+
// // 60 // 0
242+
// };
243+
214244
// constexpr uint_fast8_t RES_INDEX_SIZE = 46; // CONFIG
215245
// etl::array<uint_fast8_t, RES_INDEX_SIZE> RES_INDEX_TABLE = {
216246
// 0, 1, 2, 4, 3, 8, 5, 6, 9, 12, 16, 11, 7, 14, 13, 15,

include/LoadContainer.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class LoadContainer {
2020
// Arduino Loop has priority 1
2121
// TODO: Note: Task priority must be < 25
2222

23-
TaskInfo tFSM{vTaskUpdateFSM, "FSM", 2048, nullptr, 20,
23+
TaskInfo tFSM{vTaskUpdateFSM, "FSM", 4096, nullptr, 20,
2424
nullptr, 0, false, true};
2525
TaskInfo tPoll{vTPollS, "Poll", 4096, nullptr, 20,
2626
nullptr, 0, false, false};
@@ -61,7 +61,7 @@ class LoadContainer {
6161
inline bool isTargetRPMExceeded() const {
6262
// constexpr uint_fast16_t TARGET_RPM = 2200; // todo
6363
// return (currentRPM > TARGET_RPM);
64-
constexpr uint_fast16_t TARGET_POWER_mW = 40000; // todo
64+
constexpr uint_fast16_t TARGET_POWER_mW = 40000; // TODO, expecting ? RPM
6565
return (INA260::power_mW > TARGET_POWER_mW);
6666
} // todo
6767

include/LoadFSM.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,21 +57,21 @@ class LoadFSM {
5757
* an error occurred
5858
*/
5959
UPDATE_RESULT updateState() {
60-
ESP_LOGI(TAG, "AWDAWDAWDA");
60+
// ESP_LOGI(TAG, "AWDAWDAWDA");
6161
// Check safety task / E-Stop conditions
6262
if ((currentState != FSMCommon::States::sESTOP) &&
6363
(load.getSafetyFlag() != ESTOP_TYPE_FAST::NONE)) {
6464
// * -> sESTOP
6565
currentState = FSMCommon::States::sESTOP;
66-
ESP_LOGI(TAG, "ANTIBACKWARDS = %s", antiBackwards);
66+
// ESP_LOGI(TAG, "ANTIBACKWARDS = %s", antiBackwards);
6767
// DONE: Signal nacelle to ESTOP (setSafetyFlag)
6868
vTaskSuspend(load.tAdjustLoad.pxHandle);
6969
// Don't adjust load
7070

7171
return UPDATE_RESULT::STATE_CHANGED;
7272
} else if ((currentState == FSMCommon::States::sESTOP) &&
7373
(load.getSafetyFlag() != ESTOP_TYPE_FAST::NONE)) {
74-
INA260::antiBackwards = 0;
74+
// INA260::antiBackwards = 0;
7575
// sESTOP -> sESTOP: Nothing to do
7676
return UPDATE_RESULT::NO_CHANGE;
7777
} else {
@@ -153,7 +153,7 @@ class LoadFSM {
153153
return UPDATE_RESULT::ERROR;
154154
}
155155

156-
int antiBackwards = 0;
156+
// int antiBackwards = 0;
157157
private: // MARK: Private
158158
LoadContainer &load; // todo switch to by reference
159159

include/triggerVoltages_mV.csv

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
25000,
2+
24000,
3+
23660,
4+
23330,
5+
23000,
6+
22660,
7+
22330,
8+
22000,
9+
21815,
10+
21630,
11+
21444,
12+
21259,
13+
21074,
14+
20889,
15+
20704,
16+
20519,
17+
20333,
18+
20148,
19+
19963,
20+
19778,
21+
19593,
22+
19407,
23+
19222,
24+
19037,
25+
18852,
26+
18667,
27+
18481,
28+
18296,
29+
18111,
30+
17926,
31+
17741,
32+
17556,
33+
17370,
34+
17185,
35+
17000,
36+
16750,
37+
16500,
38+
16250,
39+
16000,
40+
15750,
41+
15500,
42+
15250,
43+
15000,
44+
14750,
45+
14500,
46+
14250,
47+
14000

0 commit comments

Comments
 (0)