6 Commits

Author SHA1 Message Date
jonny_l480
0b113eafb5 Add functions to modify/toggle fading (button x8)
- add 3 functions to controlledMotor class in motorctl.cpp/hpp
  - setFade: set specific msFade duration for acceleration or
    deceleration
  - setFade: disable or set to default ramp for acceleration or
    deceleration
  - toggleFade: toggle between fading enabled or disables for
    acceleration or deceleration

- button.cpp
  - add controlledMotor objects to constructor
  - add new command 8x press which now toggles fade-deceleration of both
    motors

- config.cpp
  - slightly decrease fading durations
2022-07-23 15:13:09 +02:00
jonny_ji7
0a2695f45f Fix fading: correctly use different accel, decel ramps
- Change fading algorithm to handle Acceleration and Deceleration for
  forward and reverse separately (4 different cases)

- rename variables to make fading direction more obvious
  e.g. msFadeUp -> msFadeAccel  or  dutyIncrementDon -> dutyIncrementDecel

TODO: fading needs optimization
2022-07-18 17:32:31 +02:00
jonny_l480
436c528eaf Add fade-down functionality to motorctl (bug)
With this changes the motors are faded down (same as already existing fading up)
when the target duty suddenly decreases.
It can be configured or disabled with setting msFadeDown to 0  in config struct of
motorctl object.

- Add new config parameter msFadeDown
- Change msFade to msFadeDown

- Add fade down functionality to motorctl instead of just setting the
  duty to lower value

!!!TODO: fix major  BUG when motor direction changes suddenly (before fade got to
0) the motor immediately starts in other direction with previous duty
   (no/less fading up happening)
2022-07-16 12:46:56 +02:00
jonny_ji7
ad2dbb0ce0 Create class controlledFan, Add getStatus to motorctl
- Add class for controlling fans for cooling the motor drivers
- Add configuration for left and right fan to config.cpp
- Create fan task in main.cpp
- Add getStatus function to controlledMotor class
2022-06-11 16:47:13 +02:00
jonny_ji7
f7ce61c666 Add function 'joystick_generateCommandsDriving'
- add new function to joystick.hpp/cpp
  - reads data from joystick and generates commands for driving in
    "joystick" mode
  - returns struct with commands for both motors

- main.cpp
  - add code for testing the new function
  - enable 5v regulator (needed for pullups AB left motor)
  - add newly created motorRight to handle function

- add new struct with two motorcommands to motorctl.hpp
2022-06-09 21:42:01 +02:00
jonny_ji7
84bfe211ac Create class 'controlledMotor', Create config
- Create class 'controlledMotor':
  - handles 'fading / ramp' of the pwm duty
  - handles current limit **not implemented yet**
  - has .handle function that is intended to be run very fast in another task
    commands are sent via queue

- Create config.hpp
  - Globally available instance motorLeft of controlledMotor class
- Create config.cpp
  - Configuration of motordriver and control parameters for motorLeft

- Add config.cpp and motorctl.cpp to cmakelists

- main.cpp:
  - create 'task_motorctl' which repeatedly runs motorLeft.handle()
  - modify testing code for testing the new class
  - comments

The fading/ramp capability of the new class was tested successfully
using a breakoutboard with an led.
2022-06-05 16:36:57 +02:00