23 Commits

Author SHA1 Message Date
jonny_l480
a6a630af44 Add boost outer tire, Add ratio-threshold, Fix motorctl timeout
Rework joystick command generation
Fix timeout no commands received in motorctl

Successfully tested this state on actual hardware:
turning behavior is significantly improved - does not get slower when turning anymore

joystick:
    - add boost of inner tire when turning
    - add threshold where ratio snaps to 1
    - optimize structure, logging

control:
    - rename maxDuty to maxDutyStraight to be more clear
    - add methods to change and get new variable RelativeBoostPer for menu item

menu:
    - add new item to set maxRelativeBoost config parameter

motorctl:
    - fix timeout not working:
    previously when not receiving commands for 15s the duty was set to 0 for 1 handle cycle only
2024-03-05 23:59:12 +01:00
jonny_l480
179c608638 Merge branch 'dev' into driving-behavior 2024-03-04 13:24:46 +01:00
jonny
3514dd6bf2 Add Brightness reduction at inactive, Optimize timeout
display.cpp:
    - add timeout where display brightness gets reduced
    - rework display-task loop to handle timeouts
    - run commands when changing from/to status-page (toggle scrolling)
    - add BRIGHTNESS_TEST option

config: Add display timeouts to config.cpp

control:
    - dont reset timeout at mode change (happens not always at user input)
    - remove deprecated config option
2024-03-02 13:06:55 +01:00
jonny
bc9504d4ab Add Timeout / Notification on "forgot to turn off"
control:
    - reset timeout on user input only
        -> drop reset on changed motor duty
    - add timeoutNotifyPowerStillOnMs
        -> when forgotten to turn off the power the buzzer
           beeps a few times every 30 minutes
    - Add/fix JOYSTICK_LOG_IN_IDLE option

remove empty config.hpp
2024-03-01 13:55:51 +01: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_l480
50ee4244d3 Fix bat voltage: lookup table, currentSensors: Add snap to zero
display.cpp:
    Optimize battery voltage measurement
    While calibrating noticed it is very non-linear
    - outsource function to scale using lookup table
    - add lookup table to batvoltage measurement
      inserted many values to lookup table while testing

currentsensors:
    Fix current value jumping around between 0 and 0.2 on display
    while standstill
    - add parameter snapToZeroThreshold
2024-02-27 12:24:38 +01:00
jonny_l480
bf481ae8ea Adjust GPIO-pins and conf, Invert currentsensor, Buzzer
motorctl, currentsensor:
    - add config option for inverted current sensor
    - adjust loglevels

config:
    - Adjust gpio pins to actual wiring (not breakout board for testing)
    - Add min pulse durations for speedsensors (measurements with scope)
    - Adjust config to currently mounted encoders

control, buzzer:
    - adjust beeping
    - Add feature for optinal delay to buzzer class:
      have some pause after beeps instead of immediately
      continuing with next queued sequence
2024-02-26 22:57:22 +01:00
jonny_jr9
db4e6b56a5 Rework direction-detection, ignore bad pulses, optimize
- trigger on rising edge only
- ignore too short pulses - possible noise (config option)
- ignore invalid pulse orders
- debug log count of ignored sequences
2024-02-26 11:12:35 +01:00
jonny_jr9
ccef663c33 Fix chairAdjust, Add different status screens (Speed)
- config, chairAdjust:
    - disable reset-pin of display (not connected, random pin was assigned)
      same pin was used for chair adjust resulting in on state after startup
    - fix chairAdjust not stopping in OFF state

- display
    - add functionality to show different status screens (content when not in MENU)
    - add status screen 'Speed' (to show speed and debug speedsensors)

- menu
    - fix item joystick define center not working
    - add item to select status screen
2024-02-24 12:25:45 +01:00
jonny_jr9
cef2a841c8 Add menu item Set Max Duty
Add nvs to control.cpp
2024-02-22 23:59:13 +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_jr9
021a3660e1 Outsource display, encoder cfg to config.cpp, Optimize speedsensor
- outsource configuration of display and encoder from source/header file
  to config.cpp and pass it to init function or task from main()

- optimize logging in several init functions

- speedsensor:
    - fix startup error: initialize ISR only once
    - create instances at initialization instead of first method call

- ssd1306 display library:
    - modify library to pass offsetX to init function instead of using macro
2024-02-20 12:24:41 +01:00
jonny_jr9
26761f4a80 Oursource task_fans and task_buzzer
- outsource task_fans and task_buzzer from main.cpp to their source files
- use task parameters to pass necessary configs and objects
- adjust task priorities (display was too low)
2024-02-19 13:54:22 +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
a1bb808b62 Rework/simplify chairAdjust - now using a class
- complete rework of chairAdjust.cpp/.hpp
  created a class cControlledRest which is more readable
  and saves a lot of duplicate code

- joystick.cpp: move chair control via joystick to
  chairAdjust.cpp (prevents dependency loop)
- button.cpp: fix bug instant idle when changing to ADJUST_CHAIR

Note: briefly tested this state on a breakout board:
Mode change and call of new class methods works.
2024-02-11 23:22:33 +01:00
jonny_l480
bf3adea17d Config: Update accel and decel to tested values 2023-09-15 18:09:45 +02:00
jonny_l480
69a421a924 Outsource speedsensor, Display: show speed
- move speedsensor files from motorctl pcb to common
- single pcb create and configure global speedsensor objects
- display: create fast slow veryslow loop
  - clear display every 30s
  - show speed in rpm and km/h
  NOTE: speedsensor needs fix, direction unreliable
2023-09-12 16:00:20 +02:00
jonny_l480
548b5b8d51 Hotfix: swap joystick X/Y pins, log 5V regulator start
jsut re-wired the pcb.
apparently joystick was wired wrong previously
2023-09-11 21:24:38 +02:00
jonny_l480
3449bb7f34 Config optimizations (Test-drive)
Successfull test drive with new driver
- set max duty from 90 to 100
- config adjust fading, calibrate joystick, disable deadtime
- disable 1x button cmd
- 8x sport mode: toggle accel not decel
2023-09-09 16:10:18 +02:00
jonny_jr9
27a94d7ab6 Update connection-plan: single-pcb, update pin assignment
update config to work with actual pin assignment in connection plan
2023-09-09 09:38:54 +02: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
ee5bad53ee Revert to V2.0 single board (additional folder)
New controller will be run with single controller at first...
get single board version from V2.0 and create new folder
(two boards version is kept)
-> copied firmware from e6e586e5855d81ee726bb9a0fbe8ab12def5eeef
2023-09-07 12:17:33 +02:00