C/C++ Question PID Library Wrapper - WIP ?

Discussion in 'Libraries developers questions' started by KiloBravo, Jun 20, 2019.

  1. KiloBravo

    KiloBravo Member

    I spent time trying to wrap the PID Library and got pretty far.
    I did it mostly as an exercise on how to wrap a library as it would have been a lot easier to just write it as a code module.

    Question on Initialize ...

    //commonly used functions **************************************************************************
    PID(double*, double*, double*, // * constructor. links the PID to the Input, Output, and
    double, double, double, int, int); // Setpoint. Initial tuning parameters are also set here.
    // (overload for specifying proportional mode)

    /*Constructor (...)*********************************************************
    * The parameters specified here are those for for which we can't set up
    * reliable defaults, so we need to have the user set them.
    PID::pID(double* Input, double* Output, double* Setpoint,
    double Kp, double Ki, double Kd, int POn, int ControllerDirection)

    When I use the Constructor and wrap it as the Initialize Method it has 3 pointers to doubles, (Input, Output, and Setpoint. Do I convert these to ArrayDouble* so something like:

    PID(ArrayDouble* Input, ArrayDouble* Output, ArrayDouble* SetPoint, ...

    Then .... MyInput = (Double *)Input->data or would I use an Object*

    PID(Object* Input, Object* Output, Object* SetPoint, ... ???

    I attached my attempt at a library wrapper but it is still very much a work in progress.....

    Attached Files:

  2. Erel

    Erel Administrator Staff Member Licensed User

    It depends. What does the constructor do with this pointer? Maybe it is used to return a result (out parameter).
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice