Skip to content

Bug with I contribution ? #110

Closed
Closed

Description

@SeByDocKy

Hello,

I am trying a new usage for your simplePID package, this time dedicaced for EV charging thanks to an OpenEVSE module. The idea is to regulate the AC current value sent to the car (through the OpenEVSE) according to a DC battery current measure. For my particular application, input (DC battery current) can vary about - 40A up to 40A and the output (AC current sent) is between 6A up to 20A (for example)... So PID must be a function from [-40,40]ADC |---> [6,20]AAC

When I first tried with these setting, actually with just some Kp non-zero value (Kp=0.2, Ki=Kd=0) and setpoint = 0A, I noticed the regulation was not working, i.e. the output was always staying at 6A (the output_min value) whatever the error was largely positive.... I noticed a potential problem (or something I didn't understood) with the P,I,D contributions values:

The Icontribution whatever Ki = 0 converged to the output_min value.... here 6A... More assuming I momentanary set the output_min point to 7A, the Icontribution shift to 7... but if I revert back output_min to 6A, the Icontribution.... now slowly decreases from 7A to 6A (I guess according the Ki value)
See figure attached below

Image

For me it's not normal... and would explain why the regulation don't "take off"...

Cheers,

Sébastien

BTW... it would be also nice if we can change the default device_class/icon of the output.. .coz for my application it's not percent but current device_class..

Activity

  1. bvweerd commented on Sep 18, 2025

    @bvweerd
    Owner

    Hi @SeByDocKy ,

    Please add your diagnostics file to the issue, so I can understand your complete config.

  2. SeByDocKy commented on Sep 18, 2025

    @SeByDocKy
    Author
    Image

    Ok I think I found a potential problem in the original simple-pid lib l99

            self._integral = _clamp(starting_output, output_limits)
    

    So since I set it the startup value to 6... I guess it's explaining everything... The problem actually I can't set it to 0 .... (since currently it must bound into [6,20]

  3. bvweerd commented on Sep 18, 2025

    @bvweerd
    Owner

    You can change the way it starts with the select "PID Start Value" and let it start at 0 or at previous.

  4. SeByDocKy commented on Sep 18, 2025

    @SeByDocKy
    Author

    It's what I did

    Image
  5. bvweerd commented on Sep 18, 2025

    @bvweerd
    Owner

    Okay, that's what I would expect, since you have the minimum output at 6, the I has to be set to meet your output min.

    If you really want to get to the basic functionality of the PID controller, zero-start is your starting point, and wind-up protection off.

    Regarding the diagnostics, please use the 'download diagnostics' button of the integration (use the "..." behind te integration in the device overview)

  6. SeByDocKy commented on Sep 18, 2025

    @SeByDocKy
    Author

    By the way I tried without the windup option and start with zero... but as expected... the EV don't start to charge with such low value ...:(.... This line l99 in the original lib is my main concern ... :(

  7. bvweerd commented on Sep 20, 2025

    @bvweerd
    Owner

    So, you error is roughly 40, which results in a p-contrib of roughly -8. But since you've limited the output to 6, it won't go any lower than 6. That's what would be expected.

    The I contribution is set to the lowest value when at 0-start. It won't change if you have Ki at 0, so that means that the I contribution will always be stable. Using a small value for Ki will change this behavior.

    Another option is to decrease your Kp, so it won't result in a correction lower than the minimal output you've set.

    If I understand correctly you're using it to control a EV charge rate. Note that some older cars need a current of >8A to start (although the standard says 6A), and some chargers are also not very precise in their configuration. So I would start trying with some bigger numbers during your tests.

  8. SeByDocKy commented on Sep 20, 2025

    @SeByDocKy
    Author

    I converged with some (Kp,Ki) values which are just fine.... Definitively was required a non-zero (but) small Ki value

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionMore information needed

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions