ADD: example code for turbo boost

This commit is contained in:
Niklas Fauth 2018-05-08 13:06:10 +02:00
parent 312d08b944
commit 206f67631a
3 changed files with 16 additions and 7 deletions

View File

@ -42,6 +42,15 @@
#define SPEED_COEFFICIENT 0.5
#define STEER_COEFFICIENT 0.5
//Turno boost at high speeds while button1 is pressed:
//#define ADDITIONAL_CODE \
if (button1 && speed > 700) { /* field weakening at high speeds */ \
weakl = cmd1 - 700; /* weak should never exceed 400 or 450 MAX!! */ \
weakr = cmd1 - 700; } \
else { \
weakl = 0; \
weakr = 0; }
// ###### BOBBYCAR ######
// #define FILTER 0.1
// #define SPEED_COEFFICIENT -1

View File

@ -141,6 +141,11 @@ int main(void) {
timeout = 0;
#endif
// ####### ADDITIONAL CODE #######
#ifdef ADDITIONAL_CODE
ADDITIONAL_CODE;
#endif
// ####### LOW-PASS FILTER #######
steer = steer * (1.0 - FILTER) + cmd1 * FILTER;
speed = speed * (1.0 - FILTER) + cmd2 * FILTER;
@ -155,11 +160,6 @@ int main(void) {
setScopeChannel(2, (int)speedR);
setScopeChannel(3, (int)speedL);
// ####### ADDITIONAL CODE #######
#ifdef ADDITIONAL_CODE
ADDITIONAL_CODE;
#endif
// ####### SET OUTPUTS #######
if ((speedL < lastSpeedL + 50 && speedL > lastSpeedL - 50) && (speedR < lastSpeedR + 50 && speedR > lastSpeedR - 50) && timeout < TIMEOUT) {
pwmr = speedR;

View File

@ -991,7 +991,7 @@
:103DC800F7DD0D4820210022FEF76CF8FEE70023FE
:103DD800054A1370054A137084E600BF18000020D6
:103DE8000000104200000442CC000020B000002077
:103DF8000000F041C400002000080140000000005D
:103DF8000000F841C4000020000801400000000055
:103E08000222854B5A60854B1B68B3F57A7F3ADAF4
:103E18000133824A1360824A938899B281480368C1
:103E28000B4403EBD3735B100360D38899B27E48CD
@ -1028,7 +1028,7 @@
:104018007B14AE47E17A943F00000240AC000020D8
:10402800680200200C000020080000201400002076
:10403800100000201C00002020000020D4000020D8
:104048001F85EB5118000020000039C000003940DE
:104048001F85EB511800002000002EC000002E40F4
:1040580004000020C400002000340140002C01406E
:10406800914A536C43F40043536490498B6813F0AE
:10407800200F0CBF012200228B6813F0400F0CBFE9