Skip to content

Add a default constructor #57

Closed
Closed

Description

@Nartlof

I am developing a project that needs the PID class to be inherited or prototyped, what is not allowed with a class with no default constructor. I am using PID_v1 and I had to modify the library in order to create a default constructor, but I am not comfortable using non-standard libraries. I want my code to be as compatible as possible with the tools available to the community, so people can use my work as I use the work of others.

I thought about creating a branch on PID-v1 and ask for a pull request of my version, but that project is kind of abandoned.

Is it possible to include a default constructor in QuickPID? I would gladly do it myself if I was allowed to create a branch and them request a pull.

Activity

  1. Dlloydev commented on Jan 6, 2023

    @Dlloydev
    Owner

    Is it possible to include a default constructor in QuickPID?

    Yes. Were you needing something like this?

    #pragma once
    #ifndef QuickPID_h
    #define QuickPID_h
    
    class QuickPID {
    
      public:
    
        enum class Control : uint8_t {manual, automatic, timer};        // controller mode
        enum class Action : uint8_t {direct, reverse};                  // controller action
        enum class pMode : uint8_t {pOnError, pOnMeas, pOnErrorMeas};   // proportional mode
        enum class dMode : uint8_t {dOnError, dOnMeas};                 // derivative mode
        enum class iAwMode : uint8_t {iAwCondition, iAwClamp, iAwOff};  // integral anti-windup mode
    
        // commonly used functions ************************************************************************************
    
        // Default constructor
        QuickPID() {}
    
        // Constructor. Links the PID to Input, Output, Setpoint, initial tuning parameters and control modes.
        QuickPID(float *Input, float *Output, float *Setpoint, float Kp, float Ki, float Kd,
                 pMode pMode, dMode dMode, iAwMode iAwMode, Action Action);
    
        // Overload constructor links the PID to Input, Output, Setpoint, tuning parameters and control Action.
        // Uses defaults for remaining parameters.
        QuickPID(float *Input, float *Output, float *Setpoint, float Kp, float Ki, float Kd, Action Action);
    
        // Simplified constructor which uses defaults for remaining parameters.
        QuickPID(float *Input, float *Output, float *Setpoint);
    

    I would also consider a pull request ... or could just publish this as an update with new version (QuickPID 3.1.3)

  2. Dlloydev commented on Jan 6, 2023

    @Dlloydev
    Owner

    Added default constrictor - new version published (QuickPID 3.1.3)
    Converting to discussion ... let me know if the update is suitable, or if any changes are needed.
    Thanks,
    dlloyd

  3. Repository owner locked and limited conversation to collaborators on Jan 6, 2023
  4. converted this issue into a discussion #61 on Jan 6, 2023
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