|
18 | 18 | #include "common.h" |
19 | 19 |
|
20 | 20 | #define REVISION 14 |
21 | | -#define REVPATCH 4 |
| 21 | +#define REVPATCH 5 |
22 | 22 |
|
23 | 23 | const Cfg cfgdata = { |
24 | 24 | .id = 0x32ea, |
@@ -65,7 +65,7 @@ const Cfg cfgdata = { |
65 | 65 | .music = MUSIC, // Startup music |
66 | 66 | .volume = VOLUME, // Sound volume (%) [0..100] |
67 | 67 | .beacon = BEACON, // Beacon volume (%) [0..100] |
68 | | - .bec = BEC, // BEC voltage control [0..3] |
| 68 | + .bec = BEC, // BEC voltage control (0 - 5.5V, 1 - 6.5V, 2 - 7.4V, 3 - 8.4V) |
69 | 69 | .led = LED, // LED on/off bits [0..15] |
70 | 70 | }; |
71 | 71 |
|
@@ -427,7 +427,7 @@ void adcdata(int t, int u, int v, int c, int a) { |
427 | 427 | c = 0; |
428 | 428 | } |
429 | 429 | temp1 = max((t = smooth(&st, t, 10)) >> 2, 0); // C |
430 | | - temp2 = max((u = smooth(&su, TEMP_SENS(u), 10)) >> 2, 0); // C |
| 430 | + temp2 = hall || cfg.prot_sens ? max((u = smooth(&su, TEMP_SENS(u), 10)) >> 2, 0) : 0; // C |
431 | 431 | volt = smooth(&sv, v * VOLT_MUL * 131 >> 17, 7); // V/100 |
432 | 432 | curr = smooth(&sc, c * CURR_MUL * 205 >> 11, 4); // A/100 |
433 | 433 | i += curr; // Current integral |
@@ -607,7 +607,7 @@ void main(void) { |
607 | 607 | #endif |
608 | 608 | laststep(); |
609 | 609 | PID bpid = {.Kp = 50, .Ki = 0, .Kd = 1000}; // Stall protection |
610 | | - PID cpid = {.Kp = 400, .Ki = 0, .Kd = 600}; // Overcurrent protection |
| 610 | + PID cpid = {.Kp = 80, .Ki = 0, .Kd = 600}; // Overcurrent protection |
611 | 611 | for (int curduty = 0, running = 0, braking = 2, cutoff = 0, boost = 0, choke = 0, n = 0;;) { |
612 | 612 | int ccr, arr = CLK_KHZ / cfg.freq_min; |
613 | 613 | int input = cutoff == 3000 ? 0 : throt; |
@@ -679,8 +679,8 @@ void main(void) { |
679 | 679 | if (brushed && step != reverse + 1) step = 0; // Change brushed direction |
680 | 680 | if ((newduty += boost - choke) < 0) newduty = 0; |
681 | 681 | if (ertm) { // Variable PWM frequency |
| 682 | + arr = scale(ertm, 1000, 2000, CLK_KHZ / cfg.freq_max, arr); // 30..60 kERPM |
682 | 683 | erpm = 60000000 / ertm; |
683 | | - arr = scale(erpm, 30000, 60000, arr, CLK_KHZ / cfg.freq_max); |
684 | 684 | } |
685 | 685 | int maxduty = min(scale(erpm, 0, cfg.duty_ramp * 1000, cfg.duty_spup * 20, 2000), 2000 - cutback * 25); // 75% cutback at 15C above prot_temp |
686 | 686 | if (newduty > maxduty) newduty = maxduty; |
|
0 commit comments