Files
walker_control/include/config.h
devdesk 25dc34c6e3 Replace stall/homing flow with signed slider drive control
This streamlines manual dual-motor operation by using spring-centered signed sliders and synchronized drive modes while keeping live current monitoring in the UI and API.
2026-02-20 14:30:46 +02:00

76 lines
2.8 KiB
C

#ifndef CONFIG_H
#define CONFIG_H
// WiFi Configuration
#define WIFI_SSID "tami"
#define WIFI_PASSWORD ""
// Static IP Configuration
#define STATIC_IP IPAddress(10, 81, 2, 185)
#define GATEWAY IPAddress(10, 81, 2, 1)
#define SUBNET IPAddress(255, 255, 255, 0)
#define DNS IPAddress(10, 81, 2, 1)
// Shared Enable Pins (both drivers share these)
#define R_EN_PIN 27 // Right Enable (shared)
#define L_EN_PIN 14 // Left Enable (shared)
// Motor 1 BTS7960 Pin Definitions
#define RPWM1_PIN 25 // Right PWM Motor 1 (Forward)
#define LPWM1_PIN 26 // Left PWM Motor 1 (Reverse)
#define R_IS1_PIN 34 // Right Current Sense Motor 1 (ADC input only)
#define L_IS1_PIN 35 // Left Current Sense Motor 1 (ADC input only)
// Motor 2 BTS7960 Pin Definitions
#define RPWM2_PIN 32 // Right PWM Motor 2 (Forward)
#define LPWM2_PIN 33 // Left PWM Motor 2 (Reverse)
#define R_IS2_PIN 36 // Right Current Sense Motor 2 (ADC input only - VP)
#define L_IS2_PIN 39 // Left Current Sense Motor 2 (ADC input only - VN)
// PWM Configuration
#define PWM_FREQ 20000 // 20kHz - reduces motor noise
#define PWM_RESOLUTION 8 // 8-bit resolution (0-255)
#define PWM_CHANNEL_R1 0 // LEDC channel for Motor 1 RPWM
#define PWM_CHANNEL_L1 1 // LEDC channel for Motor 1 LPWM
#define PWM_CHANNEL_R2 2 // LEDC channel for Motor 2 RPWM
#define PWM_CHANNEL_L2 3 // LEDC channel for Motor 2 LPWM
#define MIN_PWM_PERCENT 20 // Minimum PWM when motor is running (%)
// Motor pin configuration structure
struct MotorPins {
uint8_t rpwm; // Right PWM pin (forward)
uint8_t lpwm; // Left PWM pin (reverse)
uint8_t r_is; // Right current sense pin
uint8_t l_is; // Left current sense pin
uint8_t pwm_channel_r; // LEDC PWM channel for right
uint8_t pwm_channel_l; // LEDC PWM channel for left
};
// Motor 1 pin configuration
const MotorPins MOTOR1_PINS = {
RPWM1_PIN, LPWM1_PIN, R_IS1_PIN, L_IS1_PIN, PWM_CHANNEL_R1, PWM_CHANNEL_L1
};
// Motor 2 pin configuration
const MotorPins MOTOR2_PINS = {
RPWM2_PIN, LPWM2_PIN, R_IS2_PIN, L_IS2_PIN, PWM_CHANNEL_R2, PWM_CHANNEL_L2
};
// Current Sense Configuration
// BTS7960 current sense ratio: 8500:1 (kilo-amps)
// With 1kΩ resistor on IS pin: V = I_motor / 8500
// ESP32 ADC: 12-bit (0-4095), 0-3.3V
#define CURRENT_SENSE_RATIO 8500.0f // Amps to sense current ratio
#define SENSE_RESISTOR 1000.0f // 1kΩ sense resistor (ohms)
#define ADC_MAX 4095.0f // 12-bit ADC max value
#define ADC_VREF 3.3f // ADC reference voltage
#define CURRENT_CALIBRATION 1.0f // Calibration factor (measured current / reported current)
// Current logging interval for data collection
#define CURRENT_LOG_INTERVAL_MS 100 // Log current readings every 100ms
// Web Server
#define HTTP_PORT 80
#endif