Part Number: TMS320F28379D
Other Parts Discussed in Thread: C2000WARE
Tool/software: TI C/C++ Compiler
Dear all, good day
Here is my code for the discrert PID
//////////////////////////////////////////////////////////////////////////////////////
v_fonte = AdcaResultRegs.ADCRESULT0;
v_pk = kp*v_fonte;
v_ik = v_ik1 + ki*v_dt*v_fonte;
v_dk = (kd/v_dt)*(v_fonte - v_fonte_1);
v_pid = v_pk + v_ik + v_dk;
DAC_PTR[DAC_NUM]->DACVALS.all = v_pid ;
v_fonte_1 = v_fonte;
v_ik1 = v_ik;
/////////////////////////////////////////////////
As you can see, in order to compute V_IK ad V_DK, I will need V_FONTE_1 & V_IK1 which are the previous values of V_FONTE & V_IK. I attempted to place V_FONTE_1 = V_FONTE as below the DAC_PTR line.
However, V_FONTE_1 and V_IK1 keep the same values as the actual V_FONTE and V_IK values, making V_DK equal to 0.
I would like to know which is the proper writing for kind of operation.
BR,
Christian