Sim-EMS
This webpage contains the documentation of Energy Management System Analysis, Reference and Development Guide.
Implementation Architecture
Implementation Analysis
- Minimum Viable Product Roadmap
- EMS Dashboard Feature List
- Folder Structure
- Dashboard Component Analysis
- Sim-EMS Web Application Architecture`
EMS Explanation
- EMS Explanation
- Self Consumption Explanation
- State Machine Modes Explanation
- State Machine Definition
What is an EMS and Why It Matters
The Big Picture: Energy Management in Modern World
Imagine your home has: - Solar panels on the roof - A big battery in the garage - The normal power grid connection - All your household appliances
Without EMS: These components don't talk to each other. Solar might produce energy that goes to the grid when your battery is empty. Your battery might charge from the grid when solar is available. It's chaos.
With EMS: A smart brain coordinates everything to: 1. Use solar energy first for your home 2. Store excess solar in the battery 3. Only use grid power when needed 4. Sell energy back to grid when profitable
Real-World Analogy: Air Traffic Control
Think of EMS as Air Traffic Control for Energy:
| Airport System | Energy System | What Could Go Wrong |
|---|---|---|
| Planes (energy sources) | Solar, Grid, Battery | Mid-air collisions (overload) |
| Runways (wires/cables) | Electrical circuits | Runway overload (overcurrent) |
| Fuel levels | Battery charge | Plane crashes (battery damage) |
| Weather conditions | Grid stability | Dangerous landings (grid faults) |
| Air Traffic Control | EMS | Prevents disasters |
Without ATC: Planes crash, runways overload, chaos ensues. Without EMS: Batteries explode, inverters burn out, grid destabilizes.
Core Problem EMS Solves
1. The Duck Curve Problem
California's electricity demand on a sunny day:
β²
β Without EMS:
β Solar overproduces midday
β β
Demand β β
β β
ββββββββΌββββββββΊ Grid overloads!
β β Then needs fossil
β β fuels when sun sets
β βΌ
ββββββββββββββββΊ Time
Morning Evening
WITH EMS:
Batteries store excess solar midday
Release energy during evening peak
Smooth the "duck curve"
2. Battery Protection
Batteries are expensive and dangerous if mishandled: - Overcharge β Fire/explosion risk - Over-discharge β Permanent damage ($10,000+ loss) - Wrong temperature β Reduced lifespan - Imbalanced cells β Early failure
EMS is the battery's bodyguard - constantly monitoring and protecting.
How EMS Works: The Complete Flow
Step 1: Data Collection (The "Eyes")
EMS constantly monitors:
β’ Battery: "I'm at 65% charge, getting warm"
β’ Solar: "I'm producing 5kW right now"
β’ Grid: "Electricity costs $0.30/kWh currently"
β’ House: "We're using 3kW of power"
Think: Like checking your car's dashboard
- Fuel gauge (battery SOC)
- Speedometer (power flow)
- Temperature gauge (battery temp)
- GPS (energy prices)
Step 2: Decision Making (The "Brain")
Based on rules and goals:
IF solar > house_load AND battery < 80%
THEN charge battery with excess solar
IF grid_price > $0.25 AND battery > 50%
THEN discharge battery to avoid buying expensive power
IF battery_temp > 40Β°C
THEN reduce charge rate by 50%
Think: Like a smart thermostat
- Learns your patterns
- Adjusts based on conditions
- Saves money automatically
Step 3: Control Execution (The "Hands")
Sends commands to devices:
β’ To inverter: "Output 2kW from battery"
β’ To solar: "Limit production to 4kW"
β’ To grid relay: "Disconnect from grid"
Think: Like driving a car
- Accelerator (increase power)
- Brake (decrease power)
- Steering (choose energy source)
Why Each Component in Our Architecture Matters
1. State Machine - The "Consciousness"
Imagine driving a car:
β’ PARK: Engine off, can't move
β’ DRIVE: Can accelerate, must follow rules
β’ REVERSE: Can go backward, slowly
β’ NEUTRAL: Engine on, but no power to wheels
EMS States:
β’ BOOT: Starting up, checking systems
β’ IDLE: Ready but not controlling
β’ RUNNING: Actively managing energy
β’ ERROR: Something's wrong, stop everything
β’ MAINTENANCE: Safe for technician to work
WHY IT MATTERS: Prevents sending "drive" commands when in "park"
2. Data Store - The "Memory"
Imagine a doctor's patient chart:
β’ Heart rate history
β’ Medication records
β’ Test results over time
β’ Current vitals
EMS Data Store:
β’ Battery voltage history
β’ Energy prices today
β’ Solar production patterns
β’ Current power flows
WHY IT MATTERS: Makes decisions based on history, not just instant readings
3. Safety Systems - The "Reflexes"
Human reflexes:
β’ Touch hot stove β Pull hand back (0.1 seconds)
β’ Bright light β Close eyes instantly
β’ Lose balance β Arms flail to regain stability
EMS Safety:
β’ Voltage too high β Stop charging immediately
β’ Temperature rising β Reduce power automatically
β’ Grid fault β Disconnect in milliseconds
WHY IT MATTERS: Prevents damage before humans can react
4. Control Modes - The "Personalities"
Different driving modes:
β’ ECONOMY: Maximize fuel efficiency
β’ SPORT: Maximize performance
β’ CRUISE: Maintain set speed
β’ MANUAL: Full driver control
EMS Control Modes:
β’ SELF-CONSUMPTION: Use your own solar first
β’ PEAK SHAVING: Avoid grid usage during peak hours
β’ CHARGE-ONLY: Fill battery from grid
β’ BACKUP: Prepare for grid outage
WHY IT MATTERS: Different goals for different situations
Real Example: A Day with EMS
Morning (6:00 AM)
Situation: Family wakes up, grid price = $0.15/kWh
EMS Action:
β’ Battery at 30% (low)
β’ Solar not producing yet (dark)
β’ House needs 2kW for breakfast/morning routine
Decision: Use grid power (cheap), save battery for later
Midday (12:00 PM)
Situation: Sunny, grid price = $0.40/kWh (peak!)
EMS Action:
β’ Solar producing 8kW
β’ House using 3kW
β’ Battery at 40%
Decision:
1. Solar β House (3kW) β
2. Excess solar β Battery (5kW) β
3. Battery charges to 80%
4. ZERO grid usage (saving money!)
Evening Peak (6:00 PM)
Situation: Sun setting, grid price = $0.45/kWh (very expensive!)
EMS Action:
β’ Solar producing 1kW (low)
β’ House needs 5kW (dinner, TV, etc.)
β’ Battery at 80%
Decision:
1. Solar β House (1kW)
2. Battery β House (4kW)
3. ZERO expensive grid power!
Night (10:00 PM)
Situation: Grid price = $0.10/kWh (cheap!)
EMS Action:
β’ Battery at 40% (used during peak)
β’ House needs 1kW (fridge, etc.)
Decision:
1. Grid β Battery (charge at 3kW)
2. Grid β House (1kW)
3. Battery fills overnight with cheap power
Result: Saved $15 today, extended battery life, helped stabilize grid.
The Disaster Without EMS
Scenario: Heat Wave + High Demand
Day: 95Β°F, everyone running AC
Time: 2:00 PM
WITHOUT EMS:
β’ Solar panels overheating (reduced output)
β’ Battery charging at full speed (gets too hot)
β’ Grid struggling with demand
β’ House AC cycling on/off (brownouts)
β’ Battery overheats β Permanent damage β $10,000 loss
WITH EMS:
β’ Detects high temperature
β’ Reduces battery charge rate by 50%
β’ Limits solar production to prevent overheating
β’ Sheds non-critical loads (pool pump, water heater)
β’ Battery stays cool, lasts years longer
β’ Grid gets relief from controlled demand
EMS as a "Money Printer"
Revenue Streams Enabled:
1. **Bill Savings**: Avoid buying expensive grid power
Example: Buy at $0.10, avoid buying at $0.45 = $0.35/kWh savings
2. **Grid Services**: Get paid to help stabilize grid
Example: California pays $100/kW-year for frequency regulation
3. **Solar Maximization**: Use more of your own solar
Example: Without battery, excess solar goes to grid at low price
With EMS, stores excess for later use
4. **Demand Charge Reduction**: Commercial buildings
Example: Reduce peak demand from 500kW to 300kW
Saves $10,000/month in demand charges
Architecture Components = Team Members
Think of EMS architecture as a sports team:
| Position | EMS Component | Role | If Missing |
|---|---|---|---|
| Coach | State Machine | Sets strategy, makes substitutions | Team runs in circles |
| Playbook | Data Store | Knows all plays, opponent history | Forgets what works |
| Defense | Safety Systems | Prevents opponents from scoring | Gets scored on easily |
| Quarterback | Control Logic | Calls plays based on situation | Random plays, no strategy |
| Wide Receivers | Device Interfaces | Catch commands, execute plays | QB throws to nobody |
| Scoreboard | Dashboard | Shows game status, stats | Don't know if winning |
| Team Doctor | Health Monitor | Checks player injuries | Play injured players |
| Stadium Announcer | Logging System | Announces plays, updates | Silent game |
Why Our Specific Architecture Matters
The "Edge-Cloud" Split
WHY SEPARATE?
Edge (Local Controller):
β’ Milliseconds response (safety!)
β’ Works without internet
β’ Handles hardware directly
β’ Safety-critical functions
Cloud (Remote):
β’ Complex calculations
β’ Historical analysis
β’ Multi-site optimization
β’ User interfaces
β’ Can be down without danger
ANALOGY: Aircraft
β’ On-board computer (edge): Immediate decisions, flight controls
β’ Air traffic control (cloud): Routing, weather, long-term planning
β’ Both needed for safe, efficient flight
The Layered Approach
Layer 1: Hardware Interface
β’ Talks "device language" (Modbus, CAN bus)
β’ Like speaking Spanish to Spanish devices
Layer 2: Data Normalization
β’ Converts to common format
β’ Like translator making everything English
Layer 3: Control Logic
β’ Makes decisions in common format
β’ Like manager making decisions in English
Layer 4: User Interface
β’ Presents information to humans
β’ Like dashboard showing status in simple terms
WHY LAYERS: Change one layer without breaking others
Example: Swap BMS brand β Only change Layer 1
The Business Impact
For Homeowners:
β’ 30-50% lower electricity bills
β’ Backup power during outages (freezer stays cold!)
β’ Longer battery life (5+ years extra)
β’ Increased solar self-consumption (70% β 95%)
For Utilities:
β’ Reduced peak demand (delays billion-dollar upgrades)
β’ Grid stabilization (fewer blackouts)
β’ Renewable integration (more solar/wind possible)
β’ Load balancing (smoother operation)
For Society:
β’ Reduced fossil fuel use
β’ More renewable energy integration
β’ Lower carbon emissions
β’ More resilient energy infrastructure
The Code We're Writing = Digital Power Plant Operator
Think of our EMS code as hiring a 24/7 power plant operator who:
- Never sleeps (unlike humans)
- Makes decisions in milliseconds (human: seconds)
- Never gets distracted (human: coffee breaks)
- Sees all data simultaneously (human: one screen at a time)
- Follows rules exactly (human: might cut corners)
- Costs pennies per day (human: $100,000/year salary)
Why This Specific Order of Implementation?
Safety First (State Machine)
Would you:
1. Build car engine
2. THEN add brakes
3. THEN add steering
OR:
1. Build frame and safety systems
2. THEN add engine
3. THEN add features
We're doing #2 - safety foundation first
Data Before Decisions
Would you:
1. Make medical diagnosis
2. THEN take patient's temperature
OR:
1. Collect all patient data
2. THEN make diagnosis
We're collecting data (DataStore) before making decisions (Control)
Local Before Cloud
Would you:
1. Connect car to internet
2. THEN make sure it can drive
OR:
1. Make sure car drives safely
2. THEN add GPS/navigation
We're making EMS work locally before adding cloud features
The Big Picture: Energy Transition
We're at a historic moment in energy:
PAST: Centralized power plants β Long transmission β Homes
(One-way flow, dumb consumption)
PRESENT: Solar on rooftops + Batteries in garages
(Two-way flow, needs coordination)
FUTURE: Millions of small energy resources coordinated
Like internet: distributed, resilient, smart
OUR EMS: Enables this future
Summary: Why Every Line of Code Matters
- Safety Code = Prevents fires, explosions, damage
- Control Code = Saves money, optimizes energy
- Monitoring Code = Extends equipment life
- Communication Code = Enables grid services revenue
- UI Code = Makes system usable for people
Every component in our architecture has a critical real-world impact. This isn't just software - it's the nervous system for the clean energy transition.