Skip to content

Handling NaN values #92

Open
Open
@ioneater

Description

@ioneater

I control a heater voltage based on a temperature reading.
The temperature reading may be NaN if there is a communication issue or if the communication is initialized.
I can off course check for that and only call pid if it is not NaN but it may be good to have a general solution for what happens in this case.
In my case it caused the Integral value to be NaN as well and it did not recover from that.
It was returning NaN which caused the heater to run at full power.

Suggestions:

  1. If the input is NaN it should be ignored and not affect the values of the components.
  2. If the input is NaN a warning should be printed independent of the return value.
  3. pid should never return NaN as this can have unpredictable consequences.
  4. What should be returned when the input is NaN I am not sure. Maybe the minimum allowed value or an additionally defined "save/neutral output value".

Activity

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

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions