Overview & Engineering Scope
Commissioned for a confidential construction industry client, Winch Master SSR is a dual-ESP32 wireless auto-leveling control and power-switching system engineered to hoist and position a heavy bridge bearing using four 24 V battery-powered industrial DC winches, each rated at 4,000 lb (16,000 lb combined rated lifting capacity across all four corners).
My direct engineering scope covered designing and building the complete embedded control hardware, MOSFET-driven Solid State Relay power switching stage, 8-relay directional contactor controller, dual-ESP32 firmware, mobile-first Web UI with Wireless OTA, and a custom 3D-printed 4-column miniature home test rig used to validate every leveling algorithm under controlled tilt disturbances before the system was handed off and integrated into the client engineering team's full-scale steel lifting gantry for unloaded workshop trials and the successful on-site bridge-bearing lift.
To keep high-current 24 V motor noise isolated from directional switching and operator telemetry, the architecture splits across two wireless ESP32 nodes linked over zero-latency ESP-NOW: a Sensor & SSR Speed-Control Node running DMP quaternion fusion on an MPU-6050 IMU alongside 50 Hz PWM gating of four 60 A DC Solid State Relays (GOLD SDP6060D), and a Master Relay & Web UI Node enforcing hardware directional interlocks across an 8-channel relay bank, triple-layer safety watchdogs, and a 20 Hz Blackbox Flight Data Recorder.
Dual-ESP32 Wireless Architecture & Triple-Layer Safety
Separating direction switching from high-speed SSR duty-cycle modulation lets the system adjust individual corner speeds smoothly in real time without chattering mechanical relays under heavy DC inductive load:
Because a dropped wireless packet or frozen sensor during a multi-ton lift is unacceptable, the firmware enforces four independent fail-safe layers:
- Hardware Directional Interlock (
setMotorDirection()): Before energizing any motor's UP or DOWN relay, the Master Relay node explicitly forces the opposing relayHIGH(OFF) and inserts a10 µsdeadtime so opposing contactor coils can never short simultaneously. - IMU Freeze Watchdog (
> 400 ms): Blocks engaging Auto-Lift/Descend and immediately cuts all SSRs and relays if MPU-6050 DMP packets stop arriving, accompanied by automatic16-clock SCLI²C bus-deadlock recovery (clearI2CBus()) if motor EMI stalls the I²C lines. - ESP-NOW Inter-Node Link Watchdog (
> 1000 ms): The Master streams10 Hzheartbeats while moving (2 Hzidle); any link dropout exceeding 1 second cuts all 4 SSR gates and drops all 8 relays. - Browser Press-and-Hold Dead-Man's Switch (
> 1000 ms): Motion runs strictly while the operator holdsLIFTorDESCEND—releasing the button or losing browser Wi-Fi telemetry immediately halts the entire gantry.
void setMotorDirection(int motorIdx, int dir) {
if (motorIdx < 0 || motorIdx > 3) return;
int pinUp = RELAY_PINS[motorIdx * 2];
int pinDn = RELAY_PINS[motorIdx * 2 + 1];
if (dir == 1) {
// Interlock: Explicitly force DOWN relay OFF (HIGH) FIRST
digitalWrite(pinDn, HIGH);
delayMicroseconds(10);
// Then engage UP relay ON (LOW)
digitalWrite(pinUp, LOW);
} else if (dir == 2) {
// Interlock: Explicitly force UP relay OFF (HIGH) FIRST
digitalWrite(pinUp, HIGH);
delayMicroseconds(10);
// Then engage DOWN relay ON (LOW)
digitalWrite(pinDn, LOW);
} else {
// Turn BOTH OFF (HIGH)
digitalWrite(pinUp, HIGH);
digitalWrite(pinDn, HIGH);
}
}Hardware Electronics, Schematics & Miniature Test Rig
Tech Stack
- Embedded Compute & Comms: Dual ESP32 (
NodeMCU-32S/ESP32 Dev) nodes communicating via packed binary ESP-NOW frames (Channel 1), SoftAP WebServer (Winch_Control_System/Winch_Sensor_System), NVSPreferencespersistence, and browser-based Wireless Web OTA (/update) so field engineers can flash updates from a smartphone with zero USB cables. - High-Current Power Switching: Four industrial
GOLD SDP6060DDC Solid State Relays (12–600 VDC,60 A) driven through four low-sideSTP40NF10LN-channel MOSFETs at50 Hz(LEDC8-bit PWM on GPIOs4, 19, 17, 18), paired with an 8-channel opto-isolated low-level-trigger relay module (GPIOs 4, 16, 17, 18, 19, 21, 22, 23) and 8 manual override switch inputs. - Power Regulation & Sensing: Dual
LM2596step-down buck converters regulating clean5 Vlogic rails from12 Vcontrol power (with reverse-polarity diode protection), plus an MPU-6050 6-axis IMU running on-chip DMP quaternion fusion filtered through a SimpleKalman filter (Q = 0.001,R = 0.25) with automatic 100-packet startup zero/tare lock. - CAD & Scale Test Rig (
Autodesk Inventor): Full 3D-printed 4-tower miniature winch rig (WinchProjectSSR.iamwithJGB37-520geared test motors, custom V3 pulleys, white 3D-printed SSR brackets, and protective circuit enclosures) built to torture-test every leveling mode at home prior to full-scale steel gantry integration. - Diagnostics & Telemetry Tooling: Embedded
400-sample (20 sat20 Hz) Blackbox Flight Data Recorder (/api/blackboxJSON) paired with a Python analysis dashboard (dashboard.py) and 1-click OTA binary packaging scripts.
Multi-Mode Auto-Leveling Algorithms & Motor Physics
Four industrial winches lifting an asymmetric load behave completely differently during ascent (fighting static friction and gravity) versus descent (where gravity assists runaway on heavier corners). To handle both regimes cleanly, src/main.cpp implements four operator-selectable control modes (Full PID, Full Cyclic Round-Robin, Hybrid: PID Ascend + Cyclic Descend, and Inverse Hybrid) backed by calibrated nonlinear motor curves and stiction breakaway pulses:
- Nonlinear Industrial Motor Duty Mapping (
mapSpeedToDutyPct()): Compensates for low-duty DC winch deadband and torque saturation using selectable power curves—defaulting to the Industrial Profile on the full-scale winches (20%floor to90%ceiling with a0.75low-end sensitivity exponent) paired with an independent250 ms100% PWM Jump-Start Boost whenever a stopped winch starts under load:
float mapSpeedToDutyPct(int speedPct) {
speedPct = constrain(speedPct, 0, 100);
if (speedPct == 0) return 0.0f;
if (activeMotorProfile == 0) {
// Hobby Motor Profile (Min 35% PWM offset, scaling smoothly to 75% max)
float normalized = speedPct / 100.0f;
return 35.0f + (40.0f * pow(normalized, 1.4f));
} else if (activeMotorProfile == 1) {
// Industrial Motor Profile (Min 20%, Max 90%, 0.75 exponent for low-end sensitivity)
float normalized = speedPct / 100.0f;
return 20.0f + (70.0f * pow(normalized, 0.75f));
} else {
// Direct Linear 1:1 Profile
return (float)speedPct;
}
}- Minimum-Bounded 4-Corner PID Mixing & Dynamic Drop-Factor: Computes pitch and roll PID efforts (
kp = 30.0,ki = 2.5,kd = 1.5, anti-windup±100) and projects them onto the four corners—automatically inverting signs and stacking a configurable Descent Gain Multiplier (175%) plus Descent Speed Factor (50%) during lowering:
Whenever persistent tilt remains >= 2.0° with saturated spread (>= 40) for more than 1000 ms, the controller fires a 100 ms SSR-only catch-up pulse—gating leading SSRs to 0% and driving the lagging corner at 100% without cycling mechanical relays.
// Configurable base auto speed using active Motor Profile mapping (scaled by descent speed factor on descent)
int effBaseSpd = isLifting ? autoBaseSpeedPct : (int)round((float)autoBaseSpeedPct * ((float)globalDescentSpeedFactor / 100.0f));
effBaseSpd = constrain(effBaseSpd, 0, 100);
float mappedBasePct = mapSpeedToDutyPct(effBaseSpd);
float base_pwm = (mappedBasePct * 255.0f) / 100.0f;
// Minimum-Bounded Kinematic Matrix (Original Proven 99b60cd Formula)
float p4 = 0;
float p3 = -u_pitch;
float p2 = u_roll;
float p1 = u_roll - u_pitch;
// Invert PID response if Declining (Lowering) and apply descent-specific gain multiplier
if (!isLifting) {
const float descentGainMult = (float)globalDescentMultPct / 100.0f;
p1 = -p1 * descentGainMult;
p2 = -p2 * descentGainMult;
p3 = -p3 * descentGainMult;
p4 = -p4 * descentGainMult;
}Embedded WINCH MASTER Web UI, 3D Gyro & Wireless OTA
Hosted directly from flash on the Master Relay ESP32 (src/web_ui.h), the responsive mobile-first dashboard gives operators complete control from any phone or tablet without installing a native app:
- Main Tab: Real-time Pitch & Roll readouts, press-and-hold
LIFT/DESCENDcontrols,Target SpeedandDescent Speed Factorsliders, instantZERO / TARE,EMERGENCY STOP, and live per-winchW1–W4SSR PWM readouts. - Jog & 3D Gyro Tabs: Individual corner jog buttons for rigging slack adjustment alongside a live 3D platform orientation visualizer synchronized to physical MPU-6050 mounting axes.
- Dev / Diag & Wireless OTA: Full live tuning of auto-leveling mode (
Full PID,Full Cyclic,Hybrid), corner target angle (0.50°), correction aggressiveness, descent multiplier, adjacent winch cross-bleed, independent manual relay testers (M1–M4 UP/DOWN), NVS persistence, and direct browser/updateOTA firmware uploads for both ESP32 boards.
Testing Progression: Scale Testbed to Construction Site Lift
1. Miniature 4-Tower Home Test Rig
Before putting embedded electronics anywhere near four 4,000 lb industrial winches, I built a custom 3D-printed 4-column scale test rig at home to validate MPU-6050 Kalman filtering, ESP-NOW safety watchdogs, 20 Hz Blackbox telemetry logging (dashboard.py), and edge-case leveling behavior under induced imbalance and rapid mobile commands.
2. Full-Scale Carriage Integration & Unloaded Workshop Test
With the control loop verified at bench scale, the custom 3D-printed Master Relay and Sensor enclosures were handed over and mounted directly onto the engineering team’s welded steel lifting carriage—interfacing with dual 12 V series-wired batteries (24 V), four 4,000 lb DC winches, and 200 A DC Solid State Relays (GOLD SDM100200D) for unloaded workshop verification.
3. On-Site Construction Bridge-Bearing Lift
Following successful workshop checkout, the complete system was deployed on-site at night to hoist the heavy bridge bearing into its final seat—with the black 3D-printed Sensor & IMU node centered directly atop the bearing plate feeding continuous tilt corrections to all four corners throughout the lift.
Challenges & Lessons Learned
EMI & I²C Resilience Around High-Current DC Winches
Switching inductive 24 V winch loads at high currents generates significant electromagnetic noise capable of locking up I²C sensor buses mid-run. Hardening the sensor node with automatic 16-clock SCL bus recovery (clearI2CBus()), dual-frequency probing (400 kHz with 50 kHz fallback), and a > 400 ms IMU freeze watchdog ensured any transient bus glitch recovered seamlessly or failed safe instead of flying blind.
Asymmetric Ascent vs. Gravity-Assisted Descent
Tunable math built for lifting against gravity breaks down when gravity pulls a multi-ton load downward faster than lightly loaded corners. Pairing stiction-overcoming 250 ms 100% jump-start pulses and the nonlinear Industrial Power Curve with an independent Descent Speed Factor, Descent Gain Multiplier (175%), 100 ms SSR-only saturation catch-up pulses, and Hybrid PID / Cyclic switching solved asymmetrical lowering cleanly on the miniature rig before field deployment.
Zero-Cable Field Serviceability
Because field operators on a construction deck shouldn't need laptops or USB cables, bundling the responsive SoftAP WINCH MASTER Web UI, NVS parameter persistence, 20 Hz JSON Blackbox recorder, and phone-accessible /update Wireless OTA directly inside the ESP32 flash allowed the engineering team to tune, monitor, diagnose, and update the deployed system wirelessly straight from a smartphone—turning a compact embedded prototype into field-ready industrial control electronics.
