library ieee; use ieee.std_logic_1164.all; library APA; entity Stickstoff is port (P1: in std_logic_vector(0 to 4); Wert_AD : in std_logic_vector(0 to 11); S4,S5 : in std_logic_vector (0 to 2); clock, busyadc : in std_logic; LED_OFF,V85,V96L,Latch_Catcher,V97,Pumpe, switch, cs, rd, clockad, convst: out std_logic); signal clock1: std_logic; signal systemzeit,zeitpunkt: integer range 0 to 1000000000; signal Wert_Druck,Wert_Feuchte,Wert_Druck_Vorwahl,Wert_Feuchte_Vorwahl: bit_vector(0 to 11); signal count : integer range 0 to 34; signal count1 : integer range 0 to 1334; end Stickstoff; ------------------------------------------------------------------------------------------------- architecture eins of Stickstoff is -- Stand-By-Prozedur (AUS) procedure AUS is begin V85<='0'; V96L<='0'; Latch_Catcher<='1'; V97<='0'; Pumpe<='0'; end; ------------------------------------------------------------------------------------------------- begin takt: process (clock,clock1,busyadc,wert_ad) is begin if rising_edge(clock) then count1 <= count1+1; if count>=0 and count<=666 then clock1<='0'; elsif count>=666 and count<1333 then clock1<='1'; elsif count>=1333 then count<=0; end if; end if; -- Taktaktivierung für ADC clockad <= clock1; ------------------------------------------------------------------------------------------------- if rising_edge(clock1) then count <= count+1; if count>=0 and count<17 then switch<='0'; convst<='0'; rd<='1'; cs<='1'; elsif count=17 and busyadc<='0' then switch<='0'; convst<='1'; rd<='0'; cs<='0'; Wert_Feuchte <= to_bitvector(Wert_Ad); elsif count>17 and count<34 then switch<='1'; convst<='0'; rd<='1'; cs<='1'; elsif count>=34 and busyadc<='0' then switch<='1'; convst<='1'; rd<='0'; cs<='0'; Wert_Druck <= to_bitvector(Wert_Ad); systemzeit <= systemzeit+1; count<=0; end if; end if; end process; --------------------------------------------------------------------------------------------------------------------- Steuerung: process (P1,S4,S5,systemzeit,zeitpunkt,Wert_druck,Wert_Feuchte) is variable programm: integer range 1 to 5 :=1; variable sequenz: bit :='0'; ------------------------------------------------------------------------------------------------- begin -- Aufnahme Wert Druckvorwahl case S4 is when "001" => Wert_Druck_Vorwahl<="000000000010"; when "010" => Wert_Druck_Vorwahl<="000000000100"; when "011" => Wert_Druck_Vorwahl<="000000001000"; when "100" => Wert_Druck_Vorwahl<="000000010000"; when others => Wert_Druck_Vorwahl<="000000000000"; end case; -- Aufnahme Wert Feuchtevorwahl case S5 is when "001" => Wert_Feuchte_Vorwahl<="000000000010"; when "010" => Wert_Feuchte_Vorwahl<="000000000100"; when "011" => Wert_Feuchte_Vorwahl<="000000001000"; when "100" => Wert_Feuchte_Vorwahl<="000000010000"; when others => Wert_Feuchte_Vorwahl<="111111111111"; end case; ------------------------------------------------------------------------------------------------- if systemzeit <= 3 then programm:=1; AUS; else if P1="00000" then null; elsif P1="10000" then programm:=1; elsif P1="01000" then programm:=2; elsif P1="00100" then programm:=3; elsif P1="00010" then programm:=4; elsif P1="00001" then sequenz:='0'; programm:=5; else programm:=1; end if; if programm=1 then AUS; LED_OFF<='1'; elsif programm=2 then -- Vakuumieren bis Druck auf Wert_Druck_Vorwahl gefallen ist. if Wert_Druck >= Wert_Druck_Vorwahl then V85<='0'; V96L<='0'; Latch_Catcher<='1'; V97<='0'; Pumpe<='1'; else AUS; end if; elsif programm=3 then -- Spülen mit Stickstoff bis 50mbar Überdruck erreicht sind. if Wert_Druck <= "000010000000" then V85<='1'; V96L<='1'; Latch_Catcher<='0'; V97<='1'; Pumpe<='0'; else AUS; end if; elsif programm=4 then -- Druck-Programm, keine Prüfschleifen V85<='1'; V96L<='0'; Latch_Catcher<='0'; V97<='0'; Pumpe<='0'; elsif programm=5 then -- Automatischer Spülablauf if sequenz='0' then if Wert_Druck <= Wert_Druck_Vorwahl then if (systemzeit>=zeitpunkt+1)then sequenz := '1'; else V85<='0'; V96L<='0'; Latch_Catcher<='1'; V97<='0'; Pumpe<='1'; end if; else zeitpunkt <= systemzeit; V85<='0'; V96L<='0'; Latch_Catcher<='1'; V97<='0'; Pumpe<='1'; end if; elsif sequenz='1' then if Wert_Druck>="000010000000" then if (systemzeit >= zeitpunkt+10) then if Wert_Feuchte >= Wert_Feuchte_Vorwahl then sequenz:='0'; else AUS; end if; else AUS; end if; else zeitpunkt <= systemzeit; V85<='1'; V96L<='1'; Latch_Catcher<='0'; V97<='1'; Pumpe<='0'; end if; end if; end if; end if; end process; end eins;