Trying to make a VHDL TemperatureController for my “AirFryer”

Right now I am trying to make an AirFryer in my DE2-115 FPGA. The behavior I am trying to achieve is the following:

  • The starting temperature of the AirFryer would be 20ºC when about to be ran.
  • The temperature Sensor would have a variaton of 10ºC/min
  • 1m would translate to 1s IRL.
  • There would be several modes with different default temperatures
    – There would be a User mode that would allow the said User to set his own desired temperature.

Right now I have figured out the “UserMode”. However I am struggling quite hard to make the incrementation of temperature work automatically. These would be showcased in HEX Displays for better readability.

NOTE: I have made all temperature vary always in 10ºC, I thought It wouldnt be needed to adjust 5 by 5.

library IEEE;
use IEEE.STD_LOGIC_1164.all;
use IEEE.NUMERIC_STD.all;

entity TemperatureController is
    Port(
        clk          : in std_logic;
        clkEnable    : in std_logic;
        startingTemp : in std_logic_vector(7 downto 0); -- temperatura do programa selecionado
        enable       : in std_logic;
        run          : in std_logic; -- se está a trabalhar
        estado       : in std_logic;     -- estar aberto ou fechado (a cuba)
        fastCooler   : in std_logic;
        program      : in std_logic_vector(2 downto 0);
        tempUp       : in std_logic;
        tempDown     : in std_logic;
        tempUnits    : out std_logic_vector(3 downto 0);
        tempDozens   : out std_logic_vector(3 downto 0);
        tempHundreds : out std_logic_vector(3 downto 0)
    );
end TemperatureController;

architecture Behavioral of TemperatureController is
    signal tempMin      : INTEGER := 20;
    signal tempMax      : INTEGER := 250;
    signal tempShown    : INTEGER := 0;
    signal tempTarget   : INTEGER := 0;
    signal tempInitialized, runInitialized : std_logic := '0';
begin
    process(clk)
    begin
        if rising_edge(clk) and clkEnable = '1' then
            if enable = '1' then
                if run = '0' then
                    if program = "001" then
                        if tempInitialized = '0' then
                            tempShown <= to_integer(unsigned(startingTemp));
                            tempInitialized <= '1';
                        else
                            -- Verifica a borda de subida de tempUp
                            if tempUp = '1' and tempShown <= tempMax - 10 then
                                tempShown <= tempShown + 10;
                            -- Verifica a borda de subida de tempDown
                            elsif tempDown = '1' and tempShown >= tempMin + 10 then
                                tempShown <= tempShown - 10;
                            end if;
                        end if;
                    end if;
                    -- Redefine a inicialização quando run está desativado
                    runInitialized <= '0';
                else
                    if runInitialized = '0' then
                        tempTarget      <= tempShown;
                        tempShown       <= tempMin;
                        runInitialized  <= '1';
                    elsif tempShown < tempTarget then
                        tempShown <= tempShown + 10;
                        if tempShown >= tempTarget then
                            tempShown <= tempTarget;
                        end if;
                    end if;
                end if;
            end if;
            -- Redefine a inicialização quando enable está desativado
            if enable = '0' then
                tempInitialized <= '0';
            end if;
        end if;
    end process;

    -- Converte a temperatura em dígitos BCD
    process(tempShown)
    begin
        tempHundreds <= std_logic_vector(to_unsigned((tempShown / 100) mod 10, 4));
        tempDozens   <= std_logic_vector(to_unsigned((tempShown / 10) mod 10, 4));
        tempUnits    <= std_logic_vector(to_unsigned(tempShown mod 10, 4));
    end process;
end Behavioral;
library IEEE;
use IEEE.STD_LOGIC_1164.all;
use IEEE.NUMERIC_STD.all;

entity AirFryer is

    -- ON_OFF: SW(0)
    -- RUN: SW(1)
    -- OPEN_OVEN: SW(2)
    -- PROGRAMS: SW(4,5,6)
     -- FAST_COOL: SW(7).
     -- SELECIONAR COOK OU HEAT: SW(8)
    -- TimerUp: Key(0)
    -- TimerDw: Key(1)
    -- TempUp: Key(2)
    -- TemUp: Key(3)
    -- FOOD_IN: LEDG(0)
    -- HALFTIME: LEDG(7...4)
    -- STATUS: LEDR(0,1,2,): IDLE, PreHEAT, COOK, FINISH, COOL
    -- MODO SELECIONADO: LEDR(8)
    -- Temperature Display: HEX0, HEX1 e HEX2 (código BCD)
    -- Time Display: HEX4 e HEX5 (código BCD)
    -- RefClock: CLOCK_50
    port(CLOCK_50    : in  std_logic;
            KEY      : in  std_logic_vector(3 downto 0); 
            SW       : in  std_logic_vector(8 downto 0);
            
            LEDR     : out std_logic_vector(8 downto 0); 
            LEDG     : out std_logic_vector(7 downto 0);
            
            HEX0     : out std_logic_vector(6 downto 0);
            HEX1     : out std_logic_vector(6 downto 0);
            HEX2     : out std_logic_vector(6 downto 0);
            HEX4     : out std_logic_vector(6 downto 0);
            HEX5     : out std_logic_vector(6 downto 0));
