Skip to content

Class PowerAPI

ClassList > PowerAPI

Public Functions

Type Name
void connectCapacitor (leg_t leg)
Connect the electrolytic capacitor.
void connectDriver (leg_t leg)
Turns the driver of the leg ON. This enables control over the power switches.
void disconnectCapacitor (leg_t leg)
Disconnect the electrolytic capacitor.
void disconnectDriver (leg_t leg)
Turns the driver of the leg OFF.
float32_t getDutyCycleMax (leg_t leg)
gets the Maximum Duty Cycle Limit as a float
uint16_t getDutyCycleMaxRaw (leg_t leg)
gets the Maximum Duty Cycle Limit as an unsigned integer.
float32_t getDutyCycleMin (leg_t leg)
gets the Minimum Duty Cycle Limit as a float
uint16_t getDutyCycleMinRaw (leg_t leg)
gets the Minimum Duty Cycle Limit as an unsigned integer.
uint16_t getPeriod (leg_t leg)
returns the value of the leg period as an unsigned integer
void initBoost (leg_t leg)
Initialise all the legs for boost topology, current mode is not supported for boost.
void initBuck (leg_t leg, hrtim_pwm_mode_t leg_mode=VOLTAGE_MODE)
Initialise a leg for buck topology.
void initMode (leg_t leg, hrtim_switch_convention_t leg_convention, hrtim_pwm_mode_t leg_mode)
Initialize the power mode for a given leg.
void setAdcDecim (leg_t leg, uint16_t adc_decim)
Sets ADC decimator for a leg.
void setDeadTime (leg_t leg, uint16_t ns_rising_dt, uint16_t ns_falling_dt)
set the dead time value for a leg
void setDutyCycle (leg_t leg, float32_t duty_value)
Set the duty cycle for a specific leg's power control.
void setDutyCycleMax (leg_t leg, float32_t duty_cycle)
sets the Maximum Duty Cycle Limit
void setDutyCycleMaxRaw (leg_t leg, uint16_t duty_cycle)
sets the Maximum Duty Cycle Limit as an unsigned int
void setDutyCycleMin (leg_t leg, float32_t duty_cycle)
sets the Minimum Duty Cycle Limit
void setDutyCycleMinRaw (leg_t leg, uint16_t duty_cycle)
sets the Minimum Duty Cycle Limit as an unsigned int
void setDutyCycleRaw (leg_t leg, uint16_t duty_value)
Set the duty cycle for a specific leg's power control.
void setPhaseShift (leg_t leg, int16_t phase_shift)
Set the phase shift value for a specific leg's power control.
void setSlopeCompensation (leg_t leg, float32_t set_voltage, float32_t reset_voltage)
Set the slope compensation in current mode for a leg.
void setTriggerValue (leg_t leg, float32_t trigger_value)
Set the trigger value for a specific leg's ADC trigger.
void start (leg_t leg)
Start power output for a specific leg.
void stop (leg_t leg)
Stop power output for a specific leg.

Public Functions Documentation

function connectCapacitor

Connect the electrolytic capacitor.

void PowerAPI::connectCapacitor (
    leg_t leg
) 

Parameters:

  • leg The selected leg for which the capacitor will be connected: LEG1 to ALL

Warning:

This function can only be called AFTER initializing the LEG.


function connectDriver

Turns the driver of the leg ON. This enables control over the power switches.

void PowerAPI::connectDriver (
    leg_t leg
) 

Parameters:

  • leg The leg for which the driver will be turned on: LEG1 to ALL

Warning:

This function can only be called AFTER initializing the LEG.


function disconnectCapacitor

Disconnect the electrolytic capacitor.

void PowerAPI::disconnectCapacitor (
    leg_t leg
) 

Parameters:

  • leg The selected leg for which the capacitor will be disconnected: LEG1 to ALL

Warning:

This function can only be called AFTER initializing the LEG.


function disconnectDriver

Turns the driver of the leg OFF.

void PowerAPI::disconnectDriver (
    leg_t leg
) 

Parameters:

  • leg The leg for which the driver will be turned off: LEG1 to ALL

