Skip to content
Snippets Groups Projects
Commit dce31eb4 authored by Luiz Fernando Lavado Villa's avatar Luiz Fernando Lavado Villa :speech_balloon:
Browse files

This commit is a patch to address the issue of the Twist v1.1.2 board whose...

This commit is a patch to address the issue of the Twist v1.1.2 board whose HRTIMA signals have been inverter in routing.

This commit defines a new hardware version, the TWIST_V_1_1_2.
This hardware version is then used to set up the control initialization sequence of the power legs, applying the necessary changest to leg 1 whose timer signals have been reversed in routing.
There is also a correction on the hrtim_init_independent_mode functino that initializes the pwm_phase_shift variable as well as their leg dependent equivalents.
This initalization is necessary to use the hrtim_interleaved_pwm_update function which uses the phase_shift variable when updating the duty cycle of interleaved buck and boost applicaitons.
parent bf77fe57
No related branches found
No related tags found
1 merge request!30This commit is a patch to address the issue of the Twist v1.1.2 board whose...
......@@ -47,6 +47,10 @@
HardwareConfiguration hwConfig;
/////
// Static class members
hardware_version_t HardwareConfiguration::hardware_version = nucleo_G474RE;
/////
// Public static configuration functions
......@@ -63,6 +67,8 @@ HardwareConfiguration hwConfig;
*/
void HardwareConfiguration::setBoardVersion(hardware_version_t hardware_version)
{
HardwareConfiguration::hardware_version = hardware_version;
if (hardware_version == O2_v_1_1_2 || hardware_version == O2_v_0_9)
{
uart_lpuart1_swap_rx_tx();
......@@ -70,7 +76,7 @@ void HardwareConfiguration::setBoardVersion(hardware_version_t hardware_version)
}else if(hardware_version == SPIN_v_0_1){
uart_lpuart1_swap_rx_tx();
hrtim_leg_tu(TIMA, TIMC);
}else if(hardware_version == SPIN_v_0_9){
}else if(hardware_version == SPIN_v_0_9 || hardware_version == TWIST_v_1_1_2){
hrtim_leg_tu(TIMA, TIMC);
}else if(hardware_version == nucleo_G474RE){
hrtim_leg_tu(TIMA, TIMB);
......@@ -140,52 +146,91 @@ uint32_t HardwareConfiguration::getIncrementalEncoderValue()
void HardwareConfiguration::initInterleavedBuckMode()
{
hrtim_init_interleaved_buck_mode();
if(HardwareConfiguration::hardware_version == TWIST_v_1_1_2){
hrtim_init_independent_mode(false, true); //patch for the TWIST v0.9 - the second leg is inverted
}else{
hrtim_init_interleaved_buck_mode();
}
}
void HardwareConfiguration::initInterleavedBuckModeCenterAligned()
{
hrtim_init_interleaved_buck_mode_center_aligned();
if(HardwareConfiguration::hardware_version == TWIST_v_1_1_2){
hrtim_init_independent_mode_center_aligned(false, true); //patch for the TWIST v0.9 - the second leg is inverted
}else{
hrtim_init_interleaved_buck_mode_center_aligned();
}
}
void HardwareConfiguration::initInterleavedBoostMode()
{
hrtim_init_interleaved_boost_mode();
if(HardwareConfiguration::hardware_version == TWIST_v_1_1_2){
hrtim_init_independent_mode(true, false); //patch for the TWIST v0.9 - the second leg is inverted
}else{
hrtim_init_interleaved_boost_mode();
}
}
void HardwareConfiguration::initInterleavedBoostModeCenterAligned()
{
hrtim_init_interleaved_boost_mode_center_aligned();
if(HardwareConfiguration::hardware_version == TWIST_v_1_1_2){
hrtim_init_independent_mode_center_aligned(true, false); //patch for the TWIST v0.9 - the second leg is inverted
}else{
hrtim_init_interleaved_boost_mode_center_aligned();
}
}
void HardwareConfiguration::initFullBridgeBuckMode()
{
hrtim_init_full_bridge_buck_mode();
if(HardwareConfiguration::hardware_version == TWIST_v_1_1_2){
hrtim_init_full_bridge_buck_mode(true); //patch for the TWIST v0.9 - the second leg is inverted
}else{
hrtim_init_full_bridge_buck_mode(false);
}
}
void HardwareConfiguration::initFullBridgeBuckModeCenterAligned(inverter_modulation_t inverter_modulation_type)
{
bool bipolar_mode;
if (inverter_modulation_type == bipolar) bipolar_mode = true; else bipolar_mode = false;
hrtim_init_full_bridge_buck_mode_center_aligned(bipolar_mode);
if(HardwareConfiguration::hardware_version == TWIST_v_1_1_2){
hrtim_init_full_bridge_buck_mode_center_aligned(bipolar_mode,true); //patch for the TWIST v0.9 - the second leg is inverted
}else{
hrtim_init_full_bridge_buck_mode_center_aligned(bipolar_mode,false);
}
}
void HardwareConfiguration::initFullBridgeBoostMode()
{
hrtim_init_interleaved_boost_mode();
if(HardwareConfiguration::hardware_version == TWIST_v_1_1_2){
hrtim_init_independent_mode(true, false); //patch for the TWIST v0.9 - the second leg is inverted
}else{
hrtim_init_interleaved_boost_mode();
}
}
void HardwareConfiguration::initFullBridgeBoostModeCenterAligned()
{
hrtim_init_interleaved_boost_mode_center_aligned();
if(HardwareConfiguration::hardware_version == TWIST_v_1_1_2){
hrtim_init_independent_mode_center_aligned(true, false); //patch for the TWIST v0.9 - the second leg is inverted
}else{
hrtim_init_interleaved_boost_mode_center_aligned();
}
}
void HardwareConfiguration::initIndependentMode(leg_operation_t leg1_operation_type, leg_operation_t leg2_operation_type)
{
bool leg1_mode, leg2_mode;
if (leg1_operation_type == buck) leg1_mode = true; else leg1_mode = false;
if (leg2_operation_type == buck) leg2_mode = true; else leg2_mode = false;
if (HardwareConfiguration::hardware_version == TWIST_v_1_1_2){ //patch for the TWIST v0.9 - the second leg is inverted
if (leg2_operation_type == buck) leg2_mode = false; else leg2_mode = true;
}else{
if (leg2_operation_type == buck) leg2_mode = true; else leg2_mode = false;
}
hrtim_init_independent_mode(leg1_mode, leg2_mode);
}
......@@ -193,7 +238,12 @@ void HardwareConfiguration::initIndependentModeCenterAligned(leg_operation_t leg
{
bool leg1_mode, leg2_mode;
if (leg1_operation_type == buck) leg1_mode = true; else leg1_mode = false;
if (leg2_operation_type == buck) leg2_mode = true; else leg2_mode = false;
if (HardwareConfiguration::hardware_version == TWIST_v_1_1_2){ //patch for the TWIST v0.9 - the second leg is inverted
if (leg2_operation_type == buck) leg2_mode = false; else leg2_mode = true;
}else{
if (leg2_operation_type == buck) leg2_mode = true; else leg2_mode = false;
}
hrtim_init_independent_mode_center_aligned(leg1_mode, leg2_mode);
}
......
......@@ -49,7 +49,8 @@ typedef enum
O2_v_0_9,
O2_v_1_1_2,
SPIN_v_0_1,
SPIN_v_0_9
SPIN_v_0_9,
TWIST_v_1_1_2
} hardware_version_t;
/** Switch leg operation type.
......@@ -145,6 +146,9 @@ public:
static void configureAdcDefaultAllMeasurements();
static void configureAdcDefaultAllMeasurementsAndExtra();
private:
static hardware_version_t hardware_version;
};
......
......@@ -136,6 +136,7 @@ void hrtim_init_independent_mode(bool leg1_buck_mode, bool leg2_buck_mode)
pwm_period = leg_period();
pwm_phase_shift_leg1 = 0;
pwm_phase_shift_leg2 = pwm_period / 2;
pwm_phase_shift = pwm_period/2;
pwm_low_pulse_width = pwm_period * LOW_DUTY;
pwm_high_pulse_width = pwm_period * HIGH_DUTY;
}
......@@ -169,9 +170,13 @@ void hrtim_init_independent_mode_center_aligned(bool leg1_buck_mode, bool leg2_b
/**
* This function initializes both legs in full-bridge mode
*/
void hrtim_init_full_bridge_buck_mode()
void hrtim_init_full_bridge_buck_mode(bool SPIN_board_V_1_1_2)
{
hrtim_init_voltage_buck(leg1_tu, leg1_tu);
if(SPIN_board_V_1_1_2){
hrtim_init_voltage_leg1_buck_leg2_boost(leg1_tu, leg2_tu); //patch for the spin v0.9 - the second leg is inverted
}else{
hrtim_init_voltage_buck(leg1_tu, leg2_tu);
}
full_bridge_bipolar_mode = false; //left-aligned inverter is always on unipolar mode
pwm_period = leg_period();
......@@ -185,9 +190,14 @@ void hrtim_init_full_bridge_buck_mode()
/**
* This function initializes both legs in full-bridge mode
*/
void hrtim_init_full_bridge_buck_mode_center_aligned(bool bipolar_mode)
void hrtim_init_full_bridge_buck_mode_center_aligned(bool bipolar_mode,bool SPIN_board_V_1_1_2)
{
hrtim_init_voltage_buck_center_aligned(leg1_tu, leg2_tu);
if(SPIN_board_V_1_1_2){
hrtim_init_voltage_leg1_buck_leg2_boost_center_aligned(leg1_tu, leg2_tu); //patch for the spin v0.9 - the second leg is inverted
}else{
hrtim_init_voltage_buck_center_aligned(leg1_tu, leg2_tu);
}
full_bridge_bipolar_mode = bipolar_mode;
pwm_period = leg_period();
......
......@@ -62,14 +62,16 @@ void hrtim_init_interleaved_boost_mode();
/**
* @brief This function initializes the converter in full bridge mode
* with the input on the high side and the output on the low side with the HRTIM on left aligned
*/
void hrtim_init_full_bridge_buck_mode();
* @param[in] SPIN_board_V_1_1_2 boolean to treat the case of the spin board V 0.9 -- Patch
*/
void hrtim_init_full_bridge_buck_mode(bool SPIN_board_V_1_1_2);
/**
* @brief This function initializes the converter in full bridge mode
* with the input on the high side and the output on the low side with the HRTIM as center aligned
* @param[in] SPIN_board_V_1_1_2 boolean to treat the case of the spin board V 0.9 -- Patch
*/
void hrtim_init_full_bridge_buck_mode_center_aligned(bool bipolar_mode);
void hrtim_init_full_bridge_buck_mode_center_aligned(bool bipolar_mode, bool SPIN_board_V_1_1_2);
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment