LMA
Lightweight Metrology for AC
Loading...
Searching...
No Matches
Control

Description

LMA Control API

The LMA Control API is used to control the functionality of LMA, that is to say it defines LMA's behaviour. For example starting and stopping operation or performing a calibration.

Collaboration diagram for Control:

Functions

void LMA_Init (LMA_Config *const p_config_arg)
 Initalises the Light-Weight Metrology for AC Framework according to the config.
void LMA_Deinit (void)
 Deinitialises LMA.
void LMA_PhaseRegister (LMA_Phase *const p_phase)
 Registers a phase to the library.
void LMA_NeutralRegister (LMA_Phase *const p_phase, LMA_Neutral *const p_neutral)
 Registers the systems neutral line to the library (if used)
void LMA_ComputationHookRegister (LMA_Phase *const p_phase, float(*comp_hook)(float *i, float *v, float *f))
 Registers a hook to be called during parameter computations.
void LMA_GlobalLoadCalibration (const LMA_GlobalCalibration *const p_calib)
 Loads calibration data to a system (and config).
void LMA_PhaseLoadCalibration (LMA_Phase *const p_phase, const LMA_PhaseCalibration *const p_calib)
 Loads calibration data to a phase.
void LMA_NeutralLoadCalibration (LMA_Neutral *const p_neutral, const LMA_NeutralCalibration *const p_calib)
 Loads calibration data to a neutral.
void LMA_Start (void)
 Starts LMA Operation.
void LMA_Stop (void)
 Stops LMA Operation.
void LMA_PhaseCalibrate (LMA_PhaseCalibArgs *const calib_args)
 Performs a calibration command according to the flags passed.
void LMA_GlobalCalibrate (LMA_GlobalCalibArgs *const calib_args)
 Performs a calibration command according to the flags passed.
void LMA_EnergySet (LMA_SystemEnergy *const p_energy)
 Sets the energy data.
void LMA_EnergyGet (LMA_SystemEnergy *const p_energy)
 Gets the energy data.
LMA_Status LMA_StatusGet (const LMA_Phase *const p_phase)
 Gets copy of the current phase status using critical secrtions.

Function Documentation

◆ LMA_Init()

void LMA_Init ( LMA_Config *const p_config_arg)

Initalises the Light-Weight Metrology for AC Framework according to the config.

Parameters
[in]p_config_arg- pointer to the configuration structure.
Here is the call graph for this function:

◆ LMA_Deinit()

void LMA_Deinit ( void )

Deinitialises LMA.

Deconstructs the phase linked list so callbacks have no structures to work on.

Warning
Does NOT stop drivers operating - call LMA_Stop first if this is the desired behaviour.

◆ LMA_PhaseRegister()

void LMA_PhaseRegister ( LMA_Phase *const p_phase)

Registers a phase to the library.

Do once on power up. This function also initialises the phase, so should be called BEFORE LMA_NeutralRegister LMA_ComputationHookRegister

Parameters
[in]p_phase- pointer to the phase

◆ LMA_NeutralRegister()

void LMA_NeutralRegister ( LMA_Phase *const p_phase,
LMA_Neutral *const p_neutral )

Registers the systems neutral line to the library (if used)

Warning
Must be performed AFTER a phase is registered - registering a phase nullifys this.
Parameters
[in]p_phase- pointer to the phase structure to link to
[in]p_neutral- pointer to the neutral structure

◆ LMA_ComputationHookRegister()

void LMA_ComputationHookRegister ( LMA_Phase *const p_phase,
float(* comp_hook )(float *i, float *v, float *f) )

Registers a hook to be called during parameter computations.

Warning
Must be performed AFTER a phase is registered - registering a phase nullifys this.

provides a function which is called after voltage and current are computed. This function can modify the voltage and current and also return a compensation factor which is applied to the computed power values, from which the energy values are derived. This is useful for linearisation and compensation techniques used for accuracy improvements at run time.

Parameters
[in]p_phase- pointer to the phase structure to link to
[in]comp_hook- function pointer that should point to a function which accepts two pointers to floats and returns a float. the first argument is a pointer to the computed current, the second to the voltage and the third to the frequency it returns a compensation factor which is multiplied by ALL power values and propogates to the energy values. If no compensation is desired, return 1.00f - if no computation hook is set, no compensation is applied.

◆ LMA_GlobalLoadCalibration()

void LMA_GlobalLoadCalibration ( const LMA_GlobalCalibration *const p_calib)

Loads calibration data to a system (and config).

Parameters
[in]p_calib- pointer to the calibration data to load.

◆ LMA_PhaseLoadCalibration()

void LMA_PhaseLoadCalibration ( LMA_Phase *const p_phase,
const LMA_PhaseCalibration *const p_calib )

Loads calibration data to a phase.

Parameters
[in,out]p_phase- pointer to the phase
[in]p_calib- pointer to the calibration data to load.

◆ LMA_NeutralLoadCalibration()

void LMA_NeutralLoadCalibration ( LMA_Neutral *const p_neutral,
const LMA_NeutralCalibration *const p_calib )

Loads calibration data to a neutral.

Parameters
[in,out]p_neutral- pointer to the neutral object.
[in]p_calib- pointer to the calibration data to load.

◆ LMA_Start()

void LMA_Start ( void )

Starts LMA Operation.

Starts the metering state machine and all associated drivers.

Here is the call graph for this function:

◆ LMA_Stop()

void LMA_Stop ( void )

Stops LMA Operation.

Stops the metering state machine and all associated drivers.

Here is the call graph for this function:

◆ LMA_PhaseCalibrate()

void LMA_PhaseCalibrate ( LMA_PhaseCalibArgs *const calib_args)

Performs a calibration command according to the flags passed.

  • for calibration of the phase angle error - the result is stored in each phases phase.calib.vi_phase_correction. Because it depends on whether your ADC supports phase correction in hardware, it is left to the programmer to use this parameter as they see fit.
    Remarks
    This function also calibrates neutral if the a pointer to the neutral structure in the phase is non-NULL.
    Todo
    Calculate neutral phase angle error?
    Parameters
    [in]calib_args- Arguments and data structure use for a calibration.
Here is the call graph for this function:

◆ LMA_GlobalCalibrate()

void LMA_GlobalCalibrate ( LMA_GlobalCalibArgs *const calib_args)

Performs a calibration command according to the flags passed.

Here is the call graph for this function:

◆ LMA_EnergySet()

void LMA_EnergySet ( LMA_SystemEnergy *const p_energy)

Sets the energy data.

Parameters
[in]p_energy- pointer to the energy data structure to work on

◆ LMA_EnergyGet()

void LMA_EnergyGet ( LMA_SystemEnergy *const p_energy)

Gets the energy data.

Parameters
[in]p_energy- pointer to the energy data structure to work on

◆ LMA_StatusGet()

LMA_Status LMA_StatusGet ( const LMA_Phase *const p_phase)

Gets copy of the current phase status using critical secrtions.

Parameters
[in,out]p_phase- pointer to the phase block on which to get status from.
Returns
LMA_Status of phase