Warning:

This function can only be called AFTER initializing the LEG.


function getDutyCycleMax

gets the Maximum Duty Cycle Limit as a float

float32_t PowerAPI::getDutyCycleMax (
    leg_t leg
) 

Parameters:

  • leg the leg for which to set dead time value: LEG1 to LEG5.

Warning:

ALL is NOT supported !


function getDutyCycleMaxRaw

gets the Maximum Duty Cycle Limit as an unsigned integer.

uint16_t PowerAPI::getDutyCycleMaxRaw (
    leg_t leg
) 

Parameters:

  • leg the leg for which to set dead time value: LEG1 to LEG5.

Warning:

ALL is NOT supported !


function getDutyCycleMin

gets the Minimum Duty Cycle Limit as a float

float32_t PowerAPI::getDutyCycleMin (
    leg_t leg
) 

Parameters:

  • leg the leg for which to set dead time value: LEG1 to LEG5.

Warning:

ALL is NOT supported !


function getDutyCycleMinRaw

gets the Minimum Duty Cycle Limit as an unsigned integer.

uint16_t PowerAPI::getDutyCycleMinRaw (
    leg_t leg
) 

Parameters:

  • leg the leg for which to set dead time value: LEG1 to LEG5.

Warning:

ALL is NOT supported !


function getPeriod

returns the value of the leg period as an unsigned integer

uint16_t PowerAPI::getPeriod (
    leg_t leg
) 

Parameters:

  • leg the leg for which to set dead time value: LEG1 to LEG5.

Warning:

ALL is NOT supported !


function initBoost

Initialise all the legs for boost topology, current mode is not supported for boost.

void PowerAPI::initBoost (
    leg_t leg
) 

Parameters:

  • leg Leg to initialize: LEG1 to ALL

function initBuck

Initialise a leg for buck topology.

void PowerAPI::initBuck (
    leg_t leg,
    hrtim_pwm_mode_t leg_mode=VOLTAGE_MODE
) 

Parameters:

  • leg Leg to initialize: LEG1 to ALL
  • leg_mode PWM mode - VOLTAGE_MODE or CURRENT_MODE

Note:

CURRENT_MODE only available to LEG1 and LEG2 for the Twist board


function initMode

Initialize the power mode for a given leg.

void PowerAPI::initMode (
    leg_t leg,
    hrtim_switch_convention_t leg_convention,
    hrtim_pwm_mode_t leg_mode
) 

This function configures modulation, frequency, phase shift, dead time, and other parameters for power control of a specified leg.

Parameters:

  • leg The leg to initialize:LEG1 to ALL
  • leg_convention PWM Switch to be driven by the duty cycle: PWMx1, PWMx2
  • leg_mode PWM mode: VOLTAGE_MODE, CURRENT_MODE

function setAdcDecim

Sets ADC decimator for a leg.

void PowerAPI::setAdcDecim (
    leg_t leg,
    uint16_t adc_decim
) 

This function sets the number of event which will be ignored between two events. ie. you divide the number of trigger in a fixed period.

For example if adc_decim = 1, nothing changes but with adc_decims = 2 you have twice less adc trigger.

Parameters:

  • leg leg for which to set adc decimator value: LEG1 to ALL
  • adc_decim adc decimator, a number between 1 and 32

function setDeadTime

set the dead time value for a leg

void PowerAPI::setDeadTime (
    leg_t leg,
    uint16_t ns_rising_dt,
    uint16_t ns_falling_dt
) 

Parameters:

  • leg the leg for which to set dead time value: LEG1 to ALL
  • ns_rising_dt rising dead time value in nanoseconds
  • ns_falling_dt falling dead time value in nanoseconds

function setDutyCycle

Set the duty cycle for a specific leg's power control.

void PowerAPI::setDutyCycle (
    leg_t leg,
    float32_t duty_value
) 

This function sets the duty cycle for the power control of a specified leg.

The duty cycle determines the ON/OFF ratio of the power signal for the leg.