end AirFryer;

architecture Demo of AirFryer is 

        signal s_timeUp, s_timeDown, s_tempUp, s_tempDown  : std_logic;
        signal s_temp_Uni, s_temp_Doz, s_temp_Cen          : std_logic_vector(3 downto 0);
          signal s_time_Uni, s_time_Doz                           : std_logic_vector(3 downto 0);
          signal s_1Hz                                                    : std_logic;
          signal s_timeCook, s_timeHeat                           : std_logic_vector(4 downto 0);
          signal s_temp                                              : std_logic_vector(7 downto 0);

begin 
    -- Debouncer for all keys
    keys_debounce   : entity work.DebounceUnits(Behavioral)
    port map(clock          => CLOCK_50,
            timer_up_key    => KEY(0),
            timer_dw_key    => KEY(1),
            temp_up_key     => KEY(2),
            temp_dw_key     => KEY(3),
            timer_up_out    => s_timeUp,
            timer_dw_out    => s_timeDown,
            temp_up_out     => s_tempUp,
            temp_dw_out     => s_tempDown);
                
                
     -- CLOCK DIVIDER
     clkDivider : entity work.ClkDividerN(Behavioral)
    generic map (divFactor => 50_000_000)
    port map (clkIn => CLOCK_50,
              clkOut => s_1Hz);
                  
                  
     -- PROGRAM SELECTOR
     progamSelector : entity work.ProgramSelector(Behavioral)
     port map(clk               => CLOCK_50,
                 input          => SW(6 downto 4),
                  ps_temp       => s_temp,
                  ps_timeCook   => s_timeCook,
                  ps_timeHeat   => s_timeHeat);
                
                
     -- TEMPERATURA
    TemperatureController : entity work.TemperatureController(Behavioral)
    port map(clk            => CLOCK_50,
                 clkEnable       => s_1Hz,
             startingTemp   => "01100100", -- temperatura do programa selecionado
             enable         => SW(0),
             run             => SW(1),
             estado         => '0',      -- estar aberto ou fechado (a cuba)
                 fastCooler      => SW(8),
             program        => "001",
             tempUp         => s_tempUp,
             tempDown       => s_tempDown,
             tempUnits      => s_temp_Uni,
             tempDozens     => s_temp_Doz,
             tempHundreds   => s_temp_Cen);
                 
                 
                 
    -- TEMPO
     TimeController : entity work.TimeController(Behavioral)
    port map(clk            => CLOCK_50,
                 timeHeat        => "00000", -- MUDAR
                 timeCook        => "00000", -- MUDAR
                 
             estado         => '0',    -- estar aberto ou fechado (a cuba)
             program       => "001",
                 heatOrCook     => SW(8),
             timeUp         => s_timeUp,
             timeDown       => s_timeDown,
             enable         => SW(0),
             run             => SW(1),
             timeUnits      => s_time_Uni,
             timeDozens    => s_time_Doz,
                 ledSignal      => LEDR(8));

     -- DISPLAYS CONTROLLER
    DisplaysController : entity work.DisplaysController(Behavioral)
    port map(enable               => SW(0),
              tempUnits       => s_temp_Uni,
             tempDozens      => s_temp_Doz,
             tempHundreds    => s_temp_Cen,
                 
                 timeUnits          => s_time_Uni,
                 timeDozens         => s_time_Doz,
            
             s_HEX0          => HEX0,
             s_HEX1          => HEX1,
             s_HEX2          => HEX2,
             s_HEX4          => HEX4,
             s_HEX5          => HEX5);

end Demo;

I have tried implementing a CounterUpDown which didn’t work either. I ended up getting the error “Can’t resolve multiple constant drivers for net “tempShown[23]””

library IEEE;
use IEEE.STD_LOGIC_1164.all;
use IEEE.NUMERIC_STD.all;

entity CounterUpDownN is
    generic (step : positive := 10);
    port (clk         : in std_logic;
             clkEnable  : in std_logic;
        upDown      : in std_logic;
        startNumber : in INTEGER;
        stopNumber  : in INTEGER;
        count       : out INTEGER);
end CounterUpDownN;

architecture Behavioral of CounterUpDownN is
    signal s_count : INTEGER;
begin
    process(clk)
    begin
        if rising_edge(clk) and clkEnable = '1' then
            if upDown = '0' then
                if s_count - step >= startNumber then
                    s_count <= s_count - step;
                end if;
            else
                if s_count + step <= stopNumber then
                    s_count <= s_count + step;
                end if;
            end if;
        end if;
    end process;
    count <= s_count;
end Behavioral;

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật