This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

UCD3138A: Change PID parameters

Part Number: UCD3138A

About TI demo code:

 configure_new_compensation(volatile FILTER_PMBUS_REGS *source)

volatile struct FILTER_REGS *dest;
 
 if(source == &filter1_pmbus_regs)
 {
  dest = &Filter1Regs;
 }
 else
 {
  dest = &Filter0Regs;
 }

dest->COEFCONFIG.all = 0;

 //Configure bin 1 with the new bin 0 coefficients
 dest->FILTERKPCOEF0.bit.KP_COEF_1  = source->FILTERKPCOEF0.bit.KP_COEF_0;
 dest->FILTERKICOEF0.bit.KI_COEF_1  = source->FILTERKICOEF0.bit.KI_COEF_0;
 dest->FILTERKDCOEF0.bit.KD_COEF_1  = source->FILTERKDCOEF0.bit.KD_COEF_0;
 dest->FILTERKDALPHA.bit.KD_ALPHA_1 = source->FILTERKDALPHA.bit.KD_ALPHA_0;

 //Configure filter to use bin 1 coefficients only
 dest->COEFCONFIG.all = FILTER_CONFIG_BIN1;

 //Configure bin 0 with the new bin 0 coefficients
 dest->FILTERKPCOEF0.bit.KP_COEF_0  = source->FILTERKPCOEF0.bit.KP_COEF_0;
 dest->FILTERKICOEF0.bit.KI_COEF_0  = source->FILTERKICOEF0.bit.KI_COEF_0;
 dest->FILTERKDCOEF0.bit.KD_COEF_0  = source->FILTERKDCOEF0.bit.KD_COEF_0;
 dest->FILTERKDALPHA.bit.KD_ALPHA_0 = source->FILTERKDALPHA.bit.KD_ALPHA_0;

 //Configure filter to use bin 0 coefficients only
 dest->COEFCONFIG.all = 0;

 //Reprogram the remaining filter coefficients
 dest->FILTERKPCOEF0.all = source->FILTERKPCOEF0.all;
 dest->FILTERKPCOEF1.all = source->FILTERKPCOEF1.all;
 dest->FILTERKICOEF0.all = source->FILTERKICOEF0.all;
 dest->FILTERKICOEF1.all = source->FILTERKICOEF1.all;
 dest->FILTERKDCOEF0.all = source->FILTERKDCOEF0.all;
 dest->FILTERKDCOEF1.all = source->FILTERKDCOEF1.all;
 dest->FILTERKDALPHA.all = source->FILTERKDALPHA.all;

 //Configure filter to use bins as defined
 dest->COEFCONFIG.all = source->COEFCONFIG.all;

change old PID parameters to new ones.

 Why first configure " COEFCONFIG.all = 0" then "configure dest->COEFCONFIG.all = source->COEFCONFIG.all? Why used new SETA coefficient  then change to new SETA/B/C coefficients?

why not use "configure dest->COEFCONFIG.all = source->COEFCONFIG.all " directly?  just change new SETA/B/C coefficients  directly from old SETA/B/C coefficients?