Parameters:

  • leg The leg for which to set the duty cycle: LEG1 to ALL
  • duty_value The duty cycle value to set (a floating-point number between 0.1 and 0.9).

function setDutyCycleMax

sets the Maximum Duty Cycle Limit

void PowerAPI::setDutyCycleMax (
    leg_t leg,
    float32_t duty_cycle
) 

Parameters:

  • leg the leg for which to set dead time value: LEG1 to ALL
  • duty_cycle - new maximum duty cycle value between 0.0 and 1.0

function setDutyCycleMaxRaw

sets the Maximum Duty Cycle Limit as an unsigned int

void PowerAPI::setDutyCycleMaxRaw (
    leg_t leg,
    uint16_t duty_cycle
) 

Parameters:

  • leg the leg for which to set dead time value: LEG1 to ALL
  • duty_cycle - new minimum duty cycle value between 0 and period

function setDutyCycleMin

sets the Minimum Duty Cycle Limit

void PowerAPI::setDutyCycleMin (
    leg_t leg,
    float32_t duty_cycle
) 

Parameters:

  • leg the leg for which to set dead time value: LEG1 to ALL
  • duty_cycle - new minimum duty cycle value between 0.0 and 1.0

function setDutyCycleMinRaw

sets the Minimum Duty Cycle Limit as an unsigned int

void PowerAPI::setDutyCycleMinRaw (
    leg_t leg,
    uint16_t duty_cycle
) 

Parameters:

  • leg the leg for which to set dead time value: LEG1 to ALL
  • duty_cycle - new minimum duty cycle value between 0 and period

function setDutyCycleRaw

Set the duty cycle for a specific leg's power control.

void PowerAPI::setDutyCycleRaw (
    leg_t leg,
    uint16_t duty_value
) 

This function sets the duty cycle for the power control of a specified leg.

The duty cycle determines the ON/OFF time ratio of the power signal for the leg.

Parameters:

  • leg The leg for which to set the duty cycle: LEG1 to ALL
  • duty_value The duty cycle value to set an unsigned integer number between duty_cycle_min_raw and duty_cycle_max_raw.

function setPhaseShift

Set the phase shift value for a specific leg's power control.

void PowerAPI::setPhaseShift (
    leg_t leg,
    int16_t phase_shift
) 

Parameters:

  • leg The leg for which to set the phase shift value: LEG1 to ALL
  • phase_shift phase shift value in degrees between -360 and 360

function setSlopeCompensation

Set the slope compensation in current mode for a leg.

void PowerAPI::setSlopeCompensation (
    leg_t leg,
    float32_t set_voltage,
    float32_t reset_voltage
) 

Parameters:

  • leg The leg to initialize: LEG1 to ALL
  • set_voltage in volt, the DAC peak voltage for slope compensation (value between 0 and 2.048)
  • reset_voltage in volt, the DAC lowest voltage for slope compensation (value between 0 and 2.048)

Warning:

Be sure that set_voltage > reset_voltage


function setTriggerValue

Set the trigger value for a specific leg's ADC trigger.

void PowerAPI::setTriggerValue (
    leg_t leg,
    float32_t trigger_value
) 

This function sets the trigger value for the ADC trigger of a specified leg.

The trigger value determines the level at which the ADC trigger is activated.

Parameters:

  • leg The leg for which to set the ADC trigger value: LEG1 to ALL
  • trigger_value The trigger value to set between 0.05 and 0.95.

function start

Start power output for a specific leg.

void PowerAPI::start (
    leg_t leg
) 

This function initiates the power output for a specified leg by starting the PWM subunits associated with the leg's output pins.

If the leg's output pins are not declared inactive in the device tree, the corresponding subunits are started. eg.

If output1 is declared inactive in the device tree, PWMA1 will not start.

Parameters:

  • leg The leg for which to start the power output: LEG1 to ALL

function stop

Stop power output for a specific leg.

void PowerAPI::stop (
    leg_t leg
) 

Parameters:

  • leg The leg for which to stop the power output: LEG1 to ALL


The documentation for this class was generated from the following file docs/core/zephyr/modules/owntech_shield_api/zephyr/src/Power.h