Skip to content
Snippets Groups Projects
Commit ae44969f authored by Christos Gentsos's avatar Christos Gentsos
Browse files

PWM: adjustments for the new fan driver's complementary PWM ctrl

parent c9739288
Branches
No related merge requests found
......@@ -25,15 +25,13 @@ uint16_t currs_lin[3];
uint16_t powrs_lin[3];
uint16_t frpms_lin[3];
const uint16_t total_pwm_clocks_1 = 320;
const uint16_t total_pwm_clocks_2 = 320;
const uint16_t total_pwm_clocks_3 = 320;
#define TOTAL_PWM_CLOCKS 255
uint16_t curr_pwm_duty1000_1 __xMR = 10;
uint16_t curr_pwm_duty1000_2 __xMR = 10;
uint16_t curr_pwm_duty1000_3 __xMR = 10;
#define FAN_RAMPUP 300
#define FAN_RAMPUP 800
uint16_t goal_pwm_duty1000_1 __xMR = FAN_RAMPUP;
uint16_t goal_pwm_duty1000_2 __xMR = FAN_RAMPUP;
......@@ -47,8 +45,8 @@ uint16_t tacho_rpm[3];
// when fan_cmdrpm is 0, setfrpms and temp_curve_points_y represent
// duty cycle (0 to 1000)
uint16_t fan_installed[3] __xMR = {1, 1, 1};
uint16_t fan_cmdrpm[3] __xMR = {1, 1, 0};
uint16_t fan_installed[3] __xMR = {1, 1, 0};
uint16_t fan_cmdrpm[3] __xMR = {0, 0, 0};
uint16_t fan_ppr[3] __xMR = {1, 1, 1}; // a 1 here means 2 pulses per revolution
uint16_t setfrpms[3] __xMR = {1000, 100, 100};
......@@ -73,12 +71,12 @@ float currs[3];
#define ADC_MAX 65535.0
// V[V] = V_adc * scaling_coeff
const float volt_scaling_coeff[3] = {1/(10.0/(90.9+10.0)), 1/(10.0/(20.0+10.0)), 1/(10.0/(10.0+10.0))};
const float curr_scaling_coeff[3] = {1/(10.0/(10.0+10.0)), 1/(10.0/(10.0+10.0)), 1/(10.0/(10.0+10.0))};
const float volt_scaling_coeff[3] = {(10.0+2.0)/2.0, (18.0+10.0)/10.0, (10.0+10.0)/10.0};
const float curr_scaling_coeff[3] = {1/(10.0/(10.0+10.0)), (1.0/10)*(1.0/10), (1.0/10)*(1.0/10)};
// T[degC] = (V_adc + a) * b
const float temp_coeff_a[3] = {-0.6, -0.6, -0.6};
const float temp_coeff_b[3] = {100.0, 100.0, 100.0};
const float temp_coeff_a[3] = {0, -1e-3*100.0*19.0, -1e-3*100.0*19.0};
const float temp_coeff_b[3] = {100.0, 100.0/(1e-3*19.0*(138.5-100.0)), 100.0/(1e-3*19.0*(138.5-100.0))};
uint16_t trig_adc_next_second __xMR = 0;
......@@ -163,9 +161,9 @@ void __xMR update_pwm()
curr_pwm_duty1000_3 = 0;
}
pwm_set_parameters(&PWM_0, total_pwm_clocks_1, total_pwm_clocks_1*(float)(curr_pwm_duty1000_1/1000.0));
pwm_set_parameters(&PWM_1, total_pwm_clocks_2, total_pwm_clocks_2*(float)(curr_pwm_duty1000_2/1000.0));
pwm_set_parameters(&PWM_2, total_pwm_clocks_3, total_pwm_clocks_3*(float)(curr_pwm_duty1000_3/1000.0));
pwm_set_parameters(&PWM_0, TOTAL_PWM_CLOCKS, TOTAL_PWM_CLOCKS*(float)(curr_pwm_duty1000_1/1000.0));
pwm_set_parameters(&PWM_1, TOTAL_PWM_CLOCKS, TOTAL_PWM_CLOCKS*(float)(curr_pwm_duty1000_2/1000.0));
pwm_set_parameters(&PWM_2, TOTAL_PWM_CLOCKS, TOTAL_PWM_CLOCKS*(float)(curr_pwm_duty1000_3/1000.0));
}
void __xMR adc_cb(const struct adc_async_descriptor *const descr, const uint8_t channel)
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment