Skip to content

Chargerate #117

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 2, 2025
Merged

Chargerate #117

merged 4 commits into from
May 2, 2025

Conversation

JohnAZoidberg
Copy link
Member

@JohnAZoidberg JohnAZoidberg commented Apr 29, 2025

Resolves #13

Setting a custom charger current limit

# 1C = normal charging rate
# This means charging from 0 to 100% takes 1 hour
# Set charging rate to 0.8C
> sudo framework_tool --charge-rate-limit 0.8

# Limit charge current to the battery to to 2A
# In the output of `framework_tool --power -vv` above you can se "Design Capacity"
# Dividing that by 1h gives you the maximum charging current (1C)
# For example Design Capacity:  3915 mAh => 3915mA
> sudo framework_tool --charge-current-limit 2000

# And then plug in a power adapter
> sudo framework_tool --power
Charger Status
  AC is:            connected
  Charger Voltage:  17800mV
  Charger Current:  2000mA
  Chg Input Current:3084mA
  Battery SoC:      87%
Battery Status
  AC is:            connected
  Battery is:       connected
  Battery LFCC:     3713 mAh (Last Full Charge Capacity)
  Battery Capacity: 3215 mAh
                    56.953 Wh
  Charge level:     86%
  Battery charging

# Remove limit (set rate to 1C)
> sudo framework_tool --charge-rate-limit 1

# Back to normal
> sudo framework_tool --power
Charger Status
  AC is:            connected
  Charger Voltage:  17800mV
  Charger Current:  2740mA
  Chg Input Current:3084mA
  Battery SoC:      92%
Battery Status
  AC is:            connected
  Battery is:       connected
  Battery LFCC:     3713 mAh (Last Full Charge Capacity)
  Battery Capacity: 3387 mAh
                    60.146 Wh
  Charge level:     91%
  Battery charging

# Set charge rate/current limit only if battery is >80% charged
> sudo framework_tool --charge-rate-limit 80 0.8
> sudo framework_tool --charge-current-limit 80 2000

@kiram9
Copy link
Member

kiram9 commented Apr 29, 2025

we should see if this updates the PMF frameworks correctly for the input current limit. Otherwise there might be a risk of brownout. especially on 16in.

@JohnAZoidberg
Copy link
Member Author

JohnAZoidberg commented Apr 30, 2025

It doesn't. This is about the current going into the battery. Not the current limit from AC to the system.

@JohnAZoidberg JohnAZoidberg force-pushed the chargerate branch 2 times, most recently from b35bca8 to 3365194 Compare April 30, 2025 08:56
```
> sudo framework_tool --power
Place your right index finger on the fingerprint reader
Charger Status
  AC is:            not connected
  Charger Voltage:  17048mV
  Charger Current:  0mA
  Chg Input Current:384mA
  Battery SoC:      93%
Battery Status
  AC is:            not connected
  Battery is:       connected
  Battery LFCC:     3693 mAh (Last Full Charge Capacity)
  Battery Capacity: 3409 mAh
                    58.96 Wh
  Charge level:     92%
  Battery discharging
```

Signed-off-by: Daniel Schaefer <dhs@frame.work>
Signed-off-by: Daniel Schaefer <dhs@frame.work>
Usually the user won't want to specify a mA value to limit the charge
current. Setting a charge rate 0.0-1.0 is more useful.

```
PS C:\Users\Daniel\clone\framework-system-private> sudo .\target\debug\framework_tool.exe --power
Charger Status
  AC is:            connected
  Charger Voltage:  17800mV
  Charger Current:  2740mA
                    0.6998723C
  Chg Input Current:2848mA
  Battery SoC:      94%
Battery Status
  AC is:            connected
  Battery is:       connected
  Battery LFCC:     4021 mAh (Last Full Charge Capacity)
  Battery Capacity: 3751 mAh
                    66.512 Wh
  Charge level:     93%
  Battery charging
PS C:\Users\Daniel\clone\framework-system-private> sudo .\target\debug\framework_tool.exe --charge-rate-limit 0.5
Requested Rate:      0.5C
Design Current:      3915mA
Limiting Current to: 1957mA
PS C:\Users\Daniel\clone\framework-system-private> sudo .\target\debug\framework_tool.exe --power
Charger Status
  AC is:            connected
  Charger Voltage:  17800mV
  Charger Current:  1956mA
                    0.49961686C
  Chg Input Current:2848mA
  Battery SoC:      94%
Battery Status
  AC is:            connected
  Battery is:       connected
  Battery LFCC:     4021 mAh (Last Full Charge Capacity)
  Battery Capacity: 3754 mAh
                    66.584 Wh
  Charge level:     93%
  Battery charging
```

Signed-off-by: Daniel Schaefer <dhs@frame.work>
Signed-off-by: Daniel Schaefer <dhs@frame.work>
@JohnAZoidberg JohnAZoidberg merged commit 60ff99f into main May 2, 2025
6 checks passed

/// Get or set max charge current limit
#[arg(long)]
#[clap(num_args = ..2)]
Copy link

@tjkirch tjkirch May 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I'm understanding correctly, I believe this limits the argument count to a max of 1, and if you want to allow 2, you need ..=2 instead, right? Same for charge rate limit. I mention this because I'm trying to use framework_tool v0.4 with --charge-rate-limit 60 0.7 (similar to the syntax given in the new examples) but I get a clap error, "unexpected argument '0.7' found". It does work with a single argument, but I wanted to use the conditional form with the second argument based on battery state of charge.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you're right. Thanks!. #123

Comment on lines +245 to +246
> sudo framework_tool --charge-rate-limit 80 0.8
> sudo framework_tool --charge-current-limit 80 2000
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that the limit (out of 1.0) is always required and the state of charge (out of 100) is optional, and in the code the limit is always first and the SoC is second (in an Option), so would that mean that this example has the arguments reversed? Sorry if I'm missing something obvious; I can't test it because of the issue in the other comment I'm leaving.

@JohnAZoidberg JohnAZoidberg deleted the chargerate branch May 2, 2025 09:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add option to limit charging rate
3 participants