diff --git a/.ccsproject b/.ccsproject index 6ffb037..e963963 100644 --- a/.ccsproject +++ b/.ccsproject @@ -9,6 +9,6 @@ - + diff --git a/.cproject b/.cproject index b6924c1..7b141b6 100644 --- a/.cproject +++ b/.cproject @@ -15,8 +15,8 @@ - - diff --git a/.project b/.project index 8ad43ef..fab4582 100644 --- a/.project +++ b/.project @@ -134,7 +134,7 @@ FAST_FPU32_SUPPLEMENT - file:/C:/ti/controlSUITE/libs/math/FPUfastRTS/V100 + $%7BTI_PRODUCTS_DIR__TIREX%7D/controlSUITE/libs/math/FPUfastRTS/V100 ORIGINAL_PROJECT_ROOT @@ -146,7 +146,7 @@ UTILITIES - file:/C:/ti/controlSUITE/libs/utilities + $%7BTI_PRODUCTS_DIR__TIREX%7D/controlSUITE/libs/utilities diff --git a/FRAM/FRAMConfigurationParameters.cpp b/FRAM/FRAMConfigurationParameters.cpp index 1e4cadc..b375d3b 100644 --- a/FRAM/FRAMConfigurationParameters.cpp +++ b/FRAM/FRAMConfigurationParameters.cpp @@ -40,7 +40,7 @@ void FRAMDATABASE::register_configuration_parameters(SYSCTRL::SystemControlConfi // // High Voltage Cell // - add_uint16(0, &sys_config->hardware.cell_level, 4); + add_uint16(0, &sys_config->hardware.cell_level, 4); // for debug!!! add_uint16(0, &sys_config->hardware.version.pwm, 210); add_uint16(0, &sys_config->hardware.version.cell, 211); add_uint32(0, &sys_config->hardware.version.cpu_cpld, 202); @@ -123,6 +123,10 @@ void FRAMDATABASE::register_configuration_parameters(SYSCTRL::SystemControlConfi add_float( 0, &sys_config->signal_decompose.projection_filter.a3, 2.61313); add_float( 0, &sys_config->signal_decompose.projection_filter.a2, 3.41422); add_float( 0, &sys_config->signal_decompose.projection_filter.a1, 2.61313); + // +#if TYPEVOLTAGEDECOMPOSE == TYPEVOLTAGEDECOMPOSE_SIMPLE + add_float( 0, &sys_config->voltage_decompose.projection_filter.time, DECOMPOSEVOLTAGETIME); +#endif //<> @@ -354,10 +358,21 @@ void FRAMDATABASE::register_configuration_parameters(SYSCTRL::SystemControlConfi #if TYPECONTROL == SCALARCONTROL + + +#if TYPEVOLTAGEDECOMPOSE == TYPEVOLTAGEDECOMPOSE_DIFFICULT add_float( 0, &sys_config->regulator_voltage_load_active_reactive.gain, 0.04); add_float( 0, &sys_config->regulator_voltage_load_active_reactive.time, 10.0e-3); - add_float( 0, &sys_config->regulator_voltage_load_active_reactive.high_saturation, 4500.0); - add_float( 0, &sys_config->regulator_voltage_load_active_reactive.low_saturation, -4500.0); + add_float( 0, &sys_config->regulator_voltage_load_active_reactive.high_saturation, 1800.0); + add_float( 0, &sys_config->regulator_voltage_load_active_reactive.low_saturation, -1800.0); +#endif +#if TYPEVOLTAGEDECOMPOSE == TYPEVOLTAGEDECOMPOSE_SIMPLE + add_float( 0, &sys_config->regulator_voltage_load_active_reactive.gain, 1/5.0); + add_float( 0, &sys_config->regulator_voltage_load_active_reactive.time, REGULATORVOLTAGETIME); + add_float( 0, &sys_config->regulator_voltage_load_active_reactive.high_saturation, 1800.0); // for debug!!! + add_float( 0, &sys_config->regulator_voltage_load_active_reactive.low_saturation, -1800.0); // for debug!!! +#endif + // add_float( 0, &sys_config->regulator_current_limit.gain, 1.0); add_float( 0, &sys_config->regulator_current_limit.time, 5.0); @@ -369,12 +384,12 @@ void FRAMDATABASE::register_configuration_parameters(SYSCTRL::SystemControlConfi add_float( 0, &sys_config->regulator_current_pfc.high_saturation, GRID_VOLTAGE_REFERENCE * 0.57735); add_float( 0, &sys_config->regulator_current_pfc.low_saturation, -GRID_VOLTAGE_REFERENCE * 0.57735); // - add_float( 0, &sys_config->current_regulator_active.gain, 0.17); // 0.34 for single winding + add_float( 0, &sys_config->current_regulator_active.gain, 0.34); // 0.34 for single winding 0.17 for double winding add_float( 0, &sys_config->current_regulator_active.time, 0.04); add_float( 0, &sys_config->current_regulator_active.high_saturation, 500.0); add_float( 0, &sys_config->current_regulator_active.low_saturation, -500.0); // - add_float( 0, &sys_config->current_regulator_reactive.gain, 0.17); // 0.34 for single winding + add_float( 0, &sys_config->current_regulator_reactive.gain, 0.34); // 0.34 for single winding 0.17 for double winding add_float( 0, &sys_config->current_regulator_reactive.time, 0.04); add_float( 0, &sys_config->current_regulator_reactive.high_saturation, 500.0); add_float( 0, &sys_config->current_regulator_reactive.low_saturation, -500.0); @@ -398,8 +413,8 @@ void FRAMDATABASE::register_configuration_parameters(SYSCTRL::SystemControlConfi // add_float( 0, &sys_config->drc_voltage_controller.gain, 0.4); //0.4 - for single winding; 0.7958 - for double winding. //7.958//1.592//0.7958 add_float( 0, &sys_config->drc_voltage_controller.time, 3.2e-3); //31.83e-3//6.366e-3//3.183e-3 - add_float( 0, &sys_config->drc_voltage_controller.high_saturation, 4500.0); - add_float( 0, &sys_config->drc_voltage_controller.low_saturation, -4500.0); + add_float( 0, &sys_config->drc_voltage_controller.high_saturation, 1276.0); + add_float( 0, &sys_config->drc_voltage_controller.low_saturation, -1276.0); // add_float( 0, &sys_config->drc_reference_voltage_direct_intensity.time, 333.0e-3); add_float( 0, &sys_config->drc_reference_voltage_direct_intensity.damp_factor, 0.9); diff --git a/SYSCTRL/AlgorithmStart.cpp b/SYSCTRL/AlgorithmStart.cpp index 99d4490..1305334 100644 --- a/SYSCTRL/AlgorithmStart.cpp +++ b/SYSCTRL/AlgorithmStart.cpp @@ -282,7 +282,7 @@ void AlgorithmStart::_execute_run() m_voltage_a = m_env.drc_voltage_cell_a * m_env.cell_dc_voltage_a_reciprocal; m_voltage_b = m_env.drc_voltage_cell_b * m_env.cell_dc_voltage_b_reciprocal; m_voltage_c = m_env.drc_voltage_cell_c * m_env.cell_dc_voltage_c_reciprocal; - // + }// // #endif diff --git a/SYSCTRL/AlgorithmWork.cpp b/SYSCTRL/AlgorithmWork.cpp index b64ae9f..f40d26c 100644 --- a/SYSCTRL/AlgorithmWork.cpp +++ b/SYSCTRL/AlgorithmWork.cpp @@ -247,7 +247,8 @@ void AlgorithmWork::_execute_single_phase(SYSCTRL::AlgorithmSinglePhaseControl& { - if(phase.control_bit.signal.enable_current_limit) +// if(phase.control_bit.signal.enable_current_limit) // for debug!!! + if(false) { phase.reference.voltage_limit = regulator_limit.execute(phase.reference.current_ampl_limit_const, phase.feedback.current_ampl_real); @@ -275,7 +276,8 @@ void AlgorithmWork::_execute_single_phase(SYSCTRL::AlgorithmSinglePhaseControl& }//if else - if(phase.control_bit.signal.enable_pfc) +// if(phase.control_bit.signal.enable_pfc) // for debug!!! + if(false) { phase.reference.voltage_ampl_real = sqrtf(phase.reference.voltage_limit * phase.reference.voltage_limit - phase.reference.voltage_pfc * phase.reference.voltage_pfc); phase.reference.voltage_ampl_jm = phase.reference.voltage_pfc; @@ -290,7 +292,8 @@ void AlgorithmWork::_execute_single_phase(SYSCTRL::AlgorithmSinglePhaseControl& // phase.reference.voltage_cell_ampl_real = regulator_active.execute(phase.reference.voltage_ampl_real, phase.feedback.voltage_ampl_real); // - if(phase.control_bit.signal.enable_pfc) + //if(phase.control_bit.signal.enable_pfc) // for debug!!! + if(false) { phase.reference.voltage_cell_ampl_jm = regulator_reactive.execute(phase.reference.voltage_ampl_jm, phase.feedback.voltage_ampl_jm); // @@ -358,8 +361,8 @@ void AlgorithmWork::_execute_run() } // m_env.drc_positive_voltage_cell_direct = m_env.drc_positive_voltage_controller_direct.execute(m_env.drc_voltage_reference_load_direct, m_env.drc_positive_voltage_load_direct); - //m_env.drc_positive_voltage_cell_quadrature = m_env.drc_positive_voltage_controller_quadrature.execute(m_env.drc_voltage_reference_load_quadrature, m_env.drc_positive_voltage_load_quadrature); - m_env.drc_positive_voltage_cell_quadrature = FP_ZERO; + m_env.drc_positive_voltage_cell_quadrature = m_env.drc_positive_voltage_controller_quadrature.execute(m_env.drc_voltage_reference_load_quadrature, m_env.drc_positive_voltage_load_quadrature); + //m_env.drc_positive_voltage_cell_quadrature = FP_ZERO; m_env.drc_negative_voltage_cell_direct = m_env.drc_negative_voltage_controller_direct.execute(m_env.drc_voltage_reference_zero, m_env.drc_negative_voltage_load_direct); m_env.drc_negative_voltage_cell_quadrature = m_env.drc_negative_voltage_controller_quadrature.execute(m_env.drc_voltage_reference_zero, m_env.drc_negative_voltage_load_quadrature); //m_env.drc_negative_voltage_cell_direct = FP_ZERO; diff --git a/SYSCTRL/Hardcode.cpp b/SYSCTRL/Hardcode.cpp index c973d42..6466fef 100644 --- a/SYSCTRL/Hardcode.cpp +++ b/SYSCTRL/Hardcode.cpp @@ -233,9 +233,9 @@ void SystemControl::get_hard_code_configuration() // // Generator ABC // - m_system_configuration.generator_abc.amplitude = 1.0; - m_system_configuration.generator_abc.frequency = 2.0*FP_PI*50.0; - m_system_configuration.generator_abc.phase_shift = 0.0; + //m_system_configuration.generator_abc.amplitude = 1.0; + //m_system_configuration.generator_abc.frequency = 2.0*FP_PI*50.0; + //m_system_configuration.generator_abc.phase_shift = 0.0; // diff --git a/SYSCTRL/MaxDetection.cpp b/SYSCTRL/MaxDetection.cpp new file mode 100644 index 0000000..3efecad --- /dev/null +++ b/SYSCTRL/MaxDetection.cpp @@ -0,0 +1,32 @@ +/* + * MaxDetection.cpp + * + * Created on: 23 февр. 2023 г. + * Author: Oleg + */ + +#include + +namespace SYSCTRL +{ + +MaxDetection::MaxDetection(): + max_value(FP_ZERO) +{ + // TODO Auto-generated constructor stub +} + +void MaxDetection::execute(float ia, float ib, float ic) +{ + if(ia > max_value) + {max_value = ia;} + + if(ib > max_value) + {max_value = ib;} + + if(ic > max_value) + {max_value = ic;} +} // execute + + +} /* namespace SYSCTRL */ diff --git a/SYSCTRL/MaxDetection.h b/SYSCTRL/MaxDetection.h new file mode 100644 index 0000000..93635a2 --- /dev/null +++ b/SYSCTRL/MaxDetection.h @@ -0,0 +1,28 @@ +/* + * MaxDetection.h + * + * Created on: 23 февр. 2023 г. + * Author: Oleg + */ + +#include +#include + +#ifndef SYSCTRL_MAXDETECTION_H_ +#define SYSCTRL_MAXDETECTION_H_ + +namespace SYSCTRL +{ + +class MaxDetection +{ +public: + MaxDetection(); + void execute(float ia, float ib, float ic); +private: + float max_value; +}; + +} /* namespace SYSCTRL */ + +#endif /* SYSCTRL_MAXDETECTION_H_ */ diff --git a/SYSCTRL/SignalDecompose.cpp b/SYSCTRL/SignalDecompose.cpp index 4b7a0d8..dbc6e5d 100644 --- a/SYSCTRL/SignalDecompose.cpp +++ b/SYSCTRL/SignalDecompose.cpp @@ -9,78 +9,12 @@ namespace SYSCTRL { + //CONSTRUCTOR SignalDecompose::SignalDecompose(): m_time_sample(-1.0), m_projection_active(), - m_projection_reactive(), - m_projection_filter_active(), - m_projection_filter_reactive(), - _execute(&SYSCTRL::SignalDecompose::_execute_undef) -// + m_projection_reactive() {}//CONSTRUCTOR -void SignalDecompose::setup(float time_sample) -{ - - m_time_sample = time_sample; - m_projection_filter_active.setup(m_time_sample); - m_projection_filter_reactive.setup(m_time_sample); - // -}// -// -void SignalDecompose::configure(const SignalDecomposeConfiguration& config) -{ - - m_projection_filter_active.configure(config.projection_filter); - m_projection_filter_reactive.configure(config.projection_filter); - // - if((m_time_sample > FP_ZERO) && (config.projection_filter.time > m_time_sample)) - { - _execute = &SYSCTRL::SignalDecompose::_execute_operational; - // - }//if - // -}// -// -#pragma CODE_SECTION("ramfuncs"); -void SignalDecompose::reset() -{ - m_projection_active = FP_ZERO; - m_projection_reactive = FP_ZERO; - m_projection_filter_active.reset(); - m_projection_filter_reactive.reset(); - // -}// -// -#pragma CODE_SECTION("ramfuncs"); -void SignalDecompose::get_outputs(float& projection_active, float& projection_reactive) -{ - projection_active = m_projection_active; - projection_reactive = m_projection_reactive; - // -}// -// -#pragma CODE_SECTION("ramfuncs"); -void SignalDecompose::execute(float reference, float ort_cos, float ort_sin) -{ - (this->*_execute)(reference, ort_cos, ort_sin); - // -}// -// -void SignalDecompose::_execute_undef(float reference, float ort_cos, float ort_sin) -{ - // -}// -// -#pragma CODE_SECTION("ramfuncs"); -void SignalDecompose::_execute_operational(float reference, float ort_cos, float ort_sin) -{ - // - m_projection_active = m_projection_filter_active.execute(1.4142 * reference * ort_cos); - // - m_projection_reactive = m_projection_filter_reactive.execute(-(1.4142 * reference * ort_sin)); - // -}// -// } /* namespace SYSCTRL */ diff --git a/SYSCTRL/SignalDecompose.h b/SYSCTRL/SignalDecompose.h index 2b913e7..c6726eb 100644 --- a/SYSCTRL/SignalDecompose.h +++ b/SYSCTRL/SignalDecompose.h @@ -8,17 +8,14 @@ #include #include -#include "SYSCTRL/BaseComponent.h" #include "SYSCTRL/HeadersFLTSYSLIB.h" #ifndef SYSCTRL_SIGNALDECOMPOSE_H_ #define SYSCTRL_SIGNALDECOMPOSE_H_ - namespace SYSCTRL { - struct SignalDecomposeStructure { float projection_active; @@ -34,40 +31,26 @@ struct SignalDecomposeStructure {} };// -struct SignalDecomposeConfiguration -{ - FLTSYSLIB::FilterForthConfiguration projection_filter; - SignalDecomposeConfiguration(): - projection_filter() - {} -};//SignalDecomposeConfiguration - - class SignalDecompose { -private: +protected: float m_time_sample; -private: +protected: float m_projection_active; float m_projection_reactive; - FLTSYSLIB::FilterForth m_projection_filter_active; - FLTSYSLIB::FilterForth m_projection_filter_reactive; public: SignalDecompose(); - void setup(float time_sample); - void configure(const SignalDecomposeConfiguration& config); + virtual void setup(float time_sample) = 0; public: - void reset(); - void get_outputs(float& projection_active, float& projection_reactive); + virtual void reset() = 0; + virtual void get_outputs(float& projection_active, float& projection_reactive) = 0; public: - void execute(float reference, float ort_cos, float ort_sin); -private: - void (SignalDecompose::*_execute)(float reference, float ort_cos, float ort_sin); - void _execute_undef(float reference, float ort_cos, float ort_sin); - void _execute_operational(float reference, float ort_cos, float ort_sin); - // -};//SignalDecompose + virtual void execute(float reference, float ort_cos, float ort_sin) = 0; +protected: + virtual void _execute_undef(float reference, float ort_cos, float ort_sin) = 0; + virtual void _execute_operational(float reference, float ort_cos, float ort_sin) = 0; +}; } /* namespace SYSCTRL */ diff --git a/SYSCTRL/SignalDecomposeFI.cpp b/SYSCTRL/SignalDecomposeFI.cpp new file mode 100644 index 0000000..54ac49f --- /dev/null +++ b/SYSCTRL/SignalDecomposeFI.cpp @@ -0,0 +1,85 @@ +/* + * SignalDecomposeFI.cpp + * + * Author: Aleksey Gerasimenko + * gerasimenko.aleksey.n@gmail.com + */ + +#include "SYSCTRL/SignalDecomposeFI.h" + +namespace SYSCTRL +{ + +//CONSTRUCTOR +SignalDecomposeFI::SignalDecomposeFI(): + SYSCTRL::SignalDecompose(), + m_projection_filter_active(), + m_projection_filter_reactive(), + _execute(&SYSCTRL::SignalDecomposeFI::_execute_undef) +{}//CONSTRUCTOR + +void SignalDecomposeFI::setup(float time_sample) +{ + + m_time_sample = time_sample; + m_projection_filter_active.setup(m_time_sample); + m_projection_filter_reactive.setup(m_time_sample); + // +}// +// +void SignalDecomposeFI::configure(const SignalDecomposeFIConfiguration& config) +{ + + m_projection_filter_active.configure(config.projection_filter); + m_projection_filter_reactive.configure(config.projection_filter); + // + if((m_time_sample > FP_ZERO) && (config.projection_filter.time > m_time_sample)) + { + _execute = &SYSCTRL::SignalDecomposeFI::_execute_operational; + // + }//if + // +}// +// +#pragma CODE_SECTION("ramfuncs"); +void SignalDecomposeFI::reset() +{ + m_projection_active = FP_ZERO; + m_projection_reactive = FP_ZERO; + m_projection_filter_active.reset(); + m_projection_filter_reactive.reset(); + // +}// +// +#pragma CODE_SECTION("ramfuncs"); +void SignalDecomposeFI::get_outputs(float& projection_active, float& projection_reactive) +{ + projection_active = m_projection_active; + projection_reactive = m_projection_reactive; + // +}// +// +#pragma CODE_SECTION("ramfuncs"); +void SignalDecomposeFI::execute(float reference, float ort_cos, float ort_sin) +{ + (this->*_execute)(reference, ort_cos, ort_sin); + // +}// +// +void SignalDecomposeFI::_execute_undef(float reference, float ort_cos, float ort_sin) +{ + // +}// +// +#pragma CODE_SECTION("ramfuncs"); +void SignalDecomposeFI::_execute_operational(float reference, float ort_cos, float ort_sin) +{ + // + m_projection_active = m_projection_filter_active.execute(1.4142 * reference * ort_cos); + // + m_projection_reactive = m_projection_filter_reactive.execute(-(1.4142 * reference * ort_sin)); + // +}// + +// +} /* namespace SYSCTRL */ diff --git a/SYSCTRL/SignalDecomposeFI.h b/SYSCTRL/SignalDecomposeFI.h new file mode 100644 index 0000000..4ca99ff --- /dev/null +++ b/SYSCTRL/SignalDecomposeFI.h @@ -0,0 +1,48 @@ +/* + * SignalDecomposeFI.h + * + * Author: Aleksey Gerasimenko + * gerasimenko.aleksey.n@gmail.com + */ + + +#include "SYSCTRL/SignalDecompose.h" + +#ifndef SYSCTRL_SIGNALDECOMPOSEFI_H_ +#define SYSCTRL_SIGNALDECOMPOSEFI_H_ + +namespace SYSCTRL +{ + +struct SignalDecomposeFIConfiguration +{ + FLTSYSLIB::FilterConfiguration projection_filter; + SignalDecomposeFIConfiguration(): + projection_filter() + {} +};//SignalDecomposeFIConfiguration + + +class SignalDecomposeFI: public SYSCTRL::SignalDecompose +{ +private: + FLTSYSLIB::Filter m_projection_filter_active; + FLTSYSLIB::Filter m_projection_filter_reactive; +public: + SignalDecomposeFI(); + void setup(float time_sample); + void configure(const SignalDecomposeFIConfiguration& config); +public: + void reset(); + void get_outputs(float& projection_active, float& projection_reactive); +public: + void execute(float reference, float ort_cos, float ort_sin); +private: + void (SignalDecomposeFI::*_execute)(float reference, float ort_cos, float ort_sin); + void _execute_undef(float reference, float ort_cos, float ort_sin); + void _execute_operational(float reference, float ort_cos, float ort_sin); +}; + +} /* namespace SYSCTRL */ + +#endif /* SYSCTRL_SIGNALDECOMPOSEFI_H_ */ diff --git a/SYSCTRL/SignalDecomposeFIV.cpp b/SYSCTRL/SignalDecomposeFIV.cpp new file mode 100644 index 0000000..90ed8b8 --- /dev/null +++ b/SYSCTRL/SignalDecomposeFIV.cpp @@ -0,0 +1,84 @@ +/* + * SignalDecomposeFIV.cpp + * + * Author: Aleksey Gerasimenko + * gerasimenko.aleksey.n@gmail.com + */ + +#include "SYSCTRL/SignalDecomposeFIV.h" + +namespace SYSCTRL +{ +//CONSTRUCTOR +SignalDecomposeFIV::SignalDecomposeFIV(): + SYSCTRL::SignalDecompose(), + m_projection_filter_active(), + m_projection_filter_reactive(), + _execute(&SYSCTRL::SignalDecomposeFIV::_execute_undef) +// +{}//CONSTRUCTOR + +void SignalDecomposeFIV::setup(float time_sample) +{ + + m_time_sample = time_sample; + m_projection_filter_active.setup(m_time_sample); + m_projection_filter_reactive.setup(m_time_sample); + // +}// +// +void SignalDecomposeFIV::configure(const SignalDecomposeFIVConfiguration& config) +{ + + m_projection_filter_active.configure(config.projection_filter); + m_projection_filter_reactive.configure(config.projection_filter); + // + if((m_time_sample > FP_ZERO) && (config.projection_filter.time > m_time_sample)) + { + _execute = &SYSCTRL::SignalDecomposeFIV::_execute_operational; + // + }//if + // +}// +// +#pragma CODE_SECTION("ramfuncs"); +void SignalDecomposeFIV::reset() +{ + m_projection_active = FP_ZERO; + m_projection_reactive = FP_ZERO; + m_projection_filter_active.reset(); + m_projection_filter_reactive.reset(); + // +}// +// +#pragma CODE_SECTION("ramfuncs"); +void SignalDecomposeFIV::get_outputs(float& projection_active, float& projection_reactive) +{ + projection_active = m_projection_active; + projection_reactive = m_projection_reactive; + // +}// +// +#pragma CODE_SECTION("ramfuncs"); +void SignalDecomposeFIV::execute(float reference, float ort_cos, float ort_sin) +{ + (this->*_execute)(reference, ort_cos, ort_sin); + // +}// +// +void SignalDecomposeFIV::_execute_undef(float reference, float ort_cos, float ort_sin) +{ + // +}// +// +#pragma CODE_SECTION("ramfuncs"); +void SignalDecomposeFIV::_execute_operational(float reference, float ort_cos, float ort_sin) +{ + // + m_projection_active = m_projection_filter_active.execute(1.4142 * reference * ort_cos); + // + m_projection_reactive = m_projection_filter_reactive.execute(-(1.4142 * reference * ort_sin)); + // +}// +// +} /* namespace SYSCTRL */ diff --git a/SYSCTRL/SignalDecomposeFIV.h b/SYSCTRL/SignalDecomposeFIV.h new file mode 100644 index 0000000..086c551 --- /dev/null +++ b/SYSCTRL/SignalDecomposeFIV.h @@ -0,0 +1,49 @@ +/* + * SignalDecomposeFIV.h + * + * Author: Aleksey Gerasimenko + * gerasimenko.aleksey.n@gmail.com + */ + +#include "SYSCTRL/SignalDecompose.h" + +#ifndef SYSCTRL_SIGNALDECOMPOSEFIV_H_ +#define SYSCTRL_SIGNALDECOMPOSEFIV_H_ + + +namespace SYSCTRL +{ + +struct SignalDecomposeFIVConfiguration +{ + FLTSYSLIB::FilterForthConfiguration projection_filter; + SignalDecomposeFIVConfiguration(): + projection_filter() + {} +};//SignalDecomposeFIVConfiguration + + +class SignalDecomposeFIV: public SYSCTRL::SignalDecompose +{ +private: + FLTSYSLIB::FilterForth m_projection_filter_active; + FLTSYSLIB::FilterForth m_projection_filter_reactive; +public: + SignalDecomposeFIV(); + void setup(float time_sample); + void configure(const SignalDecomposeFIVConfiguration& config); +public: + void reset(); + void get_outputs(float& projection_active, float& projection_reactive); +public: + void execute(float reference, float ort_cos, float ort_sin); +private: + void (SignalDecomposeFIV::*_execute)(float reference, float ort_cos, float ort_sin); + void _execute_undef(float reference, float ort_cos, float ort_sin); + void _execute_operational(float reference, float ort_cos, float ort_sin); + // +};//SignalDecomposeFIV + +} /* namespace SYSCTRL */ + +#endif /* SYSCTRL_SIGNALDECOMPOSEFIV_H_ */ diff --git a/SYSCTRL/SystemConfigurator.h b/SYSCTRL/SystemConfigurator.h index 59537ae..7019ffb 100644 --- a/SYSCTRL/SystemConfigurator.h +++ b/SYSCTRL/SystemConfigurator.h @@ -23,6 +23,8 @@ #include "SYSCTRL/PhaseAlertMonitor.h" #include "SYSCTRL/RelativeAnalogSignalStructure.h" #include "SYSCTRL/SignalDecompose.h" +#include "SYSCTRL/SignalDecomposeFI.h" +#include "SYSCTRL/SignalDecomposeFIV.h" #include "SYSCTRL/SignalRelative.h" #include "SYSCTRL/TriggerRS.h" @@ -38,10 +40,21 @@ namespace SYSCTRL #if TYPECONTROL == SCALARCONTROL + +#if TYPEVOLTAGEDECOMPOSE == TYPEVOLTAGEDECOMPOSE_DIFFICULT #define HEADER_CLASS_ID ((int16_t)(0x0001)) #define HEADER_PART_ID ((int16_t)(0x0010)) #define HEADER_SOFTWARE_VERSION ((int16_t)(0x0796)) -#define FOOTER_FOOT ((int16_t)(0xA5A5)) +#define FOOTER_FOOT ((int16_t)(0x05A5)) +#endif + +#if TYPEVOLTAGEDECOMPOSE == TYPEVOLTAGEDECOMPOSE_SIMPLE +#define HEADER_CLASS_ID ((int16_t)(0x4005)) +#define HEADER_PART_ID ((int16_t)(0x4030)) +#define HEADER_SOFTWARE_VERSION ((int16_t)(0x4426)) +#define FOOTER_FOOT ((int16_t)(0x44B4)) +#endif + #endif #if TYPECONTROL == VECTORCONTROL @@ -53,10 +66,10 @@ namespace SYSCTRL #if TYPECONTROL == DIRECTREVERSECONTROL -#define HEADER_CLASS_ID ((int16_t)(0x0C00)) -#define HEADER_PART_ID ((int16_t)(0x0C00)) -#define HEADER_SOFTWARE_VERSION ((int16_t)(0x0C00)) -#define FOOTER_FOOT ((int16_t)(0x0C00)) +#define HEADER_CLASS_ID ((int16_t)(0xAAAA)) +#define HEADER_PART_ID ((int16_t)(0xAAAA)) +#define HEADER_SOFTWARE_VERSION ((int16_t)(0xAAAA)) +#define FOOTER_FOOT ((int16_t)(0xAAAA)) #endif @@ -195,9 +208,13 @@ struct SystemControlConfiguration // - // Decompose Current Load + // Decompose Signal // - SYSCTRL::SignalDecomposeConfiguration signal_decompose; + SYSCTRL::SignalDecomposeFIVConfiguration signal_decompose; + +#if TYPEVOLTAGEDECOMPOSE == TYPEVOLTAGEDECOMPOSE_SIMPLE + SYSCTRL::SignalDecomposeFIConfiguration voltage_decompose; +#endif // @@ -355,6 +372,9 @@ struct SystemControlConfiguration rms_filter_analog_signal(), signal_decompose(), +#if TYPEVOLTAGEDECOMPOSE == TYPEVOLTAGEDECOMPOSE_SIMPLE + voltage_decompose(), +#endif pll_abc_input_voltage(), diff --git a/SYSCTRL/SystemControl.cpp b/SYSCTRL/SystemControl.cpp index 7607a8e..ed4ca6c 100644 --- a/SYSCTRL/SystemControl.cpp +++ b/SYSCTRL/SystemControl.cpp @@ -346,7 +346,7 @@ void SystemControl::setup() // Signal Decompose // -#if TYPECONTROL == VECTORCONTROL +#if ( (TYPECONTROL == VECTORCONTROL) || (TYPECONTROL == DIRECTREVERSECONTROL) ) // m_decompose_voltage_input_a.setup(m_environment.time_sample_slow); m_decompose_voltage_input_b.setup(m_environment.time_sample_slow); @@ -913,9 +913,23 @@ void SystemControl::configure() m_decompose_voltage_input_b.configure(m_system_configuration.signal_decompose); m_decompose_voltage_input_c.configure(m_system_configuration.signal_decompose); // +#if (TYPECONTROL == SCALARCONTROL) +#if TYPEVOLTAGEDECOMPOSE == TYPEVOLTAGEDECOMPOSE_DIFFICULT + m_decompose_voltage_load_a.configure(m_system_configuration.signal_decompose); + m_decompose_voltage_load_b.configure(m_system_configuration.signal_decompose); + m_decompose_voltage_load_c.configure(m_system_configuration.signal_decompose); +#endif +#if TYPEVOLTAGEDECOMPOSE == TYPEVOLTAGEDECOMPOSE_SIMPLE + m_decompose_voltage_load_a.configure(m_system_configuration.voltage_decompose); + m_decompose_voltage_load_b.configure(m_system_configuration.voltage_decompose); + m_decompose_voltage_load_c.configure(m_system_configuration.voltage_decompose); +#endif +#endif +#if (TYPECONTROL == VECTORCONTROL) || (TYPECONTROL == DIRECTREVERSECONTROL) m_decompose_voltage_load_a.configure(m_system_configuration.signal_decompose); m_decompose_voltage_load_b.configure(m_system_configuration.signal_decompose); m_decompose_voltage_load_c.configure(m_system_configuration.signal_decompose); +#endif // m_decompose_current_load_a.configure(m_system_configuration.signal_decompose); m_decompose_current_load_b.configure(m_system_configuration.signal_decompose); diff --git a/SYSCTRL/SystemControl.h b/SYSCTRL/SystemControl.h index 3a37d87..138f373 100644 --- a/SYSCTRL/SystemControl.h +++ b/SYSCTRL/SystemControl.h @@ -21,6 +21,9 @@ #include "SYSCTRL/SystemConfigurator.h" #include "SYSCTRL/SystemEnvironment.h" #include "SYSCTRL/VectorSpinner.h" +#include "SYSCTRL/TypeControl.h" + +#include "SYSCTRL/MaxDetection.h" // for debug!!! #ifndef TRAPSWRST @@ -46,26 +49,37 @@ private: SYSCTRL::AlgorithmContext::algorithm_t m_algorithm_executed; bool turnQ1On; private: + // for debug!!! + MaxDetection IcellMax; + MaxDetection IloadMax; + MaxDetection IinputMax; //Decompose Signals - SYSCTRL::SignalDecompose m_decompose_voltage_input_a; - SYSCTRL::SignalDecompose m_decompose_voltage_input_b; - SYSCTRL::SignalDecompose m_decompose_voltage_input_c; + SYSCTRL::SignalDecomposeFIV m_decompose_voltage_input_a; + SYSCTRL::SignalDecomposeFIV m_decompose_voltage_input_b; + SYSCTRL::SignalDecomposeFIV m_decompose_voltage_input_c; // - SYSCTRL::SignalDecompose m_decompose_voltage_load_a; - SYSCTRL::SignalDecompose m_decompose_voltage_load_b; - SYSCTRL::SignalDecompose m_decompose_voltage_load_c; +#if TYPEVOLTAGEDECOMPOSE == TYPEVOLTAGEDECOMPOSE_DIFFICULT + SYSCTRL::SignalDecomposeFIV m_decompose_voltage_load_a; + SYSCTRL::SignalDecomposeFIV m_decompose_voltage_load_b; + SYSCTRL::SignalDecomposeFIV m_decompose_voltage_load_c; +#endif +#if TYPEVOLTAGEDECOMPOSE == TYPEVOLTAGEDECOMPOSE_SIMPLE + SYSCTRL::SignalDecomposeFI m_decompose_voltage_load_a; + SYSCTRL::SignalDecomposeFI m_decompose_voltage_load_b; + SYSCTRL::SignalDecomposeFI m_decompose_voltage_load_c; +#endif // - SYSCTRL::SignalDecompose m_decompose_current_load_a; - SYSCTRL::SignalDecompose m_decompose_current_load_b; - SYSCTRL::SignalDecompose m_decompose_current_load_c; + SYSCTRL::SignalDecomposeFIV m_decompose_current_load_a; + SYSCTRL::SignalDecomposeFIV m_decompose_current_load_b; + SYSCTRL::SignalDecomposeFIV m_decompose_current_load_c; // - SYSCTRL::SignalDecompose m_decompose_current_bypass_a; - SYSCTRL::SignalDecompose m_decompose_current_bypass_b; - SYSCTRL::SignalDecompose m_decompose_current_bypass_c; + SYSCTRL::SignalDecomposeFIV m_decompose_current_bypass_a; + SYSCTRL::SignalDecomposeFIV m_decompose_current_bypass_b; + SYSCTRL::SignalDecomposeFIV m_decompose_current_bypass_c; // - SYSCTRL::SignalDecompose m_decompose_current_cell_a; - SYSCTRL::SignalDecompose m_decompose_current_cell_b; - SYSCTRL::SignalDecompose m_decompose_current_cell_c; + SYSCTRL::SignalDecomposeFIV m_decompose_current_cell_a; + SYSCTRL::SignalDecomposeFIV m_decompose_current_cell_b; + SYSCTRL::SignalDecomposeFIV m_decompose_current_cell_c; // private: // diff --git a/SYSCTRL/SystemControlExecute.cpp b/SYSCTRL/SystemControlExecute.cpp index 5e1b5fa..d5ab151 100644 --- a/SYSCTRL/SystemControlExecute.cpp +++ b/SYSCTRL/SystemControlExecute.cpp @@ -56,6 +56,10 @@ void SystemControl::_additional_operational() m_environment.rms_voltage_load_ca = m_rms_filter_voltage_load_c.execute(m_environment.voltage_load_c - m_environment.voltage_load_a); //<> + IcellMax.execute(m_environment.current_cell_a, m_environment.current_cell_b, m_environment.current_cell_c); // for debug!!! + IinputMax.execute(m_environment.current_input_a, m_environment.current_input_b, m_environment.current_input_c); // for debug!!! + IloadMax.execute(m_environment.current_load_a, m_environment.current_load_b, m_environment.current_load_c); // for debug!!! + // // RMS Module // @@ -1078,7 +1082,8 @@ void SystemControl::_execute_operational() m_environment.drc_current_cell_beta, m_environment.drc_current_cell_direct, m_environment.drc_current_cell_quadrature); -/* // + // + m_environment.drc_direct_voltage_decomposer.execute(m_environment.voltage_load_a, m_environment.voltage_load_b, m_environment.voltage_load_c, @@ -1098,8 +1103,9 @@ void SystemControl::_execute_operational() m_environment.main_abc_reverse_orts.phase_a.reactive, m_environment.main_abc_reverse_orts.phase_b.reactive, m_environment.main_abc_reverse_orts.phase_c.reactive); -*/ // + // +/* m_environment.drc_direct_voltage_decomposer.execute(m_environment.voltage_load_a - m_environment.drc_negative_voltage_load_direct * m_environment.main_abc_reverse_orts.phase_a.active + m_environment.drc_negative_voltage_load_quadrature * m_environment.main_abc_reverse_orts.phase_a.reactive, m_environment.voltage_load_b - m_environment.drc_negative_voltage_load_direct * m_environment.main_abc_reverse_orts.phase_b.active + m_environment.drc_negative_voltage_load_quadrature * m_environment.main_abc_reverse_orts.phase_b.reactive, m_environment.voltage_load_c - m_environment.drc_negative_voltage_load_direct * m_environment.main_abc_reverse_orts.phase_c.active + m_environment.drc_negative_voltage_load_quadrature * m_environment.main_abc_reverse_orts.phase_c.reactive, @@ -1119,7 +1125,7 @@ void SystemControl::_execute_operational() m_environment.main_abc_reverse_orts.phase_a.reactive, m_environment.main_abc_reverse_orts.phase_b.reactive, m_environment.main_abc_reverse_orts.phase_c.reactive); - +*/ // m_environment.drc_positive_voltage_load_direct = m_environment.drc_direct_voltage_decomposer.direct; diff --git a/SYSCTRL/SystemDefinitions.h b/SYSCTRL/SystemDefinitions.h index 48fcfe3..62d2ffa 100644 --- a/SYSCTRL/SystemDefinitions.h +++ b/SYSCTRL/SystemDefinitions.h @@ -135,10 +135,40 @@ union BoolRegister +// Decompose Voltage +#define DECOMPOSEVOLTAGETIME_50HZ (float)(3.183e-3) +#define DECOMPOSEVOLTAGETIME_25HZ (float)(6.366e-3) +#define DECOMPOSEVOLTAGETIME_20HZ (float)(7.958e-3) +#define DECOMPOSEVOLTAGETIME_10HZ (float)(15.915e-3) +#define DECOMPOSEVOLTAGETIME_5HZ (float)(31.831e-3) +// + +#ifndef DECOMPOSEVOLTAGETIME +//#define DECOMPOSEVOLTAGETIME DECOMPOSEVOLTAGETIME_50HZ +//#define DECOMPOSEVOLTAGETIME DECOMPOSEVOLTAGETIME_25HZ +//#define DECOMPOSEVOLTAGETIME DECOMPOSEVOLTAGETIME_20HZ +#define DECOMPOSEVOLTAGETIME DECOMPOSEVOLTAGETIME_10HZ +//#define DECOMPOSEVOLTAGETIME DECOMPOSEVOLTAGETIME_5HZ +#endif + +#ifndef REGULATORVOLTAGETIME +//#define REGULATORVOLTAGETIME DECOMPOSEVOLTAGETIME_50HZ +//#define REGULATORVOLTAGETIME DECOMPOSEVOLTAGETIME_25HZ +//#define REGULATORVOLTAGETIME DECOMPOSEVOLTAGETIME_20HZ +//#define REGULATORVOLTAGETIME DECOMPOSEVOLTAGETIME_10HZ +#define REGULATORVOLTAGETIME DECOMPOSEVOLTAGETIME_5HZ +#endif + + + + + + + #define CURRENT_LIMIT_RMS (float)(100.0) #define CURRENT_PFC_RMS (float)(0.0) -#define GRID_VOLTAGE_REFERENCE (float)(5700.0) //6000 +#define GRID_VOLTAGE_REFERENCE (float)(6050.0) //6000 #define GRID_VOLTAGE_HIGH_LIMIT (float)(6600.0) #define CELL_DC_VOLTAGE_REFERENCE (float)(5.0*950.0) diff --git a/SYSCTRL/SystemEnvironment.h b/SYSCTRL/SystemEnvironment.h index 46e5bb7..5de2888 100644 --- a/SYSCTRL/SystemEnvironment.h +++ b/SYSCTRL/SystemEnvironment.h @@ -7,6 +7,7 @@ #include #include +#include #include "framework.h" #include "DSP2833x_Device.h" // DSP2833x Headerfile Include File @@ -18,7 +19,6 @@ #include "SYSCTRL/HardWare.h" #include "SYSCTRL/MonitorDigitalInputSignal.h" #include "SYSCTRL/PhaseAlertMonitor.h" -#include "SYSCTRL/SignalDecompose.h" #include "SYSCTRL/SymmetricalComponents.h" #include "SYSCTRL/ScaleCompute.h" #include "SYSCTRL/SystemDefinitions.h" diff --git a/SYSCTRL/TypeControl.h b/SYSCTRL/TypeControl.h index df50db7..34b1270 100644 --- a/SYSCTRL/TypeControl.h +++ b/SYSCTRL/TypeControl.h @@ -28,11 +28,17 @@ #endif +#ifndef CURRENTCONTROLLER_PI #define CURRENTCONTROLLER_PI 1 +#endif +#ifndef CURRENTCONTROLLER_P #define CURRENTCONTROLLER_P 2 +#endif +#ifndef TYPECURRENTCONTROLLER #define TYPECURRENTCONTROLLER CURRENTCONTROLLER_PI //#define TYPECURRENTCONTROLLER CURRENTCONTROLLER_P +#endif #define VOLTAGE_CONTROLLER_I 1 @@ -41,5 +47,19 @@ //#define TYPE_VOLTAGE_CONTROLLER VOLTAGE_CONTROLLER_PII +#ifndef TYPEVOLTAGEDECOMPOSE_SIMPLE +#define TYPEVOLTAGEDECOMPOSE_SIMPLE 1 +#endif +#ifndef TYPEVOLTAGEDECOMPOSE_DIFFICULT +#define TYPEVOLTAGEDECOMPOSE_DIFFICULT 2 +#endif + +#ifndef TYPEVOLTAGEDECOMPOSE +//#define TYPEVOLTAGEDECOMPOSE TYPEVOLTAGEDECOMPOSE_SIMPLE +#define TYPEVOLTAGEDECOMPOSE TYPEVOLTAGEDECOMPOSE_DIFFICULT +#endif + + + #endif /* SYSCTRL_TYPECONTROL_H_ */