{"id":23835166,"url":"https://github.com/johassel/h_bridge_inverter","last_synced_at":"2026-05-14T20:32:16.823Z","repository":{"id":269569226,"uuid":"907810060","full_name":"JoHassel/H_Bridge_Inverter","owner":"JoHassel","description":"Hardware/Microcontroller project to build basic functions of an H-Bridge Inverter","archived":false,"fork":false,"pushed_at":"2025-01-02T11:28:56.000Z","size":11308,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-22T03:29:36.843Z","etag":null,"topics":["inverter-control","microcontroller","micropython","mosfet-driver","power-electronics","raspberry-pi-pico"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JoHassel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-24T12:50:53.000Z","updated_at":"2025-01-02T11:28:59.000Z","dependencies_parsed_at":null,"dependency_job_id":"442130a4-6830-4daa-97e0-c481e8978a70","html_url":"https://github.com/JoHassel/H_Bridge_Inverter","commit_stats":null,"previous_names":["johassel/h_bridge_inverter"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JoHassel%2FH_Bridge_Inverter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JoHassel%2FH_Bridge_Inverter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JoHassel%2FH_Bridge_Inverter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JoHassel%2FH_Bridge_Inverter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JoHassel","download_url":"https://codeload.github.com/JoHassel/H_Bridge_Inverter/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240122465,"owners_count":19751139,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["inverter-control","microcontroller","micropython","mosfet-driver","power-electronics","raspberry-pi-pico"],"created_at":"2025-01-02T15:27:08.961Z","updated_at":"2025-09-19T10:30:20.169Z","avatar_url":"https://github.com/JoHassel.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# H-Bridge Inverter \n\n## Goal\nBasic functionality of an H-Bridge Inverter (12V DC --\u003e 230V AC)\n\n\n## Overview\n1. Microcontroller (Raspi Pico) generates a sine PWM as a control signal\n2. Sine PWM goes into a gate driver (Bootstrap) \n3. Bootstrap (one for each side) controls H-Bridge MOSFETs --\u003e sine_wave AC\n\n\u003cbr\u003e\n\n \u003cfigure\u003e\n  \u003cimg src=\"Images/H_Bridge_Kicad.png\" width=60%\u003e\n  \u003cfigcaption\u003eFig.1 - Simple H-Bridge \u003c/figcaption\u003e\n\u003c/figure\u003e \n\n\n\u003cbr\u003e\n\n## Code\n* based on [sPWM_Basic/sPWM_Basic.ino](https://github.com/Irev-Dev/Arduino-Atmel-sPWM/blob/d9c89ceef080a3c18ce5a02e0e310f1f46b8f579/sPWM_Basic/sPWM_Basic.ino)\n\n\n### Flowchart\n \u003cfigure\u003e\n  \u003cimg src=\"Images/Flowchart_Code.png\" width=60%\u003e\n  \u003cfigcaption\u003eFig.2 - Flowchart Code \u003c/figcaption\u003e\n\u003c/figure\u003e \n\n\u003cbr\u003e\n\n### Output\n\n \u003cfigure\u003e\n  \u003cimg src=\"Images/Sine_PWM_Oscilloscope.png\" width=60%\u003e\n  \u003cfigcaption\u003eFig.3 - Sine PWM Output \u003c/figcaption\u003e\n\u003c/figure\u003e \n\n\u003cbr\u003e\n\n\n## Hardware\n\n\n### Why Bootstrap Circuit?\n* source of high side MOSFET floats between V_AC (here: 12V AC) --\u003e V_GS at the high side MOSFET must be high enough to safely switch on/off the MOSFET\n* if low side MOSFET on, Bootstrap capacitor is chraged up to V_DC (here: 12V DC, voltage drop over bootstrap diode negligible)\n* if high side MOSFET is switched on, the capacitor delivers its voltage to the control pin of the high side MOSFET\n\n\u003cbr\u003e\n\n \u003cfigure\u003e\n  \u003cimg src=\"Images/Bootstrap_Circuit.png\" width=60%\u003e\n  \u003cfigcaption\u003eFig.4 - Bootstrap CIrcuit \u003c/figcaption\u003e\n\u003c/figure\u003e \n\n\u003cbr\u003e\n\n\n### Circuit Design\n* [Infineon IR2104](https://www.infineon.com/cms/de/product/power/gate-driver-ics/ir2104/) was used\n* Dimensioning based on [TI Application Note](https://www.ti.com/lit/an/slua887a/slua887a.pdf?ts=1735164351528\u0026ref_url=https%253A%252F%252Fwww.google.com%252F)\n* MOSFETs: [IRFB7537](https://www.infineon.com/dgdl/Infineon-Data_Sheet_IRFS7537PBF-DS-v01_01-EN.pdf?fileId=5546d462533600a4015364c3ee2729cb)\n\n\n#### Bootstrap Capacitor\n$C_{boot} \u003e= \\frac{Q_{total}}{\\Delta V_{HB}} = 183.75nF$  (Rule of thumb: 10 times gate capacitance leads to $190nF$) --\u003e $C_{boot} = 200 nF$ \n\n$Q_{total} = Q_G + I_{HBS} \\cdot \\frac{D_{max}}{f_{sw}} + \\frac{I_{HB}}{f_{sw}} $\n\n* $Q_G = 210nC$ from [Data Sheet MOSFET](https://www.infineon.com/dgdl/Infineon-Data_Sheet_IRFS7537PBF-DS-v01_01-EN.pdf?fileId=5546d462533600a4015364c3ee2729cb)\n\n* $I_{HBS} = 50 \\mu A$ from [Data Sheet Gate Driver](https://www.infineon.com/cms/de/product/power/gate-driver-ics/ir2104/)\n\n* $D_{max} = 1$ (will be slightly lower beacause of 520ns Dead time, 100% assumed for conservative caluclation)\n\n* $f_{sw} = 10kHz$\n\n* $I_ {HB} = 55 \\mu A$ from [Data Sheet Gate Driver](https://www.infineon.com/cms/de/product/power/gate-driver-ics/ir2104/)\n\n\n\n$\\Delta V_{HB} = V_ {DD} − V_ {DH} − V_ {HBL} = 1.2V $\n\n* $V_ {DD} = V_{DC} = 12V$\n\n* $V_ {DH} = 1V $ from [Data Sheet 1N4148](https://www.vishay.com/docs/81857/1n4148.pdf)\n\n* $V_{HBL} = 9.8V$ from [Data Sheet Gate Driver](https://www.infineon.com/cms/de/product/power/gate-driver-ics/ir2104/)\n\n\n\n\n##### Bootstrap Resistor\n$R_{boot} = \\frac{V_{DD} - V_{Boot,Diode}}{I_{peak}} = 5.5 \\Omega$ --\u003e $5.6 \\Omega$\n\n* $V_{DD} = V_{DC} = 12V$\n\n* $V_{Boot,Diode} = V_ {DH} = 1V $ from [Data Sheet 1N4148](https://www.vishay.com/docs/81857/1n4148.pdf)\n\n* I_{peak} = I_{FSM} = 2A from [Data Sheet 1N4148](https://www.vishay.com/docs/81857/1n4148.pdf)\n\n\n\n#### Gate Resistors\n$R_{G,HS} = \\frac{V_{Gate}}{I_{o+}} = 92 \\Omega$ --\u003e $91 \\Omega$\n* $V_{Gate} = V_{DC} = 12V$\n* $I_{o+} \u003e= 130mA $ from [Data Sheet Gate Driver](https://www.infineon.com/cms/de/product/power/gate-driver-ics/ir2104/)\n\n$R_{G,LS} = \\frac{V_{Gate}}{I_{o-}} = 44 \\Omega$ --\u003e $47 \\Omega$\n* $V_{Gate} = V_{DC} = 12V$\n* $I_{o+} \u003e= 270mA $ from [Data Sheet Gate Driver](https://www.infineon.com/cms/de/product/power/gate-driver-ics/ir2104/)\n\n\n### Output Filter\n* second order passive lowpass filter (LC filter)\n* Cutoff frequency $f_g = \\frac{1}{2 \\pi \\cdot \\sqrt{LC}}$ (see [ElectronicBase.net](https://electronicbase.net/de/tiefpass-berechnen/))\n* Cap chosen based on availabilty in store: $C_{Filter} = 10 \\mu F$ (use film cap, not a polarized one)\n* $L_{Filter} = 100mH$ --\u003e $f_g = 159.2Hz$\n\n## Results\nThe higher the resolution of the sine PWM (pwm_periods \u0026 scaler, see code) the clearer the sine wave output gets. Since the performance of the C code is better than the Micropython code (see below), the sine wave from the C code has less ripples. The amplitude is relatively low at the moment since there is no output voltage regulation yet. \n\n \u003cfigure\u003e\n  \u003cimg src=\"Images/Micropython.png\" width=60%\u003e\n  \u003cfigcaption\u003eFig.5 -Resulting Sine Wave with Micropython Code \u003c/figcaption\u003e\n\u003c/figure\u003e \n\n\u003cbr\u003e\n\u003cbr\u003e\n\u003cbr\u003e\n\n\u003cfigure\u003e\n  \u003cimg src=\"Images/C.png\" width=60%\u003e\n  \u003cfigcaption\u003eFig.6 -Resulting Sine Wave with C Code \u003c/figcaption\u003e\n\u003c/figure\u003e \n\u003cbr\u003e\n\n\n## Performance\nDisclaimer: I know Micropython is not made for high performance applications, but rather for rapid prototyping and easy debugging. I still wanted to see how far I can get with Micropython and compare it to C. \nAlso the C code can become much faster by shorten the timer callback, using bit operations and more. \nI am looking forward to any improvement suggestions :)\n\n| Language |\tCode Version | \t$f_{sin,set}$ in Hz | $f_{sin,real}$ in Hz |\t$f_{switch,real}$ in kHz |\n| ----------- | ----------- | ----------- | ----------- | ----------- | \n| MicroPython\t| 26/12/2024\t| 50\t| 50\t| 5 |  \n| MicroPython\t| 26/12/2024\t| 100\t| 100\t| 10 |\n| MicroPython\t| 26/12/2024\t| 500\t| 105.3\t| 10.5 |\n| C\t| 02/01/2025\t| 50\t| 50\t| 5 |\n| C\t| 02/01/2025\t| 100\t| 100\t| 10 |\n| C\t| 02/01/2025\t| 500\t| 444.4\t| 44.4 |\n\n\n## ToDos\n* shorten timer callback \n* add output voltage regulation\n* (if inductive load: add external flyback diodes in parallel to MOSFETs)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohassel%2Fh_bridge_inverter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjohassel%2Fh_bridge_inverter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohassel%2Fh_bridge_inverter/lists"}