13 Commits

Author SHA1 Message Date
jonny_l480
c738ac96b1 Fix MASSAGE-mode messing up acceleration config
- do not update nvs with low accel when changing to massage
- store and restore previous value when changing from/to massage mode
2024-05-30 09:33:53 +02:00
jonny_l480
a839d61f65 Add menu item to set brake-deceleration
Also simplify motorctl by removing two variables
and using config struct instead
2024-05-20 09:08:10 +02:00
jonny_l480
3ebcd6ad3c Rework brake (decel-boost): simplify, config option
Briefly tested this - brake works as intended

- Add config options brakeDecel and brakePauseBefureResume
- control: update brakeStartThresholdDuty at startup
    and maxDuty change for each motor
- motorctl: drop/simplify decel boost to brake
    (faster deceleration at certain threshold)
2024-05-18 23:32:52 +02:00
jonny_l480
5d1d17915d make control-modes and TCS work [proof of concept]
Tested new control modes on actual hardware.
Adjust new code so the modes kind of work now, as proof of concept.
Still needs major optimization and fixes though.

motorctl:
    - add config option to disable logging for particular instance
    - add some definitions to finetune control modes
    - rework current and speed mode, so they actually kind of work
    - fix TCS to not cause deadlock motors off

menu:
    - add item set motorControlMode (select DUTY, CURRENT, SPEED)
    - fix missing item maxDuty

speedsensor: fix return type
2024-02-28 23:00:38 +01:00
jonny_jr9
2abeefde07 Add Duty, Current, Speed control modes, Add traction-control [testing]
very experimental needs testing/debugging,
other control modes can currently be selected by editing the class definition in motorctl.hpp

menu/config
  - add menu item to enable/disable traction control system

main: pass ptr to other motor to motor object

speedsensor: add method to get last update time

motorctl: handle loop:
  - re-arrange some code sections
  - add several methods to get current status (needed from other motor for tcs)
  - add sketchy code for different control modes DUTY, CURRENT, SPEED (very basic implementation)
  - add experimental code for traction control
2024-02-28 10:21:53 +01:00
jonny_jr9
bc014befb7 Optimize motorctl: slow down task when target reached
Major changes in motorctl and control to optimize performance
by freeing unnecessary cpu usage by motorctl task
Needs testing on actual hardware!

motorctl:
    - slow down handle loop when duty is at target (wait for new command)
    - create separate task for each motor
    - setTarget method also accepts motorCommand directly now

control.cpp:
    - redurce stress on motorctl by removing unnecessary commands
        - set motors to idle at mode change only, instead of every iteration (IDLE, MENU, ADJUST)
        - HTTP, JOYSTICK: only update motors when stick data actually changed
    - simplify code
        - add method for idling both motors
        - use motorcommands directly in setTarget()

http:cpp:
    - dont block control task with getData() method
    - handle timeout independent of one queue event
    - prevents unresponsive system for http-timeout when changing mode from HTTP
2024-02-23 23:57:21 +01:00
jonny_jr9
268018832d Add nvs in motorctl: Store and Load accel/decel conf
Changes in menu for accel/decel time are now persistent after
restarts

main: initialize nvs and pass pointer to motorctl task
motorctl:
    - add method to get default configured value
    - add name to config -> adjust logging
    - add methods to read and write msFadeAccel and msFadeDecel from nvs
2024-02-20 16:34:42 +01:00
jonny_l480
b7288b442e Fix Motor jump at startup / always on - all modes tested
While testing the new commits on actual hardware noticed
the motors always beeing on at full power.

-> This was due to uninitialized value. It had to fade down from
duty 81236182734612738 which takes forever.

-> This also fixes the old issue where left motor jumped for a
second after startup

Also tested JOYSTICK, HTTP, ADJUST_CHAIR modes and encoder+menu
2024-02-20 09:41:34 +01:00
jonny_jr9
2fcf17feda Major Rework all files - Pass pointers to tasks, Remove gloabl variables
- All files:
  Modify almost all files to adjust functions and classes to
  work with pointers to objects passed at task creation
  instead of global variables from config.hpp

- Remove/clear config.hpp to get rid of all global variables

- main.cpp
    - Create pointer to all shared (used in multiple tasks) objects in main

- remove evaluatedSwitch button object,
  since joystick library is used to get switch events

- changes HTTP-mode
    - always init http-server (do not enable/disable at mode change)
    - pass url-handle function to init-htpp function
    - add lambda function to pass method of instance for thatMajor Rework all files - Remove global variables, pass pointers to tasks

- All files:
  Modify almost all files to adjust functions and classes to
  work with pointers to objects passed at task creation
  instead of global variables from config.hpp

- Remove/clear config.hpp to get rid of all global variables

- main.cpp
    - Create pointer to all shared (used in multiple tasks) objects in main

- remove evaluatedSwitch button object,
  since joystick library is used to get switch events

- changes HTTP-mode
    - always init http-server (do not enable/disable at mode change)
    - pass url-handle function to init-htpp function
    - add lambda function to pass method of instance for that

NOTES:  - tested on breakoutboard only
        - known issue that slow encoder events are not recognized
        (especially in menu) - slowing down motorctl helps
2024-02-18 10:00:34 +01:00
jonny_jr9
fe0e0093d0 Add functional menu items (accel/decel), Add menu-timeout
menu.cpp:
    - add item center-Joystick (functional)
    - add item accel-Limit (functional)
    - add item decel-Limit (functional)
    - fix display freeze on timeout
    - add menu timeout
    - switch to previous mode on exit instead of always idle

motorctl.cpp:
    - add getFade method, to get currently configured values
    - add log output on fade change
2024-02-14 23:56:52 +01:00
jonny_jr9
f16b96c100 Optimize Display: show current mode, git-tag...
Currently testing with breakoutboard and larger
1.3'' display (OFFSETX needed)
- display.cpp:
    - change structure (outsource in page functions)
    - add git and compile info to startup screen
    - add armchair mode and motor current to status screen
- control.hpp: Add methods to get current armchair control mode (string)
- motorctl.hpp: Add method to get motor current
2024-02-12 23:00:31 +01:00
jonny_jr9
71b63ebbd3 Make drivers interchangeable, Switch to sabertooth driver
- make motorctl compatible with different drivers
    - pass set function instead of specific motor object
    - add lambda function in config.cpp
- update config to use one new sabertooth driver instead of two single100a
- main test controlled motor
2023-09-08 12:09:52 +02:00
jonny_jr9
13b896accb Outsource currentsensor, motorctl, motordrivers to common/
since board_single uses mostly the same code as board_control and
board_motorctl several files are outsorced to common folder to prevent
dupliate code and different versions
2023-09-07 12:30:22 +02:00