owntech-foundation / Core

A comprehensive API for power electronics based on Zephyr RTOS
https://www.owntech.org/
GNU Lesser General Public License v2.1
3 stars 10 forks source link

[dataAPI] Missing generic function to store calibration parameters for SPIN. #29

Closed jalinei closed 3 months ago

jalinei commented 6 months ago

Dual problem in the existing Data API:

We need to add a function in data API to store permanently the parameters (defined through setParameters) in the NVS. It has to be implemented both for twist and for SPIN.

We may also adapt interaction based function to SPIN as it is a nice feature to tweak parameters on the fly.

luizvilla commented 6 months ago

I have created a function to do this. You can find it here :

https://gitlab.laas.fr/lflavado/core/-/tree/power_test_boot?ref_type=heads

In the DataAPI.h you will find:


    /**
     * @brief Use this function to write the gain and offset parameters of the board to is non-volatile memory.
     *
     * @note  This function should be called after updating the parameters using setParameters.
     *
     * @param channel Name of the shield channel to save the values.
     */
    int8_t saveParametersInNVS(channel_t channel);

    /**
     * @brief Use this function to read the gain and offset parameters of the board to is non-volatile memory.
     *
     * @param channel Name of the shield channel to save the values.
     */
    int8_t getParametersFromNVS(channel_t channel);

This commit allows finding the update for saving to the NVS: 83a65477246b7cc5ae312cc55c7f6b0efd0a14e7

This commit allows finding the update for getting from the NVS: b165b83342cf8b4da5877b838317eb0ad40a716e

This is only implemented for the TWIST board, but it is not difficult to generalize from here if needed.

jalinei commented 6 months ago

I propose the following :

  1. Draft a PR based on these two commits. From what I understand It it already complementary to existing data.setTwistChannelsUserCalibrationFactors() which is fully manual and based on console interaction. (Which is not suitable in many contexts) @luizvilla
  2. Let's discuss how to adapt is to a generic form for SPIN. @luizvilla @jalinei
  3. Merge.
  4. Add section to documentation @jalinei
luizvilla commented 6 months ago

Sounds good to me. I can prepare a PR.

jalinei commented 6 months ago

34 Is closing this issue right ?