I am unable solve the error 10500.

Thread Starter

Zawar1214

Joined Apr 2, 2024
1
Code:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
Use IEEE.STD_LOGIC_ARITH .ALL;
Use IEEE.STD_LOGIC_UNSIGNED.ALL;


entity FOPID_Controller is
port (
     clk : in std_logic;
     Reset : in std_logic;
     speed_ref : in std_logic_vector(31 downto 0);
     speed : in std_logic_vector(31 downto 0);
     output : out std_logic_vector(31 downto 0)
     );
     end FOPID_Controller;

architecture behavioral of FOPID_Controller is 
constant Kp : real := 2.050; -- Proportional gain
  constant Ki : real := 3.756; -- Integral gain
  constant Kd : real := -0.078; -- Derivative gain
  constant lambda : real := 0.98; -- Fractional-order integrator exponent

 signal error : signed(31 downto 0);
  signal integrator : signed(31 downto 0); -- Increased width for overflow prevention
  signal differentiator : signed(31 downto 0);
  signal fractional_integrator : signed(31 downto 0);
  
begin
  -- Error calculation
  process (clk, reset)
  begin
    if reset then
      error <= (others => '0');
    else
      error <= speed_ref - speed;
    end if;
  end process;
  
  -- Integral term (with overflow prevention)
  process (clk, reset)
  begin
    if reset then
      integrator <= (others => '0');
    else
      integrator <= integrator + (Ki * error);
      if integrator > (2**63 - 1) then
        integrator <= (2**63 - 1);
      elsif integrator < 0 then
        integrator <= 0;
      end if;
    end if;
  end process;
  
  -- Fractional-order integrator using a power series approximation
  process (clk, reset)
  begin
    if reset then
      fractional_integrator <= (others => '0');
    else
      fractional_integrator <= fractional_integrator + ((Ki * error * clk'event and clk = '1') * ((error)**lambda));
      if fractional_integrator > (2**63 - 1) then
        fractional_integrator <= (2**63 - 1);
      elsif fractional_integrator < 0 then
        fractional_integrator <= 0;
      end if;
    end if;
  end process;
  
  -- Derivative term
  process (clk, reset)
  begin
    if reset then
      differentiator <= (others => '0');
    else
      differentiator <= Kd * (error - (error >> 1)); -- Simple approximation
    end if;
  end process;
  
  -- Controller output (PWM duty cycle)
  pwm_duty <=  to_unsigned((Kp * error) + (to_signed(fractional_integrator >> 32)) + integrator + differentiator, 8);
  
end architecture rtl;
 
Last edited by a moderator:

WBahn

Joined Mar 31, 2012
30,236
Help us help you by providing as much relevant information as you can.

It appears that you are writing VHDL code, but it would be nice if you actually mentioned that? What flavor of VHDL? What IDE are you using? It may also be helpful to give some information about what device the code is targeting and what the code is supposed to be doing.

You are assuming that everyone knows what error 10500 is. Not only are error codes generally IDE specific, but even if they aren't, don't make people that you are asking for free help from have to go and track down that information. Most will simply move on to someone else's post. Instead, provide as much information about that error as you can. A lot of that information is probably provided to you by the IDE in the form of an error message staring you in the face, so at least include that message. But, if necessary, you need to do some legwork to track down some information about what that particular error means -- you may well find that just doing that provides you with enough information to solve your own problem. It would also help to know when and how this error is thrown -- is it a compile-time error, or a simulation-time error, or a synthesis-time error. or what? What information does the tool give you about where the error might be located?

If you have been doing decent code development, this error popped up after a small amount of new code was added to the previous version. What code was added since the last time this error wasn't being thrown? Or, let me guess, you wrote all of this code before even attempting to run it in any way, hoping that it would somehow just happen to work on the first attempt and, now that it hasn't, you are overwhelmed by the thought of trying to actually track the error down.

It would also be very helpful to explain what steps you have already taken to find the error, or at least narrow down where it might be.

Next, it really helps people work with your code if it is well presented, in particular if the indenting matches the logical structure of the code. You can do this by enclosing your code between [code] and [/code] tags.
 
Top