Bar Logo 3.8/7.6 kw Totem pole Demonstration Application (Part-No. (not specified))
 
Content
     
Loading...
Searching...
No Matches
vac_monitor_typedef.h
Go to the documentation of this file.
1
11/*
12 (c) 2022 Microchip Technology Inc. and its subsidiaries. You may use this
13 software and any derivatives exclusively with Microchip products.
14
15 THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
16 EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED
17 WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A
18 PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION
19 WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION.
20
21 IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
22 INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
23 WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS
24 BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE
25 FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN
26 ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
27 THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
28
29 MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE
30 TERMS.
31*/
32
33// This is a guard condition so that contents of this file are not included
34// more than once.
35#ifndef VAC_MONITOR_DEVICE_DRIVER_TYPEDEF_H
36#define VAC_MONITOR_DEVICE_DRIVER_TYPEDEF_H
37
38#include <xc.h> // include processor files - each processor file is guarded.
39#include <stdint.h> // include standard intger data type header file
40#include <stdbool.h> // include standard boolean data type header file
41#include <dsp.h> // include standard DSP data type declarations header files
42
43
52{
53 union {
54 struct{
55 bool ac_drop : 1;
56 bool dc_mode : 1;
57 bool ac_ok : 1;
58 bool zero_cross : 1;
59 bool polarity_pos : 1;
60 bool end_of_cycle : 1;
61 bool slope_pos : 1;
62
63 unsigned : 1;
64 unsigned : 1;
65 unsigned : 1;
66 unsigned : 1;
67 unsigned : 1;
68 unsigned : 1;
69 unsigned : 1;
70 unsigned : 1;
71 unsigned : 1;
72 } __attribute__((packed)) bits; // data structure for single bit addressing operations
73
74 volatile uint16_t value; // buffer for 16-bit word read/write operations
75 };
76};
78
79
88{
89 union {
90 struct{
91 bool ov : 1;
92 bool uv : 1;
93 bool fmin : 1;
94 bool fmax : 1;
95 bool zc_timeout : 1;
96
97 unsigned : 1;
98 unsigned : 1;
99 unsigned : 1;
100 unsigned : 1;
101 unsigned : 1;
102 unsigned : 1;
103 unsigned : 1;
104 unsigned : 1;
105 unsigned : 1;
106 unsigned : 1;
107 unsigned : 1;
108 } __attribute__((packed)) bits; // data structure for single bit addressing operations
109
110 uint16_t value; // buffer for 16-bit word read/write operations
111 };
112};
114
115
124{
125 uint16_t* ptr_adcbuf;
126 uint16_t raw;
127 uint16_t raw_prev;
128 uint16_t rectified;
129 int16_t* ptr_offset;
130 uint16_t avg;
131 uint16_t avg_prev;
132 uint16_t avg_sqrd;
133 uint16_t vloop_ff;
134};
135typedef struct VACM_VIN_s VACM_VIN_t;
136
137
146{
147 uint16_t counter;
148 uint16_t counter_reset;
149 uint32_t acc;
150};
152
153
173
174
175
193
194
210typedef struct VACM_s VACM_t;
211
212
213#endif /* VAC_MONITOR_DEVICE_DRIVER_TYPEDEF_H */
enum VACM_STATES_e VACM_STATES_t
Enumeration of state machine operating states data type.
@ 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
VACM_STATES_e
Enumeration of state machine operating states.
ADD_SHORT_DESCRIPTION.
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.
volatile uint16_t value
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.
ADD_SHORT_DESCRIPTION.
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.
ADD_SHORT_DESCRIPTION.
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
ADD_SHORT_DESCRIPTION.
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