Lots of refactoring
This commit is contained in:
@@ -17,7 +17,6 @@
|
||||
#include "pwm.h"
|
||||
#include "amps.h"
|
||||
#include "frq.h"
|
||||
#include "measure.h"
|
||||
#include "adc.h"
|
||||
#include "init.h"
|
||||
#include "utils.h"
|
||||
@@ -25,10 +24,13 @@
|
||||
#include "timer.h"
|
||||
#include "sys_chk.h"
|
||||
#include "battery.h"
|
||||
#include "System/system.h"
|
||||
|
||||
extern float32_t Watts;
|
||||
extern uint8_t frequency,Test_Mode,catch_up_flag;
|
||||
extern ADC_t adc;
|
||||
extern float32_t Milli_amps;
|
||||
extern SYSTEM_DATA_t sys;
|
||||
|
||||
uint16_t Old_Pot_Val;
|
||||
uint8_t Power_Level,Bcast_Pwr_Level;
|
||||
float Requested_Current_Lith[5] = {10.0/1000,50.0/1000.0,150.0/1000.0,400.0/1000.0,1000.0/1000.0}; // Requested Current Output Value
|
||||
@@ -111,8 +113,8 @@ void doClampPower(void)
|
||||
float power = 0.0f;
|
||||
bool update = true;
|
||||
|
||||
clampData.voltage = adc.V_OUT_FastFilt;
|
||||
clampData.current = adc.I_OUT_FastFilt;
|
||||
clampData.voltage = sys.adc.V_OUT_FastFilt;
|
||||
clampData.current = sys.adc.I_OUT_FastFilt;
|
||||
power = clampData.voltage * clampData.current;
|
||||
|
||||
if (power > clampData.maxPower)
|
||||
@@ -365,6 +367,17 @@ uint8_t BC_Duty_val;
|
||||
return(BC_Duty_val);
|
||||
}
|
||||
|
||||
float Calc_Max_current(void)
|
||||
{
|
||||
float a;
|
||||
if(freqArray[frequency].frequency1 <= MAX_DTYPE)
|
||||
a = sqrtf(sys.maxPowerLimit / sys.adc.Ohms_slowfilt);
|
||||
else
|
||||
a = sqrtf(1/sys.adc.Ohms_slowfilt);
|
||||
|
||||
return(a);
|
||||
|
||||
}
|
||||
|
||||
void Request_Current_Change(void)
|
||||
{
|
||||
@@ -382,7 +395,7 @@ void Request_Current_Change(void)
|
||||
Current_Request = Max_Current_Allowed; //make it comply}
|
||||
|
||||
Old_Pot_Val = Dds_Pot_Val[1];
|
||||
new_pot_val = (Current_Request /adc.I_OUT_SlowFilt) * Dds_Pot_Val[1]; // Request divided by Pot current contents
|
||||
new_pot_val = (Current_Request /sys.adc.I_OUT_SlowFilt) * Dds_Pot_Val[1]; // Request divided by Pot current contents
|
||||
|
||||
if(new_pot_val < 3)
|
||||
new_pot_val = 3;
|
||||
@@ -561,12 +574,12 @@ void Check_New_Pot_Volts()
|
||||
{
|
||||
float32_t V_Calc; // Currently set value is Old_Pot requested value is Pot_Val[]
|
||||
|
||||
if(adc.V_OUT_SlowFilt > 0.0)
|
||||
if(sys.adc.V_OUT_SlowFilt > 0.0)
|
||||
{
|
||||
V_Calc = (adc.V_OUT_FastFilt / Old_Pot_Val);
|
||||
V_Calc = (sys.adc.V_OUT_FastFilt / Old_Pot_Val);
|
||||
|
||||
if(V_Calc * Dds_Pot_Val[1] > 90.0)
|
||||
Dds_Pot_Val[1] = MAX_DC_VOLTAGE / adc.V_OUT_FastFilt * Old_Pot_Val;
|
||||
Dds_Pot_Val[1] = MAX_DC_VOLTAGE / sys.adc.V_OUT_FastFilt * Old_Pot_Val;
|
||||
|
||||
if(Dds_Pot_Val[1] > freqArray[frequency].max_pot)
|
||||
Dds_Pot_Val[1] = freqArray[frequency].max_pot;
|
||||
|
||||
Reference in New Issue
Block a user