You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

462 lines
12 KiB
C

/*
* SystemConfigurator.h
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include <math.h>
#include <stdint.h>
#include "framework.h"
#include "DSP2833x_Device.h" // DSP2833x Headerfile Include File
#include "DSP2833x_Examples.h"
#include "SYSCTRL/AlgorithmContext.h"
//#include "SYSCTRL/FanControl.h"
#include "SYSCTRL/ContactorFault.h"
#include "SYSCTRL/FanTimerControl.h"
#include "SYSCTRL/GeneratorSymmetricalComponents.h"
#include "SYSCTRL/HardWare.h"
#include "SYSCTRL/HeadersFLTSYSLIB.h"
#include "SYSCTRL/PhaseAlertMonitor.h"
#include "SYSCTRL/RelativeAnalogSignalStructure.h"
#include "SYSCTRL/SignalDecompose.h"
5 months ago
#include "SYSCTRL/SignalDecomposeFI.h"
#include "SYSCTRL/SignalDecomposeFIV.h"
#include "SYSCTRL/SignalRelative.h"
#include "SYSCTRL/TriggerRS.h"
#ifndef SYSCTRL_SYSTEMCONFIGURATOR_H_
#define SYSCTRL_SYSTEMCONFIGURATOR_H_
namespace SYSCTRL
{
#define NUMBER_FRAM_PARAMETERS ((uint16_t)(200))
#define NUMBER_FLASH_PARAMETERS ((uint16_t)(10))
#if TYPECONTROL == SCALARCONTROL
5 months ago
#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))
5 months ago
#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
#define HEADER_CLASS_ID ((int16_t)(0x0002))
#define HEADER_PART_ID ((int16_t)(0x0059))
#define HEADER_SOFTWARE_VERSION ((int16_t)(0x3C3C))
#define FOOTER_FOOT ((int16_t)(0xC7C7))
#endif
#if TYPECONTROL == DIRECTREVERSECONTROL
5 months ago
#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
struct SystemControlSetup
{
float time_sample_control;
int16 time_prescale_slow;
int16 time_prescale_additional;
//
// Decompose Current Load
//
SYSCTRL::SignalRelativeSetup relative_voltage_input;
//
SystemControlSetup():
time_sample_control(-1.0),
time_prescale_slow(0),
time_prescale_additional(0),
relative_voltage_input()
{}
};//end SystemControlSetup
struct TestConfiguration
{
//
// RMS Filter
//
FLTSYSLIB::RMSF4OConfiguration rms_filter;
//
// Regulators
//
FLTSYSLIB::PIControllerConfiguration regulator_voltage;
//
// PLL-ABC Voltage
//
FLTSYSLIB::PLLABCDVRConfiguration pll_abc;
TestConfiguration():
rms_filter(),
regulator_voltage(),
pll_abc()
{}
};//
struct SystemControlConfiguration
{
//
// References
//
float reference_current_limit_rms;
float reference_current_pfc_rms;
float reference_voltage_rms;
float reference_voltage_high_limit_rms;
float reference_voltage_dc;
SYSCTRL::AlgorithmControlRegister algorithm_control;
//
// High Voltage Cell
//
SYSCTRL::HardWareConfiguration hardware;
float minimal_input_voltage_level;
float scale_voltage_input_a;
float scale_voltage_input_b;
float scale_voltage_input_c;
//
float scale_current_input_a;
float scale_current_input_b;
float scale_current_input_c;
//
float scale_current_cell_a;
float scale_current_cell_b;
float scale_current_cell_c;
//
float scale_voltage_load_a;
float scale_voltage_load_b;
float scale_voltage_load_c;
//
float scale_current_load_a;
float scale_current_load_b;
float scale_current_load_c;
//
float scale_current_bypass_a;
float scale_current_bypass_b;
float scale_current_bypass_c;
//
// System Alarm
//
SYSCTRL::PhaseAlertConfiguration phase_alert_monitor;
//
// DIGITAL INPUTS
//
FLTSYSLIB::DigitalInputAntiNoiseConfiguration digital_input_config; //3001-3020
//
// FAN CONTROL
//
SYSCTRL::FanTimerControlConfiguration fan_control;
//
// Amplitude Filter
//
// FLTSYSLIB::AMPLF4OConfiguration ampl_filter_voltage;
FLTSYSLIB::AMPLF4OConfiguration ampl_filter_current;
//
// RMS Filter
//
FLTSYSLIB::RMSF4OConfiguration rms_filter_analog_signal;
//
//Zero Drift Filter
//
FLTSYSLIB::FilterForthConfiguration zero_filter;
//
//Cell DC Voltage Filter
//
FLTSYSLIB::FilterForthConfiguration cell_dc_voltage_filter;
//
5 months ago
// Decompose Signal
//
5 months ago
SYSCTRL::SignalDecomposeFIVConfiguration signal_decompose;
#if TYPEVOLTAGEDECOMPOSE == TYPEVOLTAGEDECOMPOSE_SIMPLE
SYSCTRL::SignalDecomposeFIConfiguration voltage_decompose;
#endif
//
// Relative
//
SYSCTRL::SignalRelativeConfiguration relative_voltage_input;
//
// PLL-ABC Voltage
//
FLTSYSLIB::PLLABCDVRConfiguration pll_abc_input_voltage;
//
// ABC-Generator
//
FLTSYSLIB::GeneratorABCConfiguration generator_abc;
//SYSCTRL::GeneratorSymmetricalComponentsConfiguration gen_inp_volt;
//SYSCTRL::GeneratorSymmetricalComponentsConfiguration gen_out_volt;
//SYSCTRL::GeneratorSymmetricalComponentsConfiguration gen_out_current;
//SYSCTRL::GeneratorSymmetricalComponentsConfiguration gen_input_current;
//SYSCTRL::GeneratorSymmetricalComponentsConfiguration gen_bypass_current;
//SYSCTRL::GeneratorSymmetricalComponentsConfiguration gen_cell_current;
//
// Reference PWM-Generator
//
//FLTSYSLIB::GeneratorABCConfiguration generator_pwm;
//
//AlgorithmGenerator
//
SYSCTRL::AlgorithmSourceReference algorithm_source_references;
//
// Harmonica Analyzer
//
FLTSYSLIB::HarmonicaFilter4OrderConfiguration ph_harmonica_5;
//
// Reference Intensity Idref Iqref in Start Mode
//
FLTSYSLIB::FilterSecondConfiguration intensity_id_iq_references;
//
// Regulators
//
#if TYPECONTROL == VECTORCONTROL
FLTSYSLIB::PIControllerConfiguration regulator_voltage_load_dq;
FLTSYSLIB::IntegratorConfiguration integrator_voltage_dq;
FLTSYSLIB::FilterConfiguration reference_voltage_dq_intensity;
FLTSYSLIB::IControllerConfiguration regulator_current_limit;
FLTSYSLIB::PIControllerConfiguration regulator_current_pfc;
#if TYPECURRENTCONTROLLER == CURRENTCONTROLLER_PI
FLTSYSLIB::PIControllerConfiguration regulator_current_load_dq;
#endif
#if TYPECURRENTCONTROLLER == CURRENTCONTROLLER_P
FLTSYSLIB::PControllerConfiguration regulator_current_load_dq;
#endif
FLTSYSLIB::IControllerConfiguration referencer_current_bypass_dq;
#endif
#if TYPECONTROL == SCALARCONTROL
FLTSYSLIB::PIControllerConfiguration regulator_voltage_load_active_reactive;
FLTSYSLIB::PIControllerConfiguration regulator_current_limit;
FLTSYSLIB::PIControllerConfiguration regulator_current_pfc;
FLTSYSLIB::PIControllerConfiguration current_regulator_active;
FLTSYSLIB::PIControllerConfiguration current_regulator_reactive;
FLTSYSLIB::PIControllerConfiguration current_referencer;
FLTSYSLIB::PIControllerConfiguration regulator_dc_voltage;
#endif
#if TYPECONTROL == DIRECTREVERSECONTROL
//
FLTSYSLIB::PIControllerConfiguration drc_voltage_controller;
//
FLTSYSLIB::FilterSecondConfiguration drc_reference_voltage_direct_intensity;
//
FLTSYSLIB::PIControllerConfiguration drc_regulator_current_load;
//
FLTSYSLIB::IControllerConfiguration drc_referencer_current_bypass;
//
FLTSYSLIB::IControllerConfiguration drc_regulator_current_limit;
FLTSYSLIB::PIControllerConfiguration drc_regulator_current_pfc;
//
SYSCTRL::DRCDecomposerConfiguration drc_voltage_decomposer;
#endif
//
// Timers
//
FLTSYSLIB::FTimerConfiguration timer_start;
FLTSYSLIB::FTimerConfiguration timer_stop;
//
// Contactor Fault Control
//
SYSCTRL::ContactorFaultConfiguration contactor;
SystemControlConfiguration():
reference_current_limit_rms(FP_ZERO),
reference_current_pfc_rms(FP_ZERO),
reference_voltage_rms(FP_ZERO),
reference_voltage_high_limit_rms(FP_ZERO),
reference_voltage_dc(FP_ZERO),
hardware(),
//
minimal_input_voltage_level(FP_ZERO),
//
scale_voltage_input_a(1.0),
scale_voltage_input_b(1.0),
scale_voltage_input_c(1.0),
//
scale_current_input_a(1.0),
scale_current_input_b(1.0),
scale_current_input_c(1.0),
//
scale_current_cell_a(1.0),
scale_current_cell_b(1.0),
scale_current_cell_c(1.0),
//
scale_voltage_load_a(1.0),
scale_voltage_load_b(1.0),
scale_voltage_load_c(1.0),
//
scale_current_load_a(1.0),
scale_current_load_b(1.0),
scale_current_load_c(1.0),
//
scale_current_bypass_a(1.0),
scale_current_bypass_b(1.0),
scale_current_bypass_c(1.0),
//
// System Alarm
phase_alert_monitor(),
//
//digital inputs
digital_input_config(), //3001-3020
//
//
//fan control
fan_control(),
//
//
rms_filter_analog_signal(),
signal_decompose(),
5 months ago
#if TYPEVOLTAGEDECOMPOSE == TYPEVOLTAGEDECOMPOSE_SIMPLE
voltage_decompose(),
#endif
pll_abc_input_voltage(),
algorithm_source_references(),
generator_abc(),
//generator_pwm(),
#if TYPECONTROL == VECTORCONTROL
regulator_voltage_load_dq(),
integrator_voltage_dq(),
reference_voltage_dq_intensity(),
regulator_current_limit(),
regulator_current_pfc(),
regulator_current_load_dq(),
referencer_current_bypass_dq(),
#endif
#if TYPECONTROL == SCALARCONTROL
regulator_voltage_load_active_reactive(),
regulator_current_limit(),
regulator_current_pfc(),
current_regulator_active(),
current_regulator_reactive(),
current_referencer(),
regulator_dc_voltage(),
#endif
#if TYPECONTROL == DIRECTREVERSECONTROL
//
drc_voltage_controller(),
//
drc_reference_voltage_direct_intensity(),
//
drc_regulator_current_load(),
//
drc_referencer_current_bypass(),
//
drc_regulator_current_limit(),
drc_regulator_current_pfc(),
//
drc_voltage_decomposer(),
#endif
//
timer_start(),
timer_stop(),
//
contactor()
//
{}
void selfupdata()
{
#if TYPECONTROL == VECTORCONTROL
regulator_current_limit.low_saturation = reference_voltage_rms * 0.57735;
regulator_current_limit.high_saturation = reference_voltage_high_limit_rms * 0.57735;
#endif
#if TYPECONTROL == SCALARCONTROL
regulator_current_limit.high_saturation = reference_voltage_rms * 0.57735;
regulator_current_limit.low_saturation = FP_ZERO;
regulator_current_pfc.high_saturation = reference_voltage_rms * 0.57735;
regulator_current_pfc.low_saturation = -reference_voltage_rms * 0.57735;
regulator_dc_voltage.low_saturation = -reference_voltage_rms * 0.57735;
#endif
#if TYPECONTROL == DIRECTREVERSECONTROL
drc_regulator_current_limit.low_saturation = reference_voltage_rms * 0.57735;
drc_regulator_current_limit.high_saturation = reference_voltage_high_limit_rms * 0.57735;
#endif
//
};
};//end SystemControlConfiguration
} /* namespace SYSCTRL */
#endif /* SYSCTRL_SYSTEMCONFIGURATOR_H_ */