SUNLU AMS Heater Auto-Vent Controller - Technical Specification

1. System Overview

The SUNLU AMS Heater Auto-Vent Controller is an intelligent automation system designed for 3D printer filament dryers. It monitors AC current consumption to detect heater and fan operation states, automatically controlling a servo-operated vent to optimize humidity removal and temperature management.

1.1 Key Features

  • Automatic Current Monitoring: Real-time AC current sensing with offset compensation
  • Intelligent State Detection: Distinguishes between heater-on, fan-only, and idle states
  • Self-Learning Calibration: Adapts to different dryer models through automated threshold learning
  • Non-Volatile Memory: Stores learned parameters in EEPROM for persistence across power cycles
  • Visual Feedback: Multi-pattern LED status indication
  • User Interface: Three-mode button control (short/long/very-long press)
  • Cooldown Management: 3-minute delay for fan-only operation after heater shutoff

2. Hardware Specifications

2.1 Microcontroller

The controller supports two compatible microcontroller options:

Option 1: Seeed XIAO SAMD21

  • Processor: ARM Cortex-M0+ @ 48MHz
  • Operating Voltage: 3.3V
  • Flash Memory: 256KB
  • SRAM: 32KB
  • I/O Voltage: 3.3V logic levels

Option 2: Seeed XIAO RP2040

  • Processor: Dual ARM Cortex-M0+ @ 133MHz
  • Operating Voltage: 3.3V
  • Flash Memory: 2MB
  • SRAM: 264KB
  • I/O Voltage: 3.3V logic levels

Both microcontrollers use the same pinout and are pin-compatible for this application.

2.2 Current Sensor

  • Model: ACS758 LCB-050B
  • Type: Hall-effect AC/DC current sensor
  • Measurement Range: ±50A
  • Sensitivity: 40mV/A @ 5V supply
  • Output Type: Analog voltage (ratiometric)
  • Bandwidth: DC to 100kHz

2.3 Analog-to-Digital Converter (ADS1115)

  • Model: ADS1115
  • Resolution: 16-bit
  • Interface: I2C (address 0x48)
  • Input Range: ±4.096V (GAIN_ONE configuration)
  • LSB Size: 0.125mV
  • Sample Rate: Configurable, default 128 SPS
  • Channels Used:
    • A0: Current sensor input
    • A1: Servo feedback input

2.4 Servo Motor

  • Type: Feedback-enabled servo
  • Control: PWM signal (standard servo protocol)
  • Position Range: 0° to 180°
  • Feedback: Analog voltage proportional to position
  • Operating Voltage: 5V (separate power supply recommended)

2.5 User Interface

  • LED: Single status indicator

    • Type: Standard LED
    • Configuration: Active low (cathode to GPIO, anode to VCC through resistor)
    • Pin: D10
  • Button: Momentary push button

    • Type: SPST normally-open
    • Configuration: Active low with internal pullup resistor
    • Pin: D3

3. Software Architecture

3.1 Operating Modes

3.1.1 Normal Operation Mode

  • Continuous current monitoring
  • State detection (heater, fan, idle)
  • Automatic vent control
  • LED status indication (solid when active)

3.1.2 Standby Mode

  • System disabled
  • LED off
  • Vent remains in current position
  • Triggered by 2-5 second button press

3.1.3 Learning Mode

  • Three-phase automatic calibration
  • LED pattern guidance for user
  • EEPROM storage of learned thresholds
  • Triggered by 5+ second button press

3.2 Current Measurement Algorithm

3.2.1 Offset Compensation

At startup, the system measures the zero-current baseline for 5 seconds:

voltageOffset = average(ADC_readings) over 5 seconds

3.2.2 RMS Calculation

AC current is measured using Welford's online algorithm for numerical stability:

For each sample over 500ms:
    voltage = ADC_reading - voltageOffset
    Update running mean and variance
RMS_voltage = sqrt(variance)
RMS_current = RMS_voltage / sensitivity

3.2.3 Rolling Average

A 30-second rolling average smooths transient variations:

samples[] = circular buffer of 60 samples (0.5s each)
average_current = mean(samples[])

3.3 State Detection

The system uses hysteresis-based thresholds to prevent chattering:

StateEntry ConditionExit Condition
Heater ONCurrent > HEATER_ON_THRESHOLDCurrent < HEATER_OFF_THRESHOLD
Fan ONCurrent > FAN_ON_THRESHOLDCurrent < FAN_OFF_THRESHOLD
IdleCurrent < FAN_OFF_THRESHOLDCurrent > FAN_ON_THRESHOLD

Default thresholds (before learning):

  • HEATER_ON_THRESHOLD: 200mA
  • HEATER_OFF_THRESHOLD: 120mA
  • FAN_ON_THRESHOLD: 25mA
  • FAN_OFF_THRESHOLD: 20mA

3.4 Vent Control Logic

IF (heater_detected OR fan_detected):
    OPEN vent

IF (heater_off AND fan_detected):
    Keep vent OPEN
    Start cooldown timer

IF (heater_off AND fan_off AND cooldown_expired):
    CLOSE vent after 3 minutes

IF (heater_off AND fan_off AND NOT in_cooldown):
    CLOSE vent immediately

3.5 Learning Mode Algorithm

Phase 1: Baseline Measurement

  1. LED: SOLID (5 second prep time)
  2. User ensures dryer is OFF
  3. LED: FAST FLASH (10 second measurement)
  4. Records: baseline_current = avg(measurements)
  5. LED: SUCCESS BLINK

