53typedef enum LMA_Status_e
67typedef enum LMA_CalibrationStatus_e
77typedef struct LMA_PhaseInputs_str
88typedef struct LMA_NeutralInputs_str
97typedef struct LMA_Accs_str
110typedef struct LMA_PhaseAccs_str
120typedef struct LMA_NeutralAccs_str
130typedef struct LMA_ZeroCross_str
142typedef struct LMA_Measurements_str
157typedef struct LMA_ConsumptionData_str
173typedef struct LMA_EnergyUnit_str
198typedef struct LMA_GlobalCalibration_str
209typedef struct LMA_PhaseCalibration_str
221typedef struct LMA_NeutralCalibration_str
234typedef struct LMA_PhaseAngleError_str
248typedef struct LMA_Signals_str
259typedef struct LMA_Neutral_str
270typedef struct LMA_Phase_str
303typedef struct LMA_SystemEnergy_str
372typedef struct LMA_PhaseCalibArgs_str
384typedef struct LMA_GlobalCalibArgs_str
395typedef struct LMA_Config_str
int64_t acc_t
Accumulator type.
Definition LMA_Types.h:33
int32_t spl_t
Raw ADC sample type.
Definition LMA_Types.h:27
LMA_CalibrationStatus
Calibration status.
Definition LMA_Types.h:68
LMA_Status
Phase status.
Definition LMA_Types.h:54
@ LMA_CALIB_OK
Calibration ended sucessfully.
Definition LMA_Types.h:69
@ LMA_CALIB_PHASE_ANGLE_ERROR
The phase difference between the current and voltage is too large.
Definition LMA_Types.h:70
@ LMA_OK
No Problems.
Definition LMA_Types.h:55
@ LMA_VOLTAGE_SWELL
Vrms Swelled (Vrms > LMA_Config.v_swell)
Definition LMA_Types.h:60
@ LMA_NO_APPARENT_LOAD
No Apparent Power (S < LMA_Config.no_load_p)
Definition LMA_Types.h:58
@ LMA_NO_REACTIVE_LOAD
No Reactive Power (Q < LMA_Config.no_load_p)
Definition LMA_Types.h:57
@ LMA_VOLTAGE_SAG
Vrms Sagged (Vrms < LMA_Config.v_sag)
Definition LMA_Types.h:59
@ LMA_NO_ACTIVE_LOAD
No Active Power (P < LMA_Config.no_load_p)
Definition LMA_Types.h:56
General Accumulator structure.
Definition LMA_Types.h:98
uint32_t sample_count
Sample counter, used to track number of samples during accumulation period.
Definition LMA_Types.h:103
acc_t i_acc
Current accumulator.
Definition LMA_Types.h:100
acc_t p_acc
Active power accumulator.
Definition LMA_Types.h:101
acc_t v_acc
Voltage accumulator.
Definition LMA_Types.h:99
acc_t q_acc
Reactive power accumulator.
Definition LMA_Types.h:102
Runtime LMA Configuration.
Definition LMA_Types.h:396
float fline_tol_low
Lower tolerance of system frequency.
Definition LMA_Types.h:399
float v_sag
Voltage sag value.
Definition LMA_Types.h:404
float no_load_i
No load current value.
Definition LMA_Types.h:402
float v_swell
Voltage swell value.
Definition LMA_Types.h:405
float fline_tol_high
Upper tolerance of system frequency.
Definition LMA_Types.h:400
LMA_GlobalCalibration gcalib
Global calibration data block.
Definition LMA_Types.h:397
float meter_constant
Ws/imp ... translated Ws/imp = 3,600,000 / [imp/kwh].
Definition LMA_Types.h:401
float no_load_p
No active/reactive power load value.
Definition LMA_Types.h:403
uint32_t update_interval
Number of V line cycles to between computation updates.
Definition LMA_Types.h:398
Energy computation data.
Definition LMA_Types.h:158
float act_exp_energy_wh
active energy exported in Wh
Definition LMA_Types.h:160
float l_exp_energy_wh
reactive (inductive) energy exported in Wh
Definition LMA_Types.h:166
float c_exp_energy_wh
reactive (capacitive) energy exported in Wh
Definition LMA_Types.h:164
float app_exp_energy_wh
apparent energy exported in Wh
Definition LMA_Types.h:162
float act_imp_energy_wh
active energy imported in Wh
Definition LMA_Types.h:159
float c_imp_energy_wh
reactive (capacitive) energy imported in Wh
Definition LMA_Types.h:163
float app_imp_energy_wh
apparent energy imported in Wh
Definition LMA_Types.h:161
float l_imp_energy_wh
reactive (inductive) energy imported in Wh
Definition LMA_Types.h:165
Energy unit data.
Definition LMA_Types.h:174
float react
Currently computed unit of reactive energy per ADC interval.
Definition LMA_Types.h:177
float app
Currently computed unit of apparent energy per ADC interval.
Definition LMA_Types.h:176
float act
Currently computed unit of active energy per ADC interval.
Definition LMA_Types.h:175
Calibration arguments (global)
Definition LMA_Types.h:385
float rtc_period
period of the RTC for fs calibration
Definition LMA_Types.h:386
float fline_target
Target line frequency.
Definition LMA_Types.h:387
uint32_t rtc_cycles
number of RTC periods to accumulate for frequency calibration
Definition LMA_Types.h:388
Global/System calibration data.
Definition LMA_Types.h:199
float fline_coeff
Line Frequency Coefficient.
Definition LMA_Types.h:201
float deg_per_sample
degrees per sample
Definition LMA_Types.h:202
float fs
Sampling frequency.
Definition LMA_Types.h:200
Measurement output.
Definition LMA_Types.h:143
float irms_neutral
RMS Current (Neutral Sensing)
Definition LMA_Types.h:146
float q
Reactive Power.
Definition LMA_Types.h:149
float vrms
RMS Voltage.
Definition LMA_Types.h:144
float p
Active Power.
Definition LMA_Types.h:148
float fline
Line Frequency.
Definition LMA_Types.h:147
float s
Apparent Power.
Definition LMA_Types.h:150
float irms
RMS Current.
Definition LMA_Types.h:145
Neutral accumulators.
Definition LMA_Types.h:121
acc_t i_acc_snapshot
Snapshot of current accumulator after computation window finished.
Definition LMA_Types.h:123
acc_t i_acc_temp
Running current accumulator.
Definition LMA_Types.h:122
Neutral calibration data.
Definition LMA_Types.h:222
float irms_coeff
Irms coefficient (Neutral channel)
Definition LMA_Types.h:223
Neutral data.
Definition LMA_Types.h:260
LMA_NeutralCalibration calib
Instance of the neautrals calibration data block.
Definition LMA_Types.h:263
LMA_NeutralInputs inputs
Area to load inputs (ADC Samples) for processing.
Definition LMA_Types.h:261
LMA_NeutralAccs accs
Object holding accumulator data.
Definition LMA_Types.h:262
Phase accumulators.
Definition LMA_Types.h:111
LMA_Accs snapshot
Object holding snapshot of accumulators after computation window finished.
Definition LMA_Types.h:113
LMA_Accs temp
Object holding running accumulators.
Definition LMA_Types.h:112
Phase-angle error calibration data.
Definition LMA_Types.h:235
LMA_ZeroCross i_zero_cross
Zero cross structure for current signal.
Definition LMA_Types.h:238
float v_fraction
the fractional component of the zero cross on the voltage
Definition LMA_Types.h:240
uint32_t sample_counter
counter to track the number of phase angle computations taken for averaging
Definition LMA_Types.h:239
LMA_CalibrationStatus status
Status of the phase angle computation.
Definition LMA_Types.h:236
LMA_ZeroCross v_zero_cross
Zero cross structure for voltage signal.
Definition LMA_Types.h:237
float i_fraction
the fractional component of the zero cross on the current
Definition LMA_Types.h:241
Calibration arguments (per phase)
Definition LMA_Types.h:373
float vrms_tgt
Vrms target calibration voltage.
Definition LMA_Types.h:375
float irms_tgt
Irms target calibration current.
Definition LMA_Types.h:376
uint32_t line_cycles
Line cycles to stabilise readings over.
Definition LMA_Types.h:377
LMA_Phase * p_phase
Pointer to a phases targetting calibration.
Definition LMA_Types.h:374
Phase calibration data.
Definition LMA_Types.h:210
float vi_phase_correction
V-I Phase Correction (I relative to V i.e., I lags V = negative, I leads V = positive)
Definition LMA_Types.h:213
float vrms_coeff
Vrms coefficient.
Definition LMA_Types.h:211
float irms_coeff
Irms coefficient.
Definition LMA_Types.h:212
float p_coeff
Power coefficient.
Definition LMA_Types.h:214
Phase data.
Definition LMA_Types.h:271
LMA_Status status
Phase status.
Definition LMA_Types.h:280
LMA_PhaseCalibration calib
Instance of the phases calibration data block.
Definition LMA_Types.h:276
LMA_PhaseAngleError pa_error
phase angle error data
Definition LMA_Types.h:277
LMA_ZeroCross zero_cross
Zero cross tracking variables for voltage.
Definition LMA_Types.h:275
LMA_PhaseAccs accs
Object holding accumulator data.
Definition LMA_Types.h:274
LMA_Signals sigs
Phase signals.
Definition LMA_Types.h:281
LMA_PhaseInputs inputs
Area to load inputs (ADC Samples) for processing.
Definition LMA_Types.h:273
LMA_Neutral * p_neutral
Pointer to neutral channel (if present)
Definition LMA_Types.h:282
uint32_t phase_number
zero indexed phase number for identification
Definition LMA_Types.h:285
LMA_Measurements measurements
Object holding measurements from last computation window update.
Definition LMA_Types.h:278
float(* p_computation_hook)(float *i, float *v, float *f)
Hook to enable applying a compensation factor to power based on i, v and f args.
Definition LMA_Types.h:283
struct LMA_Phase_str * p_next
Forms singly linked list of phases (null terminated)
Definition LMA_Types.h:272
LMA_EnergyUnit energy_units
Energy processing block.
Definition LMA_Types.h:279
Signal/flag data.
Definition LMA_Types.h:249
bool calibrate_angle_error
Flag to indicate we are calibrating the phase angle error.
Definition LMA_Types.h:252
bool accumulators_ready
Flag to indicate our accumulators are ready for update.
Definition LMA_Types.h:250
bool measurements_ready
Flag to indicate a new measurement set is ready.
Definition LMA_Types.h:251
Running energy accumulators for counting energy between pulses - Ws (Watt second)
Definition LMA_Types.h:318
float app_exp_ws
Variable used to accumulate the apparent export (to grid) energy.
Definition LMA_Types.h:322
float c_react_imp_ws
Variable used to accumulate the C reactive import (from grid) energy.
Definition LMA_Types.h:323
float app_imp_ws
Variable used to accumulate the apparent import (from grid) energy.
Definition LMA_Types.h:321
float l_react_imp_ws
Variable used to accumulate the L reactive import (from grid) energy.
Definition LMA_Types.h:325
float act_imp_ws
Variable used to accumulate the active import (from grid) energy.
Definition LMA_Types.h:319
float act_exp_ws
Variable used to accumulate the active export (to grid) energy.
Definition LMA_Types.h:320
float l_react_exp_ws
Variable used to accumulate the L reactive export (to grid) energy.
Definition LMA_Types.h:326
float c_react_exp_ws
Variable used to accumulate the C reactive export (to grid) energy.
Definition LMA_Types.h:324
Total energy measured by meter in units of energy (pulses or kwh/imp)
Definition LMA_Types.h:331
uint64_t app_imp
Variable used to accumulate units of energy (pulses) over meter lifetime (apparent import ....
Definition LMA_Types.h:336
uint64_t app_exp
Variable used to accumulate units of energy (pulses) over meter lifetime (apparent export ....
Definition LMA_Types.h:338
uint64_t c_react_imp
Variable used to accumulate units of energy (pulses) over meter lifetime (C reactive import ....
Definition LMA_Types.h:340
uint64_t l_react_exp
Variable used to accumulate units of energy (pulses) over meter lifetime (L reactive export ....
Definition LMA_Types.h:346
uint64_t act_imp
Variable used to accumulate units of energy (pulses) over meter lifetime (active import ....
Definition LMA_Types.h:332
uint64_t c_react_exp
Variable used to accumulate units of energy (pulses) over meter lifetime (C reactive export ....
Definition LMA_Types.h:342
uint64_t act_exp
Variable used to accumulate units of energy (pulses) over meter lifetime (active export ....
Definition LMA_Types.h:335
uint64_t l_react_imp
Variable used to accumulate units of energy (pulses) over meter lifetime (L reactive import ....
Definition LMA_Types.h:344
Currently computed units of energy per ADC interval of whole system.
Definition LMA_Types.h:310
float react
Currently computed unit of reactive energy per ADC interval.
Definition LMA_Types.h:313
float app
Currently computed unit of apparent energy per ADC interval.
Definition LMA_Types.h:312
float act
Currently computed unit of active energy per ADC interval.
Definition LMA_Types.h:311
Energy related data.
Definition LMA_Types.h:307
Data related to impulse controls.
Definition LMA_Types.h:353
uint32_t led_on_count
Number of ADC intervals for the LED on count.
Definition LMA_Types.h:354
bool reactive_on
Flag indicating the reactive led is on.
Definition LMA_Types.h:360
uint32_t reactive_counter
Counter used to track on time of the reactive LED.
Definition LMA_Types.h:357
uint32_t apparent_counter
Counter used to track on time of the apparent LED.
Definition LMA_Types.h:356
bool apparent_on
Flag indicating the apparent led is on.
Definition LMA_Types.h:359
bool active_on
Flag indicating the active led is on.
Definition LMA_Types.h:358
uint32_t active_counter
Counter used to track on time of the active LED.
Definition LMA_Types.h:355
Energy data.
Definition LMA_Types.h:304
Zero cross detection data.
Definition LMA_Types.h:131
bool debounce
zerocross debounce flag
Definition LMA_Types.h:134
bool first_event
flag indicating we have already detected a zero cross (synch'd)
Definition LMA_Types.h:135
uint32_t count
running counter to count the number of zero cross
Definition LMA_Types.h:132
spl_t last_sample
Tracked/filtered voltage.
Definition LMA_Types.h:133