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.
◆ LMA_Init()
Initalises the Light-Weight Metrology for AC Framework according to the config.
- Parameters
-
[in] | p_config_arg | - pointer to the configuration structure. |
◆ LMA_Deinit()
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()
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()
Loads calibration data to a system (and config).
- Parameters
-
[in] | p_calib | - pointer to the calibration data to load. |
◆ LMA_PhaseLoadCalibration()
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()
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()
Starts LMA Operation.
Starts the metering state machine and all associated drivers.
◆ LMA_Stop()
Stops LMA Operation.
Stops the metering state machine and all associated drivers.
◆ LMA_PhaseCalibrate()
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.
- Todo
- Calculate neutral phase angle error?
- Parameters
-
[in] | calib_args | - Arguments and data structure use for a calibration. |
◆ LMA_GlobalCalibrate()
Performs a calibration command according to the flags passed.
◆ LMA_EnergySet()
Sets the energy data.
- Parameters
-
[in] | p_energy | - pointer to the energy data structure to work on |
◆ LMA_EnergyGet()
Gets the energy data.
- Parameters
-
[in] | p_energy | - pointer to the energy data structure to work on |
◆ LMA_StatusGet()
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