neilmallia
Technical User
Hi,
I am trying to implement an integrator but when it is reaching the maximum it is not saturating but resetting and starting again from 0.
Here is the part of the code which is relevant:
INTEGRATION := INTEGRATOR + T_DIFF + (T_DIFF & "000000000") - (T_DIFFPRE & "000000000");
IF INTEGRATION >= "0000000011111111111111111111111111" then
INTEGRATOR := "11111111111111111111111";
ELSE
INTEGRATOR := INTEGRATION(22 DOWNTO 0);
END IF;
T_DIFF is an 8bit constant
T_DIFF_PRE is an 8bit constant
INTEGRATION is a 31 bit variable
INTEGRATOR is a 23 bit variable
I don't know what I'm doing wrong but I think when INTEGRATION reaches "0000000011111111111111111111111111" INTEGRATOR should be kept at "11111111111111111111111" and it will stay like this.
Any ideas on whats happening?
Thanks
I am trying to implement an integrator but when it is reaching the maximum it is not saturating but resetting and starting again from 0.
Here is the part of the code which is relevant:
INTEGRATION := INTEGRATOR + T_DIFF + (T_DIFF & "000000000") - (T_DIFFPRE & "000000000");
IF INTEGRATION >= "0000000011111111111111111111111111" then
INTEGRATOR := "11111111111111111111111";
ELSE
INTEGRATOR := INTEGRATION(22 DOWNTO 0);
END IF;
T_DIFF is an 8bit constant
T_DIFF_PRE is an 8bit constant
INTEGRATION is a 31 bit variable
INTEGRATOR is a 23 bit variable
I don't know what I'm doing wrong but I think when INTEGRATION reaches "0000000011111111111111111111111111" INTEGRATOR should be kept at "11111111111111111111111" and it will stay like this.
Any ideas on whats happening?
Thanks