# Appendix D: Core Algorithm Description and Key Parameters for STM32 MCU ## Target Controller - MCU Model: STM32F103C8T6 - RAM Capacity: 20 KB - Flash Capacity: 64 KB - Core Frequency: 72 MHz ## Core Algorithm Architecture 1. Input Layer - Input variables: agricultural season, time period, farmer type, horizontal irradiance - Sampling interval: 1 hour - Quantization bit width: 16-bit fixed point 2. Lightweight Fuzzy Logic Inference Engine - Membership function type: Triangular - Core fuzzy rules: 25 rules (see Appendix B) - Defuzzification method: Weighted average - Rule coverage rate: 95.3% 3. Adaptive Correction Module - Algorithm: Recursive least squares (RLS) with 7-day sliding window - Function: Dynamically adjust model weight according to real-time load change - Correction period: ≤ 24 hours - No extra RAM overhead 4. Human-Centred Control Execution Layer - Operation step limit: ≤ 3 steps - Command response time: ≤ 2 seconds - Misoperation auto-correction: Supported - Fault tolerance mechanism: Enabled ## Performance Metrics on STM32 - Single-step prediction time: 186 ms - Peak RAM usage: 27.4 KB - Average prediction MAPE: 10.8% - Average prediction R²: 0.932 ## Key System Parameters - PV array capacity: 5 kWp - Energy storage capacity: 10 kWh - System voltage: DC 48 V - Charge/discharge rate: 0.5 C - SOC operating range: 20% – 80% - Conservative SOC lower limit: 22% - Voltage deviation allowance: ±7% - Total harmonic distortion (THD): ≤5% ## Memory Optimization Methods - Floating-point quantization to 16-bit fixed point - Membership function lookup table instead of real-time calculation - Redundant input variable pruning - Static memory allocation only (no dynamic malloc) ## Safety and Human-Centred Constraints - Max operation steps per task: 3 - Max cognitive load design: K = 35 (NASA-TLX) - Auto-correction rate for misoperations: ≥ 98% - Real-time performance: Meet rural low-cost controller requirements