102
102
*1.70 fix dshot for Kiss FC
103
103
*1.71 fix dshot for Ardupilot / Px4 FC
104
104
*1.72 Fix telemetry output and add 1 second arming.
105
+ *1.73 Fix false arming if no signal. Remove low rpm throttle protection below 300kv
105
106
*/
106
-
107
107
#include <stdint.h>
108
108
#include "main.h"
109
109
#include "targets.h"
121
121
122
122
123
123
#define VERSION_MAJOR 1
124
- #define VERSION_MINOR 72
124
+ #define VERSION_MINOR 73
125
125
126
126
typedef struct __attribute__((packed )) {
127
127
uint8_t version_major ;
@@ -135,6 +135,8 @@ firmware_info_s __attribute__ ((section(".firmware_info"))) firmware_info = {
135
135
device_name : FIRMWARE_NAME
136
136
};
137
137
138
+ uint8_t EEPROM_VERSION ;
139
+
138
140
//firmware build options
139
141
char BRUSHED_MODE = 0 ; // overrides everything else
140
142
char RC_CAR_REVERSE = 0 ; // have to set bidirectional, comp_pwm off and stall protection off, no sinusoidal startup
@@ -151,6 +153,7 @@ uint32_t REV_Id = 0;
151
153
152
154
uint16_t loop_time = 0 ;
153
155
uint16_t last_loop_time = 0 ;
156
+ uint16_t armed_timeout_count ;
154
157
155
158
uint8_t desync_happened = 0 ;
156
159
char maximum_throttle_change_ramp = 1 ;
@@ -526,6 +529,9 @@ void loadEEpromSettings(){
526
529
}
527
530
}
528
531
532
+ if (motor_kv < 300 ){
533
+ low_rpm_throttle_limit = 0 ;
534
+ }
529
535
low_rpm_level = motor_kv / 200 / (16 / motor_poles );
530
536
high_rpm_level = (40 + (motor_kv / 100 )) / (16 /motor_poles );
531
537
@@ -741,8 +747,9 @@ void tenKhzRoutine(){
741
747
if (!armed ){
742
748
if (inputSet ){
743
749
if (adjusted_input == 0 ){
744
- zero_input_count ++ ;
745
- if (zero_input_count > 10000 ){ // one second
750
+ armed_timeout_count ++ ;
751
+ if (armed_timeout_count > 10000 ){ // one second
752
+ if (zero_input_count > 30 ){
746
753
armed = 1 ;
747
754
#ifdef tmotor55
748
755
GPIOB -> BRR = LL_GPIO_PIN_3 ; // turn off red
@@ -761,9 +768,13 @@ if(!armed){
761
768
if (!servoPwm ){
762
769
RC_CAR_REVERSE = 0 ;
763
770
}
771
+ }else {
772
+ inputSet = 0 ;
773
+ armed_timeout_count = 0 ;
774
+ }
764
775
}
765
776
}else {
766
- zero_input_count = 0 ;
777
+ armed_timeout_count = 0 ;
767
778
}
768
779
}
769
780
}
@@ -815,10 +826,10 @@ if(!armed){
815
826
if (!running ){
816
827
old_routine = 1 ;
817
828
zero_crosses = 0 ;
818
- if (brake_on_stop ){
819
- fullBrake ();
829
+ if (brake_on_stop ){
830
+ fullBrake ();
820
831
821
- }
832
+ }
822
833
}
823
834
if (RC_CAR_REVERSE && prop_brake_active ) {
824
835
#ifndef PWM_ENABLE_BRIDGE
@@ -958,10 +969,10 @@ if(desync_check){
958
969
if (send_telemetry ){
959
970
#ifdef USE_SERIAL_TELEMETRY
960
971
makeTelemPackage (degrees_celsius ,
961
- battery_voltage ,
962
- actual_current ,
963
- (uint16_t )consumed_current /10 ,
964
- e_rpm );
972
+ battery_voltage ,
973
+ actual_current ,
974
+ (uint16_t )consumed_current /10 ,
975
+ e_rpm );
965
976
send_telem_DMA ();
966
977
send_telemetry = 0 ;
967
978
#endif
@@ -1060,7 +1071,8 @@ void zcfoundroutine(){ // only used in polling mode, blocking routine.
1060
1071
commutation_interval = (thiszctime + (3 * commutation_interval )) / 4 ;
1061
1072
advance = commutation_interval / advancedivisor ;
1062
1073
waitTime = commutation_interval /2 - advance ;
1063
- while (INTERVAL_TIMER -> CNT < waitTime ){
1074
+ // blanktime = commutation_interval / 4;
1075
+ while (INTERVAL_TIMER -> CNT - thiszctime < waitTime - advance ){
1064
1076
1065
1077
}
1066
1078
commutate ();
@@ -1157,6 +1169,7 @@ int main(void)
1157
1169
1158
1170
1159
1171
loadEEpromSettings ();
1172
+ // EEPROM_VERSION = *(uint8_t*)(0x08000FFC);
1160
1173
if (firmware_info .version_major != eepromBuffer [3 ] || firmware_info .version_minor != eepromBuffer [4 ]){
1161
1174
eepromBuffer [3 ] = firmware_info .version_major ;
1162
1175
eepromBuffer [4 ] = firmware_info .version_minor ;
@@ -1165,6 +1178,10 @@ int main(void)
1165
1178
}
1166
1179
saveEEpromSettings ();
1167
1180
}
1181
+ // if(EEPROM_VERSION != eepromBuffer[2]){
1182
+ // eepromBuffer[2] = EEPROM_VERSION;
1183
+ // saveEEpromSettings();
1184
+ // }
1168
1185
1169
1186
1170
1187
if (use_sin_start ){
@@ -1202,10 +1219,10 @@ int main(void)
1202
1219
}else {
1203
1220
playStartupTune ();
1204
1221
}
1205
-
1222
+ zero_input_count = 0 ;
1206
1223
MX_IWDG_Init ();
1207
1224
LL_IWDG_ReloadCounter (IWDG );
1208
- zero_input_count = 0 ;
1225
+
1209
1226
1210
1227
if (GIMBAL_MODE ){
1211
1228
bi_direction = 1 ;
@@ -1294,6 +1311,7 @@ if(newinput > 2000){
1294
1311
}
1295
1312
#endif
1296
1313
stuckcounter = 0 ;
1314
+
1297
1315
if (bi_direction == 1 && proshot == 0 && dshot == 0 ){
1298
1316
if (RC_CAR_REVERSE ){
1299
1317
if (newinput > (1000 + (servo_dead_band <<1 ))) {
@@ -1489,7 +1507,7 @@ if(newinput > 2000){
1489
1507
}
1490
1508
if ( stepper_sine == 0 ){
1491
1509
1492
- e_rpm = running * (100000 / e_com_time ) * 6 ;
1510
+ e_rpm = running * (100000 / e_com_time ) * 6 ;
1493
1511
k_erpm = e_rpm / 10 ; // ecom time is time for one electrical revolution in microseconds
1494
1512
if (low_rpm_throttle_limit ){ // some hardware doesn't need this, its on by default to keep hardware / motors protected but can slow down the response in the very low end a little.
1495
1513
@@ -1648,6 +1666,4 @@ void assert_failed(uint8_t *file, uint32_t line)
1648
1666
tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
1649
1667
/* USER CODE END 6 */
1650
1668
}
1651
- #endif /* USE_FULL_ASSERT */
1652
-
1653
-
1669
+ #endif /* USE_FULL_ASSERT */
0 commit comments