Skip to content

Commit

Permalink
repair ABS to use cycle length same as before PPM frame length changes
Browse files Browse the repository at this point in the history
  • Loading branch information
semerad committed May 14, 2012
1 parent 0797745 commit cd2d15d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .depend
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ eeprom.o: eeprom.c eeprom.h config.h gt3b.h stm8.h \
config.o: config.c config.h gt3b.h stm8.h task.h \
eeprom.h input.h
calc.o: calc.c calc.h gt3b.h stm8.h task.h menu.h ppm.h \
config.h eeprom.h input.h
config.h eeprom.h input.h timer.h
menu_common.o: menu_common.c menu.h gt3b.h stm8.h \
task.h config.h eeprom.h ppm.h input.h lcd.h buzzer.h
menu.o: menu.c menu.h gt3b.h stm8.h task.h config.h \
Expand Down
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*0.6.1 ()
repaired ABS to use cycle length same as before PPM frame length changes

*0.6.0 (28 Apr 2012)
increased model memories by using FLASH also
Expand Down
17 changes: 9 additions & 8 deletions calc.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "ppm.h"
#include "config.h"
#include "input.h"
#include "timer.h"



Expand Down Expand Up @@ -379,16 +380,16 @@ static void calc_loop(void) {
val = expo(val, (u8)(val < 0 ? cm.expo_forward : cm.expo_back));
if (cm.abs_type) {
// apply selected ABS
static u8 abs_cnt;
static u8 abs_time;
static _Bool abs_state; // when 1, lower brake value
// cycle time in 1ms steps: 120/80/60ms
u8 cycle_time = (u8)(cm.abs_type == 1 ? 120 :
cm.abs_type == 2 ? 80 : 60);

if (val > ABS_THRESHOLD) {
// count ABS
abs_cnt++;
if (cm.abs_type == 1 && abs_cnt >= 6
|| cm.abs_type == 2 && abs_cnt >= 4
|| cm.abs_type == 3 && abs_cnt >=3) {
abs_cnt = 0;
// check time with 40ms reserve and change abs_state
if ((u8)(ppm_timer - abs_time) <= 40) {
abs_time = (u8)(ppm_timer + cycle_time);
abs_state ^= 1;
}
// apply ABS
Expand All @@ -397,7 +398,7 @@ static void calc_loop(void) {
}
else {
// no ABS
abs_cnt = 0;
abs_time = (u8)(ppm_timer + cycle_time);
abs_state = 0;
}
}
Expand Down

0 comments on commit cd2d15d

Please sign in to comment.