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
This commit is contained in:
jonny_l480
2024-02-26 22:57:22 +01:00
parent 5b198824f2
commit bf481ae8ea
10 changed files with 50 additions and 30 deletions

View File

@@ -205,7 +205,7 @@ void buttonCommands::startHandleLoop()
{
//-- run action with count of presses --
ESP_LOGI(TAG, "timeout: count=%d, lastPressLong=%d -> running action", count, isPressed);
buzzer->beep(count, 50, 50);
buzzer->beep(count, 50, 50, 200); //beep count, with 200ms gap before next queued beeps can start
action(count, isPressed); // run action - if currently still on the last press is considered long
count = 0; // reset count
}

View File

@@ -41,7 +41,7 @@ void setLoglevels(void)
// esp_log_level_set("automatedArmchair", ESP_LOG_DEBUG);
esp_log_level_set("display", ESP_LOG_INFO);
// esp_log_level_set("current-sensors", ESP_LOG_INFO);
// esp_log_level_set("speedSensor", ESP_LOG_INFO);
esp_log_level_set("speedSensor", ESP_LOG_WARN);
esp_log_level_set("chair-adjustment", ESP_LOG_INFO);
esp_log_level_set("menu", ESP_LOG_INFO);
esp_log_level_set("encoder", ESP_LOG_INFO);
@@ -84,7 +84,7 @@ single100a_config_t configDriverRight = {
//--- configure sabertooth driver --- (controls both motors in one instance)
sabertooth2x60_config_t sabertoothConfig = {
.gpio_TX = GPIO_NUM_25,
.gpio_TX = GPIO_NUM_27,
.uart_num = UART_NUM_2};
// TODO add motor name string -> then use as log tag?
@@ -97,6 +97,7 @@ motorctl_config_t configMotorControlLeft = {
.currentSensor_adc = ADC1_CHANNEL_4, // GPIO32
.currentSensor_ratedCurrent = 50,
.currentMax = 30,
.currentInverted = true,
.deadTimeMs = 0 // minimum time motor is off between direction change
};
@@ -109,6 +110,7 @@ motorctl_config_t configMotorControlRight = {
.currentSensor_adc = ADC1_CHANNEL_5, // GPIO33
.currentSensor_ratedCurrent = 50,
.currentMax = 30,
.currentInverted = false,
.deadTimeMs = 0 // minimum time motor is off between direction change
};
@@ -154,7 +156,7 @@ joystick_config_t configJoystick = {
.y_min = 1700, //=> y=-1
.y_max = 2940, //=> y=1
// invert adc measurement
.x_inverted = true,
.x_inverted = false,
.y_inverted = true};
//----------------------------
@@ -175,20 +177,23 @@ fan_config_t configFans = {
//--------------------------------------------
speedSensor_config_t speedLeft_config{
.gpioPin = GPIO_NUM_5,
.degreePerGroup = 360 / 5,
.minPulseDurationUs = 10000, //smallest possible pulse duration (< time from start small-pulse to start long-pulse at full speed). Set to 0 to disable this noise detection
.degreePerGroup = 360 / 16,
.minPulseDurationUs = 3000, //smallest possible pulse duration (< time from start small-pulse to start long-pulse at full speed). Set to 0 to disable this noise detection
//measured wihth scope while tires in the air:
// 5-groups: 12ms
// 16-groups: 3.7ms
.tireCircumferenceMeter = 0.81,
.directionInverted = false,
.logName = "speedLeft",
.directionInverted = true,
.logName = "speedLeft"
};
speedSensor_config_t speedRight_config{
.gpioPin = GPIO_NUM_14,
.degreePerGroup = 360 / 12,
.minPulseDurationUs = 10000, //smallest possible pulse duration (< time from start small-pulse to start long-pulse at full speed). Set to 0 to disable this noise detection
.minPulseDurationUs = 4000, //smallest possible pulse duration (< time from start small-pulse to start long-pulse at full speed). Set to 0 to disable this noise detection
.tireCircumferenceMeter = 0.81,
.directionInverted = true,
.logName = "speedRight",
.directionInverted = false,
.logName = "speedRight"
};
@@ -216,7 +221,7 @@ display_config_t display_config {
rotary_encoder_t encoder_config = {
.pin_a = GPIO_NUM_25,
.pin_b = GPIO_NUM_26,
.pin_btn = GPIO_NUM_27,
.pin_btn = GPIO_NUM_21,
.code = 1,
.store = 0, //encoder count
.index = 0,

View File

@@ -447,7 +447,7 @@ void controlledArmchair::changeMode(controlMode_t modeNew) {
case controlMode_t::IDLE:
ESP_LOGW(TAG, "switching to IDLE mode: turning both motors off, beep");
idleBothMotors();
buzzer->beep(1, 1000, 0);
buzzer->beep(1, 900, 0);
#ifdef JOYSTICK_LOG_IN_IDLE
esp_log_level_set("evaluatedJoystick", ESP_LOG_DEBUG);
#endif
@@ -456,7 +456,7 @@ void controlledArmchair::changeMode(controlMode_t modeNew) {
case controlMode_t::ADJUST_CHAIR:
ESP_LOGW(TAG, "switching to ADJUST_CHAIR mode: turning both motors off, beep");
idleBothMotors();
buzzer->beep(4, 200, 100);
buzzer->beep(3, 100, 50);
break;
case controlMode_t::MENU:

View File

@@ -164,8 +164,8 @@ void createObjects()
// create objects for controlling the chair position
// gpio_up, gpio_down, name
legRest = new cControlledRest(GPIO_NUM_4, GPIO_NUM_16, "legRest");
backRest = new cControlledRest(GPIO_NUM_2, GPIO_NUM_15, "backRest");
legRest = new cControlledRest(GPIO_NUM_2, GPIO_NUM_15, "legRest");
backRest = new cControlledRest(GPIO_NUM_16, GPIO_NUM_4, "backRest");
// create control object (control.hpp)
// with configuration from config.cpp