matlab_23550/Inu/Src2/551/main/calc_rms_vals.h

67 lines
1.7 KiB
C
Raw Normal View History

/*
* calc_rms_vals.h
*
* Created on: 14 <EFBFBD><EFBFBD><EFBFBD>. 2020 <EFBFBD>.
* Author: star
*/
#ifndef SRC_MAIN_CALC_RMS_VALS_H_
#define SRC_MAIN_CALC_RMS_VALS_H_
#include <params_pwm24.h>
#include "IQmathLib.h"
#define RMS_BUFFER_SIZE (FREQ_PWM * 2 / 50)
//#define RMS_BUFFER_SIZE 18 //For FREQ_PWM 450 and signal frequency 50 Hz
typedef struct {
_iq values[RMS_BUFFER_SIZE];
int array_size;
int position;
} RMS_BUFFER;
#define RMS_BUFFER_DEFAULTS {{0}, RMS_BUFFER_SIZE, 0}
#define RMS_THINNING_BUFFER_SIZE 40 //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> 30 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define RMS_THINNING_PERIOD (RMS_THINNING_BUFFER_SIZE * 3 / 4)
typedef struct {
_iq val; //in
_iq16 values[RMS_THINNING_BUFFER_SIZE];
int array_size;
int position;
int elements_in_period; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int freq_pwm; //in
_iq signal_freq; //in
int use_teta; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> teta
_iq teta; //in
struct {
int miss_write_counter;
int teta_period_counter;
_iq teta_prev;
int zero_teta_period;
// int zero_teta_counter_prev;
} internal;
void (*add_value)();
} RMS_BUFFER_WITH_THINNING;
#define RMS_BUFFER_WITH_THINNING_DEFAULTS {0, {0}, RMS_THINNING_BUFFER_SIZE,0, \
RMS_THINNING_PERIOD,\
(FREQ_PWM * 2),0,0,0, {0,0,0,0}, \
fill_rms_array_IQ15}
void fill_rms_array_IQ15(RMS_BUFFER_WITH_THINNING *v);
void fill_RMS_buff_interrupt(_iq teta_ch1, _iq teta_ch2);
void calc_RMS_values_main();
void init_Uin_rms(void);
void test_calc_rms (_iq teta);
#endif /* SRC_MAIN_CALC_RMS_VALS_H_ */