Skip to content

OPALIB PID Voltage mode

Introduction

OwnTech Power API Library PID provides a simple PID control for buck and boost in voltage mode.

This library automatically configures the driver modules required for the OwnTech Power Converter to work.

How to use

Enable the library

To enable the library, just uncomment the pid_voltage library in src/owntech.ini.

Then, include the library header in main.cpp:

Memo: the standalone PID library configuration is as follows:

pid_voltage=https://gitlab.laas.fr/owntech/power-api/opalib-pid.git

Using OPALIB PID Voltage

  • Add the following line to your main: #include "opalib_pid_voltage.h".
  • Configure the core modules, e.g. using OPALIB Quick Start's init voltage function at the beginning of your main().
  • Initialize the pid peripheral with opalib_pid_voltage_init_buck() or opalib_pid_voltage_init_boost() depending on the converter topology.
  • Run the PID calculation with opalib_pid_voltage_calculation_and_pwm_update() in order to update the duty cycle in the PWM.

Depending on the chosen conversion topology, the controlled switch will be different.

Requirement

  • The value of task_period_us must be the same value as the user task period used for opalib_quick_start.

Example of library use in combination with Library Quick start

How to tweak the pid configuration ?

  • Open the opalib_pid_voltage.c file $(PROJECTDIR)/src/
  • Modify GainADC1, offsetADC1, GainADC2 and offsetADC2 to change and calibrate the conversion of the ADC if the values converted are not coherent.

Library structure

  • $(PROJECTDIR)/src/
    • opalib_pid_voltage.c Main source file
    • opalib_pid_voltage.h List of public functions implemented in library
    • data_conversion.c Internal use only
    • data_conversion.h Internal use only