library ieee,synplify; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; library APA; entity steuerplatine is port (P1: in std_logic_vector(0 to 5); --Eingang // Programmauswahltaster Wert_AD : in std_logic_vector(0 to 11); --Eingang // Digitalwerte des A/D Wandlers S4, S5 : in std_logic_vector(0 to 2); --Eingang // Vorwahlwerte Druck und Feuchte clock : in std_logic; --Eingänge // Systemtakt busyadc, show_temperature, reset_in : in bit; --Eingänge // Busysignal ADC, Temperaturumschaltung,Reset LED_OFF, LED_VAK, LED_DRUCK, LED_SPUEL, LED_AUTO, LED_PRUEF: out std_logic; --Ausgänge // LED Steuerung Zustand : out std_logic_vector(3 downto 0); --Ausgänge Zustandsanzeige(Debugging und Inbetriebnahme) clockad_out, switch, switch2, convst, rd, cs, V85, V96L, V97, Pumpe: out std_logic); --Ausgänge // A/D Takt, Umschaltsignale Druck,Feuchte,Temperatur, Steuersignale A/D Wandler, Ventilsteuerung end steuerplatine; architecture behavior of steuerplatine is --interne Signale zur Prozessübergreifenden Kommunikation und Programmsteuerung Signal Wert_Feuchte,Wert_Druck,Wert_Druck_Vorwahl,Wert_Feuchte_Vorwahl : bit_vector(0 to 11); Signal state_ADC : integer range 1 to 15; Signal state_automatik : integer range 1 to 8; Signal timeout,timeout2,timeout3,timeout4 : integer range 0 to 30; Signal delay,delay2 : integer range 0 to 5; Signal programm : integer range 1 to 6; begin --Beginn der Anweisungen innerhalb der Architecture AD: process (clock,wert_ad,reset_in) begin --Taktausgabe für A/D Wandler clockad_out <= clock; if rising_edge(clock) then --Reset_IN // Low active // hardwaregesteurt durch Spannungswächter auf Platine if reset_in='0' then state_ADC <= 1; convst <='1'; rd <='1'; cs <='1'; switch <='0'; end if; --state machine zur Steuerung des Auslesens des A/D Wandlers und der --Speicherung der ausgelesenen Werte in einem Bitvektor case state_ADC is --Anfangszustand when 1 => Zustand <= "0001"; convst <= '1'; rd <= '1'; cs <= '1'; switch <= '0'; state_ADC <= 2; --Start AD Wandlung durch convst <='0' when 2 => Zustand <= "0010"; convst <= '0'; rd <= '1'; cs <= '1'; timeout <= 30; --Zählvariable falls bei Einschaltvorgang in when3 gesprungen wird switch <= '0'; --bzw. im Zustand 3 kein BusyADC high kommt state_ADC <= 3; --Warten auf busyadc high, wenn 'high' Wandlung gestartet when 3 => Zustand <= "0011"; timeout2 <= 30; --Zählvariable falls bei Einschaltvorgang in when4 gesprungen wird if busyadc ='1' then --bzw. kein BusyADC low kommt convst <= '1'; rd <= '1'; cs <= '1'; switch <= '0'; state_ADC <= 4; else timeout <= timeout-1; if timeout = 0 then state_ADC <= 1; end if; end if; --Warten auf busyadc low, wenn 'low' A/D Wandlung beendet, Daten stehen am Ausgang des --A/D Wandlers an when 4 => Zustand <= "0100"; timeout <= 0; if busyadc ='0' then convst <= '1'; cs <= '0'; rd <= '0'; switch <= '0'; delay <= 5; --Zählvariable, zur doppelten Absicherung, dass wirklich state_ADC <= 5; --die aktuellen Daten am Ausgang des A/D W. anstehen else timeout2 <= timeout2-1; if timeout2 = 0 then state_ADC <= 1; end if; end if; --Daten von AD Wandler lesen // Wert Feuchte, darf nur gelesen werden, wenn Taster Temperturanzeige --(show_temperature) nicht betätigt ist, da sonst der Wert der Temperatur ausgegeben wird when 5 => Zustand <= "0101"; timeout2 <= 0; convst <= '1'; cs <= '0'; rd <= '0'; switch <= '0'; delay <= delay-1; if delay =0 and show_temperature='1' then Wert_Feuchte <= to_bitvector(Wert_AD); Zustand <= "1100"; end if; state_ADC <= 11; --erneuter Ausgangszustand when 11 => Zustand <= "0110"; convst <= '1'; rd <= '1'; cs <= '1'; switch <= '1'; state_ADC <= 12; --Start AD Wandlung durch convst <='0' (nun für den Wert Druck) when 12 => Zustand <= "0111"; convst <= '0'; rd <= '1'; cs <= '1'; timeout3 <= 30; --Zählvariable falls bei Einschaltvorgang in when13 gesprungen wird switch <= '1'; --bzw. kein BusyADC high in Zustand 13 kommt state_ADC <= 13; --Warten auf busyadc high, wenn 'high' neue Wandlung gestartet when 13 => Zustand <= "1000"; timeout4 <= 30; --Zählvariable falls bei Einschaltvorgang in when 14 gesprungen wird if busyadc ='1' then --bzw. kein BusyADC low in Zustand 14 kommt convst <= '1'; rd <= '1'; cs <= '1'; switch <= '1'; state_ADC <= 14; else timeout3 <= timeout3-1; if timeout3 =0 then state_ADC <= 1; end if; end if; --Warten auf busyadc low, wenn 'low' A/D Wandlung beendet, Daten stehen am Ausgang --des A/D Wandlers an when 14 => Zustand <= "1001"; timeout3 <= 0; if busyadc ='0' then convst <= '1'; cs <= '0'; rd <= '0'; switch <= '1'; delay2 <= 5; --Zählvariable, zur doppelten Absicherung, dass wirklich state_ADC <= 15; --die aktuellen Daten am Ausgang des A/D W. anstehen else timeout4 <= timeout4-1; if timeout4 =0 then state_ADC <= 1; end if; end if; --Daten von AD Wandler lesen // Danach Rücksprung in Zustand 1 // neuer Ausleseprozess when 15 => Zustand <= "1010"; timeout4 <= 0; convst <= '1'; cs <= '0'; rd <= '0'; switch <= '1'; delay2 <= delay2-1; if delay2 = 0 and show_temperature='0' then Wert_Druck <= to_bitvector(Wert_AD); Zustand <= "1011"; end if; state_ADC <= 1; when others => Zustand <= "1111"; state_ADC <= 1; end case; --case state adc end if;--reset_in='0' end process AD; -------------------------------------------------------------------------- end behavior;