45#define VACM_DC_ACCEPTANCE_THRESHOLD (200)
46#define VACM_DC_REJECTION_THRESHOLD (100)
47#define VACM_AC_DROP_VOLTAGE_THRESHOLD (100)
48#define VACM_AC_DROP_PERSISTANCE_COUNT (2)
49#define VACM_POLARITY_HYSTERESIS (10)
50#define VCAM_ZERO_CROSS_THRESHOLD (50)
51#define VCAM_STARTUP_HALF_GRID_CYCLE_COUNT (20)
129 switch (vacm_obj->
state)
214 else if (dc_detect_processing_complete)
492 uint32_t vin_avg_sqrd = __builtin_muluu(vacm_obj->
vin.
avg, vacm_obj->
vin.
avg);
493 vacm_obj->
vin.
avg_sqrd = (uint16_t) (vin_avg_sqrd >> 6);
613 uint32_t rectified_scaled = ((uint32_t) vacm_obj->
vin.
rectified) << 17;
694 int16_t delta_vin = abs((int16_t) (vacm_obj->
vin.
avg) - (int16_t) (vacm_obj->
vin.
avg_prev));
696 if (delta_vin < ((vacm_obj->
vin.
avg) >> 4))
731 vacm_obj->
vin.
raw = (uint16_t) vac_buffer;
769 bool processing_complete =
false;
804 processing_complete =
true;
816 processing_complete =
true;
823 processing_complete =
false;
826 return (processing_complete);
void vacm_polarity_update(struct VACM_s *vacm_obj)
bool vacm_dc_input_accept(struct VACM_s *vacm_obj)
#define VACM_DC_ACCEPTANCE_THRESHOLD
void vacm_state_standby(struct VACM_s *vacm_obj)
#define VCAM_ZERO_CROSS_THRESHOLD
void vacm_vloop_feedforward_update(struct VACM_s *vacm_obj)
void vacm_state_machine(struct VACM_s *vacm_obj)
void vacm_state_dc_detect(struct VACM_s *vacm_obj)
void vacm_vin_average(struct VACM_s *vacm_obj)
void vacm_state_wait_for_zc(struct VACM_s *vacm_obj)
#define VCAM_STARTUP_HALF_GRID_CYCLE_COUNT
void vacm_acok_assert(struct VACM_s *vacm_obj)
void vacm_capture_input(struct VACM_s *vacm_obj)
void vacm_reset_phase_monitor_object(struct VACM_s *vacm_obj)
void vacm_state_ac_sync(struct VACM_s *vacm_obj)
void vacm_state_dc_mode(struct VACM_s *vacm_obj)
void vacm_state_ac_drop(struct VACM_s *vacm_obj)
#define VACM_DC_REJECTION_THRESHOLD
void vacm_timebase_update(struct VACM_s *vacm_obj)
void vacm_reset_state_machine(struct VACM_s *vacm_obj)
#define VACM_POLARITY_HYSTERESIS
#define VACM_AC_DROP_VOLTAGE_THRESHOLD
#define VACM_AC_DROP_PERSISTANCE_COUNT
void vacm_zerocross_detect(struct VACM_s *vacm_obj)
void vacm_uv_ov_test(struct VACM_s *vacm_obj)
void vacm_state_online(struct VACM_s *vacm_obj)
#define max(a, b)
max of 2 integers
@ VACM_STATE_ACDROP
state #6: AC drop detected
@ VACM_STATE_WAIT_ZC
state #3: wait for first zero crossing
@ VACM_STATE_STANDBY
state #0: wait for launch trigger
@ VACM_STATE_DCMODE
state #2: catch-up state in DC mode, bypassing any further AC analysis of the input voltage
@ VACM_STATE_ONLINE
state #5: normal AC input operation
@ VACM_STATE_DCDETECT
state #1: check if input votlage is DC or AC
@ VACM_STATE_ACSYNC
state #4: startup-step synchronization on first few zero crossings after AC detected
#define UV_CLR_ADC
UV clear threshold converted from Volts to ADC codes.
#define AC_DROP_TIMEOUT_TICKS
AC_DROP_TIMEOUT (seconds) converted to ticks for software timer.
#define DC_ACCEPTANCE_PERIOD_TICKS
DC acceptance period in ticks.
#define FIN_MAX_TICKS
FIN_MAX (Hertz) converted to ticks for software timer.
#define OV_CLR_ADC
OV clear threshold converted from Volts to ADC codes.
#define UV_TRIG_ADC
UV_TRIG (UV trigger threshold) converted from Volts to ADC codes.
#define FIN_MIN_TICKS
FIN_MIN (Hertz) converted to ticks for software timer.
#define ZC_TMIN_TICKS
ZC_TMIN (seconds) converted to ticks for software timer.
#define OV_TRIG_ADC
OV_TRIG_ADC (OV trigger threshold) converted from Volts to ADC codes.
#define ZC_TIMEOUT_TICKS
ZC_TIMEOUT (seconds) converted to ticks for software timer.
bool ac_ok
Bit #2: flag indicating the status of the line voltage
bool zero_cross
Bit #3: flag indicating that we are in the zero cross region.
bool slope_pos
Bit #6: flag = 1 when ac line slope is positive, 0 when negative
bool polarity_pos
Bit #4: flag = 1 when polarity is positive, 0 when negative.
struct VACM_STATUS_s::@15::@17 bits
bool end_of_cycle
Bit #5: flag indicating that the end of cycle has just occured
bool dc_mode
Bit #1: 1 when Vin = DC, 0 when Vin = AC.
bool ac_drop
Bit #0: flag indicating that an ac drop may have occurred.
struct VACM_FAULT_s::@18::@20 bits
bool zc_timeout
Bit #4: flag indicating that have spent too long in zero cross region
bool fmin
Bit #2: flag indicating that frequency of line voltage < min.
bool uv
Bit #1: flag indicating that magnitude of line voltage > OV threshold.
bool ov
Bit #0: flag indicating that magnitude of line voltage < UV threshold.
bool fmax
Bit #3: flag indicating that frequency of line voltage > max.
uint16_t vloop_ff
square of the average input voltage
int16_t * ptr_offset
rectified input voltage
uint16_t * ptr_adcbuf
Pointer to register or variable where the value is read from (e.g. ADCBUFx) or written to (e....
uint16_t avg_prev
average of the rectified input voltage over 1/2 line cycle
uint16_t raw_prev
raw ADC reading of input voltage, before offset removed and rectified
uint16_t avg_sqrd
previous reading of average (over 1/2 line cycle)
uint16_t avg
pointer to offset upon which sensed input voltage sits before it is digitized by the ADC
uint16_t rectified
previous reading of raw input voltage
uint16_t counter_reset
counter used for computing the average of the rectified input voltage
uint32_t acc
when avg_counter reaches this value, compute average
uint16_t ac_drop_timer
used to time duration of zero cross
uint16_t vin_present_counter
used to time duration of AC drop event
uint16_t startup_counter
used to time duration of half cycle
uint16_t dc_loss_counter
TODO: add comment
uint16_t dc_present_counter
used to confirm that some input voltage is present
uint16_t zero_cross_timer
used to count periods at startup
uint16_t half_cycle_timer
measurement of half line cycle in IRQ ticks
Main AC Monitor data object data type declaration.
VACM_TIMEBASE_t timebase
information related to line cycle and zero cross timing
VACM_STATUS_t status
AC monitor status flags.
VACM_FAULT_t fault
AC monitor fault flags.
VACM_STATES_t state
state machine operating state ID
VACM_AVGCALC_BUFFER_t avgcalc_buffer
used for store information needed at runtime for calculation of average of rectified input voltage
VACM_VIN_t vin
information related to input voltage