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.

305 lines
10 KiB
C

/*
* SystemDefinitions.h
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include <math.h>
#include <stdint.h>
#ifndef SYSCTRL_SYSTEMDEFINITIONS_H_
#define SYSCTRL_SYSTEMDEFINITIONS_H_
namespace SYSCTRL
{
struct Register16BitField
{
uint16_t b00: 1;
uint16_t b01: 1;
uint16_t b02: 1;
uint16_t b03: 1;
uint16_t b04: 1;
uint16_t b05: 1;
uint16_t b06: 1;
uint16_t b07: 1;
uint16_t b08: 1;
uint16_t b09: 1;
uint16_t b10: 1;
uint16_t b11: 1;
uint16_t b12: 1;
uint16_t b13: 1;
uint16_t b14: 1;
uint16_t b15: 1;
};//Register16BitField
struct Register16ByteField
{
uint16_t bt0 :8;
uint16_t bt1 :8;
};//Register16ByteField
struct Register16WordField
{
uint16_t wL :16;
};//Register16WordField
union Register16
{
uint16_t all;
Register16BitField bit;
Register16ByteField byte;
};//Register16
struct Register32BitField
{
uint16_t b00: 1;
uint16_t b01: 1;
uint16_t b02: 1;
uint16_t b03: 1;
uint16_t b04: 1;
uint16_t b05: 1;
uint16_t b06: 1;
uint16_t b07: 1;
uint16_t b08: 1;
uint16_t b09: 1;
uint16_t b10: 1;
uint16_t b11: 1;
uint16_t b12: 1;
uint16_t b13: 1;
uint16_t b14: 1;
uint16_t b15: 1;
uint16_t b16: 1;
uint16_t b17: 1;
uint16_t b18: 1;
uint16_t b19: 1;
uint16_t b20: 1;
uint16_t b21: 1;
uint16_t b22: 1;
uint16_t b23: 1;
uint16_t b24: 1;
uint16_t b25: 1;
uint16_t b26: 1;
uint16_t b27: 1;
uint16_t b28: 1;
uint16_t b29: 1;
uint16_t b30: 1;
uint16_t b31: 1;
};//Register32BitField
struct Register32ByteField
{
uint16_t bt0 :8;
uint16_t bt1 :8;
uint16_t bt2 :8;
uint16_t bt3 :8;
};//Register32ByteField
struct Register32WordField
{
uint16_t wL :16;
uint16_t wH :16;
};//Register32WordField
union Register32
{
uint32_t all;
Register32BitField bit;
Register32ByteField byte;
Register32WordField word;
};//Register32
struct BoolRegisterBitField
{
uint16_t b0 :1;
};//BoolRegisterBitField
union BoolRegister
{
uint16_t all;
BoolRegisterBitField boolbit;
BoolRegister():
all(0)
{}
};//BoolRegister
#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_HIGH_LIMIT (float)(6600.0)
#define CELL_DC_VOLTAGE_REFERENCE (float)(5.0*950.0)
#define REGULATOR_CURRENT_LIMIT_LOW_SATURATION (float)(GRID_VOLTAGE_REFERENCE * 0.57735)
#define REGULATOR_CURRENT_LIMIT_HIGH_SATURATION (float)(GRID_VOLTAGE_HIGH_LIMIT * 0.57735)
#define REGULATOR_CURRENT_PFC_HIGH_SATURATION (float)(GRID_VOLTAGE_REFERENCE * 0.57735)
#define REGULATOR_CURRENT_PFC_LOW_SATURATION (float)((-1.0)*GRID_VOLTAGE_REFERENCE * 0.57735)
#define CONTROL_BIT_ENABLE_CURRENT_LIMIT (uint16_t)(0x0001)
#define CONTROL_BIT_ENABLE_PFC (uint16_t)(0x0002)
#define CONTROL_BIT_ENABLE_HARMONICA (uint16_t)(0x0004)
#define CONTROL_BIT_ENABLE_AUTO_OFFSET (uint16_t)(0x0008)
#define ENABLE_CONTROL_BIT (uint16_t)(\
CONTROL_BIT_ENABLE_CURRENT_LIMIT |\
CONTROL_BIT_ENABLE_PFC |\
CONTROL_BIT_ENABLE_AUTO_OFFSET \
)
// CONTROL_BIT_ENABLE_CURRENT_LIMIT |\//
// CONTROL_BIT_ENABLE_PFC |\//
//
// Voltage PLL-ABC Parameters
//
#define PLLABC_FREQUENCY_NOMINAL (float)(2.0*FP_PI*50.0)
#define PLLABC_FREQUENCY_CUT (float)(2.0*FP_PI*10.0)
#define PLLABC_FREQUENCY_LIMIT_HI PLLABC_FREQUENCY_CUT
#define PLLABC_FREQUENCY_LIMIT_LOW -PLLABC_FREQUENCY_CUT
/*
struct EquipmentFaultsBitFieldStructure
{
uint16_t remote_e_stop : 1; //0
uint16_t local_e_stop : 1; //1
uint16_t fan : 1; //2
uint16_t cells : 1; //3
//
uint16_t temperature_transformer_multi_winding : 1; //4
uint16_t temperature_transformer_phase_a : 1; //5
uint16_t temperature_transformer_phase_b : 1; //6
uint16_t temperature_transformer_phase_c : 1; //7
//
uint16_t cabinet_door_open : 1; //8
uint16_t reserved_09 : 1; //9
uint16_t reserved_10 : 1; //10
uint16_t reserved_11 : 1; //11
//
uint16_t reserved_12 : 1; //12
uint16_t reserved_13 : 1; //13
uint16_t reserved_14 : 1; //14
uint16_t reserved_15 : 1; //15
};//EquipmentFaultsBitFieldStructure
*/
#define REMOTE_E_STOP 0//0x0001
#define LOCAL_E_STOP 0//0x0002
#define FAN 0//0x0004
#define CELLS 0//0x0008
#define TEMPERATURE_TRANSFORMER_MULTI_WINDINGS 0//0x0010
#define TEMPERATURE_TRANSFORMER_PHASE_A 0//0x0020
#define TEMPERATURE_TRANSFORMER_PHASE_B 0//0x0040
#define TEMPERATURE_TRANSFORMER_PHASE_C 0//0x0080
#define CABINET_DOOR_OPEN 0x0100
#define ENABLE_EQUIPMENT_RESTART 0x0100
/*
#define ENABLE_EQUIPMENT_RESTART (uint16_t)(\
REMOTE_E_STOP |\
LOCAL_E_STOP |\
FAN |\
CELLS |\
TEMPERATURE_TRANSFORMER_MULTI_WINDINGS |\
TEMPERATURE_TRANSFORMER_PHASE_A |\
TEMPERATURE_TRANSFORMER_PHASE_B |\
TEMPERATURE_TRANSFORMER_PHASE_C |\
CABINET_DOOR_OPEN \
)
*/
/*
struct PhaseFaultBit
{
uint16_t exceed_voltage_level_3 :1; // 0
uint16_t exceed_voltage_level_4 :1; // 1
uint16_t decrease_voltage_level_3 :1; // 2
uint16_t phase_lost :1; // 3
//
uint16_t short_circuit :1; // 4
uint16_t high_current :1; // 5
uint16_t overload_current_level_1 :1; // 6
uint16_t overload_current_level_2 :1; // 7
//
uint16_t overload_current_level_3 :1; // 8
uint16_t overload_invertor_current_level_1 :1; // 9
uint16_t overload_invertor_current_level_2 :1; // 10
uint16_t overload_invertor_current_level_3 :1; // 11
//
uint16_t reserved_12 :1; // 12
uint16_t reserved_13 :1; // 13
uint16_t reserved_14 :1; // 14
uint16_t reserved_15 :1; // 15
};//PhaseFaultBit
*/
#define EXCEED_VOLTAGE_LEVEL_3 (uint16_t)0x0001
#define EXCEED_VOLTAGE_LEVEL_4 (uint16_t)0x0002
#define DECREASE_VOLTAGE_LEVEL_3 (uint16_t)0x0004
#define LOST_PHASE (uint16_t)0x0008
#define SHORT_CIRCUIT (uint16_t)0x0010
#define HIGH_CURRENT (uint16_t)0x0020
#define OVERLOAD_CURRENT_LEVEL_1 (uint16_t)0x0040
#define OVERLOAD_CURRENT_LEVEL_2 (uint16_t)0x0080
#define OVERLOAD_CURRENT_LEVEL_3 (uint16_t)0x0100
#define OVERLOAD_INVERTOR_CURRENT_LEVEL_1 (uint16_t)0x0200
#define OVERLOAD_INVERTOR_CURRENT_LEVEL_2 (uint16_t)0x0400
#define OVERLOAD_INVERTOR_CURRENT_LEVEL_3 (uint16_t)0x0800
#define ENABLE_PHASE_RESTART 0
/*
#define ENABLE_PHASE_RESTART (uint16_t)(\
EXCEED_VOLTAGE_LEVEL_3 |\
EXCEED_VOLTAGE_LEVEL_4 |\
DECREASE_VOLTAGE_LEVEL_3 |\
LOST_PHASE |\
SHORT_CIRCUIT |\
HIGH_CURRENT |\
OVERLOAD_CURRENT_LEVEL_1 |\
OVERLOAD_CURRENT_LEVEL_2 |\
OVERLOAD_CURRENT_LEVEL_3 |\
OVERLOAD_INVERTOR_CURRENT_LEVEL_1 |\
OVERLOAD_INVERTOR_CURRENT_LEVEL_2 |\
OVERLOAD_INVERTOR_CURRENT_LEVEL_3 \
)
*/
#define NOMINAL_GRID_VOLTAGE (float)6000.0
#define PROTECTION_EXCEED_VOLTAGE_LEVEL_1_PERCENT (float)35.0 // 10.0 was changed to 35.0
#define PROTECTION_EXCEED_VOLTAGE_LEVEL_2_PERCENT (float)35.0 // 15.0 was changed to 35.0
#define PROTECTION_EXCEED_VOLTAGE_LEVEL_3_PERCENT (float)35.0 // 25.0 was changed to 35.0
#define PROTECTION_EXCEED_VOLTAGE_LEVEL_4_PERCENT (float)20.0 // 50.0 was changed to 20.0
#define PROTECTION_DECREASE_VOLTAGE_LEVEL_1_PERCENT (float)15.0
#define PROTECTION_DECREASE_VOLTAGE_LEVEL_2_PERCENT (float)25.0
#define PROTECTION_DECREASE_VOLTAGE_LEVEL_3_PERCENT (float)40.0 // 35.0 was changed to 40.0
} /* namespace SYSCTRL */
#endif /* SYSCTRL_SYSTEMDEFINITIONS_H_ */