---
title: "MPPT Dynamo USB Charger"
tags:
description:
---
[toc]
# The plan
## Use cases
### Powering phone while navigating
### Charging a powerbank on the way
### Charging a powerbank via a solar panel?
# The specs
$V_{in_{Max}} = ? == 20V_{pp}$
$V_{in_{Min}} = 5.5V ? == 5.5V_{pp}$
$I_{DCin_{Max}} = 0.66A^{[0]}$
$P_{in_{Max}} = 13.2W$
> \[0]: Limited by current sensor resistors
# Design
Power flow:
```mermaid
graph LR
%%POWER:
ACin[Dynamo] -- 0-20Vpp --> Recti{Active rectifier}
DCin[Solar] -- 0-20VDC --> Recti{Active rectifier}
Recti --> MPPT(MPPT step down)
MPPT --> BattContr(Battery controller)
%%battController
BattContr(Battery controller) --> USB[USB C out]
BattContr --> Batt(LiPo Battery)
%%battery
Batt --> BattContr(Battery controller)
Batt --> ESP(ESP32)
Batt --> FrontLi[Front light]
Batt --> BackLi[Back light]
```
Data flow:
```mermaid
graph LR
%%DATA:
%%from ESP
ESP(ESP32) .-> BattContr(Battery controller)
ESP .-> FrontLi[Front light]
ESP .-> BackLi[Back light]
ESP .-> MPPT(MPPT step down)
%%to ESP
Recti{Active rectifier} .-> ESP
Batt(LiPo Battery) .-> ESP
%%MPPT .-> ESP
```
## Power input
Single phase AC or DC voltage from 0Hz to theoretically 100kHz.
### Active voltage doubling rectifier
Can rectify actively with low rectification losses ($R_{DSon,max}=18m\Omega$) over MOSFETs or passively over high current schottky diodes.
* 1.1A input fuse
* 20VDC voltage clamping
* Additional input for DC voltages (solar)
* Input voltage pulse counter for speed/movement detection
:::warning
> Add switch for voltage doubler/full bridge rectification?
> Add switch for capacitive voltage divider?
:::
### DC/DC MPPT converter
* Input/output voltage and input current measurement.
* Controlled via ESP32.
* Low loss DCDC converter via half bridge MOSFETs
* 10A single shot fuse for battery
* !BUCK_SD has to be high for the IC to work
### DC/DC step up converter 5V USB
>Device name ACT2802b
* controlled by a powerbank IC
* 2.2A USB output
* USB A
* USB C
:::warning
> USB C for charging?
> [ST USB C Charging IC](https://blog.st.com/stusb4500-usb-c-controller-charging/) Interesting path, but maybe not top priority as the power output is limitited from the dynamo so we won't get near USB C charging speeds.
:::
USB C with PD is not really a viable option as we can not provide the needed power (even without we can do 5*2.2=11W)
### DC/DC step up converter 6V lamps
* controlled by the ESP?
* "light me home" function, light stays on for 60(?)sec after stopping. Safety feature for waiting in traffic?
* Can be set to blinking/dimming while standing?
# Code
```cpp
void setup(){
initAll();
}
void loop(){
driveBuckConverter(findMaxPowerPoint());
}
```
:::danger
idiot is coding :laughing:

:::

## TODO
- [x] Test if programming works
- [x] Test if serial print works
- [x] Initialize all GPIO's
- [ ] Check if GPIO's are working properly
:::warning
L1 - L4 are not working. (wrong pins)
:::
- [ ] Make BUCK converter
- [x] Open loop PWM (constant pwm)
- [ ] Closed loop PWM
- [ ] Closed loop PWM with flyback MOSFET
- [ ] Maximum power point tracking
- [ ] Turn on and off front and backlight with buttons
- [ ] Feedback over LED
- [ ] Turn on and off USB output with buttons
- [ ] Feedback over LED
- [ ] LED for "battery is charging from dynamo"
- [ ] Dynamo power as output (serial or BT?)
- [ ]
## Improvements
### ADC
A lot of variance on the ADC measurements.
{%youtube RlKMJknsNpo %}
# Interesting links
## Git repository
[Git](https://git.qup.at/peter/Dynamo_USB_charger)
## Datasheets
## Theory
[Ti document about buck converter calculations.](http://www.ti.com/lit/an/slva477b/slva477b.pdf)
[mppt](https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=3&ved=2ahUKEwjijLaBqrvoAhXJzaQKHTuJBywQFjACegQIBBAB&url=https%3A%2F%2Fwww.mdpi.com%2F1996-1073%2F11%2F7%2F1826%2Fpdf&usg=AOvVaw0cK4DiRU4FdE0W_jV0-cYp)
https://docs.gimp.org/2.10/en_GB/gimp-tool-foreground-select.html