ModusToolbox Power Control Middleware Library

General Description

API functions for MPPT block.

Each function of the API accepts a pointer to an MPPT context instance as first parameter. The context is self-contained. No additional local or global static data is needed for MPPT operation. This makes the implementation reentrant.

Before using the MPPT, it must be reset (MpptReset) and initialized (MpptInit). Further, the mppt_context_t::config part of the context must be correctly set by the application.

The Mppt is called on each tracking step. It processes voltage and current inputs and returns the normalized reference by reference.

Functions

void MpptReset (mppt_context_t *const context)
 Reset MPPT module state. More...
 
void MpptInit (mppt_context_t *const context)
 Initialize internal working variables from configuration. More...
 
void Mppt (mppt_context_t *const context, float32_t voltage, float32_t current, float32_t *d_ref)
 Execute one Perturb-and-Observe (P&O) tracking step. More...
 

Function Documentation

◆ MpptReset()

void MpptReset ( mppt_context_t *const  context)

Reset MPPT module state.

Clears (zeros) all internal runtime variables stored in mppt_context_t::vars:

  • Previous voltage sample (v_prev)
  • Previous power sample (p_prev)
  • Current power and intermediate deltas (p_current, dp, dv, dp_dv)
  • Reference output (d_ref) is set to a defined initial value

Call sequence requirement:

  1. Application fills context->config
  2. MpptReset()
  3. MpptInit()
  4. Repeated Mppt() calls

Safe to call again to discard accumulated tracking history.

Precondition
context != NULL
Postcondition
Internal state cleared; NOT initialized for tracking until MpptInit() runs.
Parameters
[in]contextMPPT context
Note
Does not alter user configuration (mppt_context_t::config).
Safe to call multiple times to discard accumulated tracking history.

◆ MpptInit()

void MpptInit ( mppt_context_t *const  context)

Initialize internal working variables from configuration.

Consumes user-provided limits and step settings (e.g., config.d_min, config.d_max, config.delta_d) and prepares the internal state for the first tracking iteration:

  • Validates and (if necessary) normalizes limit ordering (implementation-specific)
  • Clamps the reference into [d_min, d_max]
  • Ensures step size (delta_d) is non-negative and within a sane bound
  • Leaves historical samples (p_prev, v_prev) at their reset values (0) so the first Mppt() call establishes a baseline
Precondition
context != NULL
MpptReset() already executed on this context
Postcondition
Context ready for first Mppt() iteration
Parameters
[in]contextMPPT context
Warning
Undefined behavior if called without a prior MpptReset().

◆ Mppt()

void Mppt ( mppt_context_t *const  context,
float32_t  voltage,
float32_t  current,
float32_t *  d_ref 
)

Execute one Perturb-and-Observe (P&O) tracking step.

Implements a Perturb and Observe algorithm that outputs a normalized reference value in the range [0.0, 1.0]. The algorithm is topology-agnostic: the output can be used as a duty cycle reference, a normalized voltage reference, or any other control variable depending on the power converter topology (e.g., buck, boost, buck-boost, full-bridge).

Algorithm steps:

  1. Compute instantaneous power: p_current = voltage * current
  2. Compute deltas: dp = p_current - p_prev, dv = voltage - v_prev
  3. Form product: dp_dv = dp * dv
  4. If dp_dv >= 0: decrement reference (d_ref -= delta_d); else increment
  5. Clamp reference into [d_min, d_max]
  6. Update historical samples (p_prev, v_prev)
  7. Output updated normalized reference

The application is responsible for scaling the normalized output to the appropriate physical range for the target converter. For example:

  • Direct use as PWM duty cycle
  • Multiply by V_bus to obtain a voltage setpoint
  • Map to a current reference for a current-controlled topology

Characteristics/limitations of current variant:

  • No adaptive step modulation
  • No explicit settling/debounce timing
  • No minimum power threshold gating
Precondition
Context initialized via MpptReset() then MpptInit()
d_ref != NULL
Postcondition
*d_ref contains new normalized reference within [config.d_min, config.d_max]
Parameters
[in]contextMPPT context
[in]voltageLatest input voltage (Volts)
[in]currentLatest input current (Amperes)
[out]d_refPointer to store normalized reference output (0.0 .. 1.0). Interpretation depends on converter topology (duty cycle, normalized voltage, etc.)
Warning
Voltage/current samples must be time-coherent.
Note
First call (after init) uses zeroed history; behavior of initial step is deterministic but may not represent a true perturb decision until second call.