Phase 2: Heater + Fan Measurement

  1. LED: BREATHING pattern (5 second prep time)
  2. User turns dryer ON (heater + fan)
  3. LED: FAST FLASH (10 second measurement)
  4. Records: heater_current = max(measurements)
  5. LED: SUCCESS BLINK

Phase 3: Fan-Only Measurement

  1. LED: DOUBLE BLINK pattern (5 second prep time)
  2. User turns heater OFF (fan continues)
  3. LED: FAST FLASH (10 second measurement)
  4. Records: fan_current = avg(measurements)
  5. LED: COMPLETE BLINK (3 long flashes)

Threshold Calculation

FAN_ON_THRESHOLD = (baseline + fan_current) / 2 + 2mA margin
FAN_OFF_THRESHOLD = FAN_ON_THRESHOLD - 5mA hysteresis

HEATER_ON_THRESHOLD = (fan_current + heater_current) / 2
HEATER_OFF_THRESHOLD = (baseline + fan_current) / 2 + 5mA margin

Thresholds are saved to EEPROM with magic number validation.

3.6 EEPROM Storage

struct ThresholdData {
    uint32_t magic;  // 0xABCD1234 for validation
    float fanOnThreshold;
    float fanOffThreshold;
    float heaterOnThreshold;
    float heaterOffThreshold;
};

SAMD21: Uses FlashStorage library for EEPROM emulation in flash memory. RP2040: Uses LittleFS or EEPROM emulation library for persistent storage in flash memory.

3.7 LED Patterns

PatternTimingMeaning
SOLIDContinuous onNormal operation / Phase 1 prep
OFFContinuous offStandby mode
FAST FLASH100ms on/offMeasuring (learning mode)
SLOW FLASH250ms on/offCalibrating servo
BREATHING2s cycle fadePhase 2 prep (turn dryer ON)
DOUBLE BLINK2 blinks, pause, repeatPhase 3 prep (turn heater OFF)
SUCCESS BLINK2 quick flashesPhase complete
COMPLETE BLINK3 long flashesLearning complete

3.8 Button Interface

Press DurationActionResult
< 2 secondsShort pressRecalibrate servo
2-5 secondsLong pressToggle standby mode
> 5 secondsVery long pressEnter learning mode

4. Timing Specifications

ParameterValueNotes
ADC Sample Period500ms~30 AC cycles @ 60Hz
Rolling Average Window30 seconds60 samples
Offset Measurement Time5 secondsAt startup
Learning Phase Duration10 secondsPer phase
Learning Prep Time5 secondsBetween phases
Fan Cooldown Delay3 minutesAfter heater turns off
Servo Settle Time1 secondAfter position change
Update Display Interval5 secondsSerial output
Button Debounce50msImplicit in timing

5. Memory Usage

SAMD21:

  • Flash: ~57KB / 256KB (22%)
  • SRAM: Estimated ~4KB / 32KB (12%)
  • EEPROM: 20 bytes (threshold storage)

RP2040:

  • Flash: ~57KB / 2MB (<3%)
  • SRAM: Estimated ~4KB / 264KB (<2%)
  • EEPROM: 20 bytes (threshold storage in flash)

6. Communication Interfaces

6.1 I2C Bus

  • Speed: 100kHz (standard mode)
  • Device: ADS1115 @ 0x48

6.2 Serial Console (Debug)

  • Baud Rate: 115200
  • Format: 8N1
  • Purpose: Debug output and manual control commands

6.3 Serial Commands (Debug Mode)

CommandAction
O or oOpen vent
C or cClose vent
R or rRecalibrate servo
F or fRead servo feedback
S or sToggle standby mode
L or lEnter learning mode
0-180Move servo to specific angle

7. Power Requirements

  • Microcontroller: 3.3V @ ~50mA (active), ~15mA (idle)
  • ADS1115: 3.3V @ ~1mA
  • Servo: 5V @ 100-500mA (load dependent)
  • Total System: 5V @ 200-600mA typical

Recommended: Use separate 5V power supply for servo, common ground with microcontroller.

8. Environmental Specifications

  • Operating Temperature: 0°C to 50°C
  • Storage Temperature: -20°C to 70°C
  • Humidity: 10% to 90% non-condensing
  • Altitude: Up to 2000m

9. Safety Features

  • Offset Compensation: Eliminates DC bias errors
  • Rolling Average: Filters transient spikes
  • Hysteresis: Prevents rapid state changes
  • Cooldown Delay: Protects dryer fan bearing
  • Watchdog: None (consider adding for production)
  • Overcurrent Protection: Relies on ACS758 internal protection

10. Calibration Procedure

10.1 Servo Calibration

Performed automatically at startup:

  1. Move to closed position (180°)
  2. Record feedback voltage
  3. Move to open position (0°)
  4. Record feedback voltage
  5. Create linear mapping between feedback and position

10.2 Current Threshold Learning

See Section 3.5 for detailed algorithm.

11. Error Handling

  • ADS1115 Not Found: System halts with error message
  • Servo Feedback Out of Range: Warning message, continues operation
  • EEPROM Read Invalid: Uses default thresholds

12. Future Enhancements

Potential improvements for future versions:

  1. Watchdog Timer: Auto-reset on system hang
  2. Temperature Sensing: Direct dryer temperature monitoring
  3. WiFi Connectivity: Remote monitoring and control
  4. Data Logging: Historical current and state data
  5. Adjustable Cooldown: User-configurable delay time
  6. Multiple Profiles: Store settings for different dryers
  7. OLED Display: On-device status display
  8. Emergency Stop: Hardware override for safety