hi there, i'm doing a fan controler for my pc, and i'm having some problems smoothing the fans' acceleration.
this is what i've so far, for the linear acceleration
"int16_t dc" is actualy a uint8_t but used int16_t there to save 1 byte.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
void PWM_setdc_lineal(int16_t dc, uint8_t ch_sel)
{
PWM_dc_rotation(&dc, ch_sel); // rotates the rect's angle
PMW_adc_adj(&dc, ch_sel); // stretchs to the min and max values, doesn't matter
// proble here, i've tried lots of methods but this is the best so far.
// calculate the diference between the current DC(OCR2) and value read
// from the ADC, filtered and adjusted previously, then divide them by
// the SMOOTH level and then subtract the value to the float version of
// OCR2....then crop....then round() and set to the hardware register
PWM_DCC[ch_sel] -= (float)(OCR2-dc)/(float)PWM_SMOOTH_LVL[ch_sel];
PMW_dcc_adj(PWM_DCC, ch_sel); //crops the value to be between min and max
PWM_set_dc(PWM_DCC, ch_sel); //set +duty cycle percentage
}
|
the problem is that it isn't that linear, and when the diference is small it starts to slow down, if i hadn't used round it would never reach to the value as that is the limit of the ecuation and since it rounds to the lower value by default it would always be 1 less.
it's exactly the same slope of the capasitors' charge time.
using an array to average isn't posible as it would use up to 255 bytes and till now i have only 446bytes of ram left, and i need two values to be controled and smoothed.
any suggestion?
thanks in advance, Laharl