Simple battery inverter model in Simscape Electrical

Hi everyone,
I’m an electrical engineering student and need to couple batteries into my power network model. I currently have an inverter model built in Simulink/SimPowerSystems (SPS), but I’m struggling to convert it into an equivalent Simscape Electrical version. I’m looking for the simplest possible inverter model that can handle battery charging and discharging.
Does anyone have a minimal Simscape Electrical example or a reference model that I could use as a starting point? Any guidance or shared files would be greatly appreciated.
Thanks!

 Réponse acceptée

Umar
Umar le 26 Mar 2026 à 11:28
Modifié(e) : Umar le 26 Mar 2026 à 11:29

0 votes

Hi @Mikel,
Saw your post and figured I'd put together everything I found so you don't have to chase it down yourself.
First-the good news. What you're trying to do (coupling a battery to an inverter in Simscape Electrical) is totally doable, and there's actually a clean, minimal path to get there. The tricky part is really just the SPS-to-SE migration, so let me walk you through it.
The Simplest Inverter to Start With
MathWorks has an official example called the Single-Phase Half-Bridge Inverter with Ideal Switches. It's exactly what it sounds like — a DC link, two IGBT (Ideal, Switching) blocks with anti-parallel diodes, and a load. PWM gate signals control the switches. That's your foundation. Once you have that running, everything else is just layering on top. If you need three-phase, there's a packaged "Converter (Three-Phase)" block under Simscape Electrical > Converters that saves you from wiring six switches by hand.
The Battery Block
Under Simscape Electrical > Energy Storage, grab the Battery block — it's the direct replacement for the old SPS Generic Battery. It handles charge/discharge, state of charge (SOC), and voltage dynamics out of the box. For your use case (simple charge/discharge coupling), the behavioral version is fine. If you ever need higher fidelity, there's a Table-Based variant that takes OCV vs. SOC lookup tables.
One useful trick: right-click the Battery block → Battery > Basic characteristics. It plots voltage-charge curves without needing a full model. Great for sanity-checking your parameters against a datasheet before you build anything.
How to Wire It All Together
Here's the minimal block recipe:
Battery (Energy Storage) → DC link Capacitor → IGBT switches (×2 for half-bridge, ×6 for three-phase)
Voltage Sensor + Current Sensor for feedback
PWM Generator on the Simulink control side
One Solver Configuration block and one Electrical Reference (ground) — these are non-negotiable in any SE model
Watch Out For These Gotchas
A few things that'll bite you if you're coming from SPS:
1. Signal domains changed. SPS used Simulink signals everywhere. SE uses physical connection lines (the blue ones). You'll need Simulink-PS Converter and PS-Simulink Converter blocks wherever your control logic meets the physical network.
2. No powergui in SE. Replace it with the Solver Configuration block — don't bring powergui over.
3. If you try the spsConversionAssistant, it can help as a scaffold, but it sometimes converts blocks into subsystems that lose their original functionality. Treat its output as a rough draft, not a finished model.
4. Solver settings matter. For the half-bridge example, MathWorks recommends ode23t (Mod. stiff/Trapezoidal), max step size 1e-4, relative tolerance 1e-4. Worth setting that up from the start.
Links Worth Bookmarking
Half-Bridge Inverter example: mathworks.com/help/sps/ug/example-model-single-phase-half-bridge-inverter-ideal-switches.html
Battery block reference: mathworks.com/help/simscape-battery/ref/battery.html
Controlled charge/discharge example: mathworks.com/help/simscape-battery/ug/perform-controlled-charging-discharging-on-battery-module.html
SPS → SE migration guide: mathworks.com/help/sps/ug/upgrade-sps-models-to-use-simscape-blocks.html
Hope this gets you unstuck. Start with the half-bridge + Battery block, get a basic charge/discharge loop working, and then build from there. Feel free to reply if you hit a wall — happy to dig into specifics.
Good luck!

4 commentaires

Mikel
Mikel le 7 Avr 2026 à 14:39
Hi Umar,
First of all thank you for aswering my question. I am a little bit stack with this part of the project. I think that it is a part of the inverters control. I am struggling to design inverters controllers. The modulation wave goes a bit higher with the time and in the DC part I was expecting 832V and I get less than that. I share the model to you so that if it possible could help me to find the fault in the inverters control. Even though, I appreciate all the work you've done gathering information for my project.
Thank you in advanced and have a nice day,
Mikel
Umar
Umar le 7 Avr 2026 à 16:20
Hi @Mikel, Thank you for sharing the model and explaining the issue—no problem at all, I’m happy to help. Unfortunately, I don’t currently have access to Simulink, so I’m unable to open or run the model files directly. However, if you could take some screenshots of the key parts of the model (especially the inverter control section, modulation signals, and DC side), and attach them here, I’d be glad to go through them carefully. Once I can see the structure and signals, I should be able to help you troubleshoot why the modulation wave is increasing over time and why the DC voltage is lower than expected. Looking forward to your screenshots.
Mikel
Mikel le 7 Avr 2026 à 17:15
Hi Umar,
Here I attach you the screenshots:
I think it is everything. Thank you very much for answering my questions.
Mikel Santiago
clear
Grid Parameters
grid.lineVoltage = 400; % RMS value of phase-phase voltage (V)
grid.frequency = 50; % Grid power frequency (Hz)
Filter Parameters
L1=110e-6;
L2=40e-6;
C=80e-6;
%theese are values of the real inverter, I used another ones.
L1=0.6e-3;
L2=0.4e-3;
C=100e-6;
%theese are values I used.
DATOS DE BATERÍA
% Battery Parameters
battery.v_cell=64; % Each cell has a voltage of 12 volts
battery.ns_cell=13; % Number of series cells
battery.vbat_nominal=battery.ns_cell*battery.v_cell; % Nominal battery voltage
battery.resistance=0.001; % in (Ohms)
battery.capacity=245; % in (Ahr)
battery.vbat_1=battery.vbat_nominal*0.9; % Voltage V1 when charge is AH1
battery.charge_vbat1=(battery.capacity)*0.8; % Charge when no-load voltage is V1. 80% más o menos.
initialSOC=100;
Umar
Umar le 8 Avr 2026 à 22:12
Hi @Mikel, please see attached.

Connectez-vous pour commenter.

Plus de réponses (0)

Produits

Version

R2025a

Question posée :

le 25 Mar 2026 à 7:53

Commenté :

le 8 Avr 2026 à 22:12

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by