10
UNIVERSIDAD NACIONAL AUTONOMA DE MEXICO FACULTAD DE INGENIERÍA Diseño y construcción de una lavadora automática Practica 12 Laboratorio de Diseño de sistemas digitales Profesora: M.I. Norma Elva Chávez Isabel Fecha de entrega: 12/11/2013

Practica DSD

Embed Size (px)

Citation preview

Page 1: Practica DSD

Universidad nacional autonoma de mexico Facultad de ingeniería

Diseño y construcción de una lavadora automática

Practica 12

Laboratorio de Diseño de sistemas digitalesProfesora: M.I. Norma Elva Chávez

IsabelFecha de entrega:

12/11/2013

Page 2: Practica DSD

Diseño y construcción de una lavadora automática

Objetivo

El alumno comprenderá a diseñar, utilizando el lenguaje VHDL y la plataforma Xilinx, el funcionamiento de una lavadora con ayuda de la herramienta “State Diagram” incluida en la plataforma de desarrollo.

Especificaciones

Se requiere el control de 3 motores, el primero para introducir agua a la lavadora, el segundo es para el lavado de la ropa y por último el succionado del agua.

Diagrama de bloques

Procedimiento

Para este proyecto se utilizó la plataforma ISE de Xilinx y la tarjeta Basys . Se crea en el escritorio una carpeta llamada “Lavadora”.

Abrimos la plataforma ISE, se crea un nuevo proyecto, el cual se guardara como “Lavadora” dentro de la carpeta creada previamente.

Para el correcto funcionamiento con la tarjeta Basys2 se colocará la siguiente configuración:

Page 3: Practica DSD

State diagram

Se crea el siguiente diagrama añadiendo una nueva fuente del tipo “State diagram”.

Código

El código para este diagrama se obtiene dando click en el botón “Generate HDL”

Lavadora

LIBRARY ieee;

Page 4: Practica DSD

USE ieee.std_logic_1164.all;

ENTITY SHELL_LAVADO ISPORT (CLK,RESET: IN std_logic;

L0,L1,L2,L3,L4 : OUT std_logic);END;

ARCHITECTURE BEHAVIOR OF SHELL_LAVADO IS-- State variables for machine sreg

SIGNAL S0, next_S0, S1, next_S1, S2, next_S2, S3, next_S3, S4, next_S4, S5,

next_S5, S6, next_S6, S7, next_S7 : std_logic;SIGNAL L : std_logic_vector (4 DOWNTO 0);

BEGINPROCESS (CLK, RESET, next_S0, next_S1, next_S2, next_S3, next_S4,

next_S5, next_S6, next_S7)

BEGINIF ( RESET='1' ) THEN

S0 <= '1';S1 <= '0';S2 <= '0';S3 <= '0';S4 <= '0';S5 <= '0';S6 <= '0';S7 <= '0';

ELSIF CLK='1' AND CLK'event THENS0 <= next_S0;S1 <= next_S1;S2 <= next_S2;S3 <= next_S3;S4 <= next_S4;S5 <= next_S5;S6 <= next_S6;S7 <= next_S7;

END IF;END PROCESS;

PROCESS (S0,S1,S2,S3,S4,S5,S6,S7,L)BEGIN

IF (( (S7='1'))) THEN next_S0<='1';ELSE next_S0<='0';END IF;

IF (( (S0='1'))) THEN next_S1<='1';ELSE next_S1<='0';END IF;

IF (( (S1='1'))) THEN next_S2<='1';ELSE next_S2<='0';END IF;

Page 5: Practica DSD

IF (( (S2='1'))) THEN next_S3<='1';ELSE next_S3<='0';END IF;

IF (( (S3='1'))) THEN next_S4<='1';ELSE next_S4<='0';END IF;

IF (( (S4='1'))) THEN next_S5<='1';ELSE next_S5<='0';END IF;

IF (( (S5='1'))) THEN next_S6<='1';ELSE next_S6<='0';END IF;

IF (( (S6='1'))) THEN next_S7<='1';ELSE next_S7<='0';END IF;

L<= (( std_logic_vector'( S0, S0, S0, S0, S0)) AND (std_logic_vector'(

"10000") ) ) OR (( std_logic_vector'( S1, S1, S1, S1, S1)) AND (

std_logic_vector'("10000") ) ) OR (( std_logic_vector'( S2, S2, S2, S2, S2)

) AND (std_logic_vector'("01000") ) ) OR (( std_logic_vector'( S3, S3, S3,

S3, S3)) AND (std_logic_vector'("00100") ) ) OR (( std_logic_vector'( S4,

S4, S4, S4, S4)) AND (std_logic_vector'("01000") ) ) OR ((

std_logic_vector'( S5, S5, S5, S5, S5)) AND (std_logic_vector'("00100") ) )

OR (( std_logic_vector'( S6, S6, S6, S6, S6)) AND (std_logic_vector'(

"00011") ) ) OR (( std_logic_vector'( S7, S7, S7, S7, S7)) AND (

std_logic_vector'("00011") ) );

L4 <= L(4);L3 <= L(3);L2 <= L(2);L1 <= L(1);L0 <= L(0);

END PROCESS;END BEHAVIOR;

LIBRARY ieee;USE ieee.std_logic_1164.all;

ENTITY LAVADO ISPORT (L : OUT std_logic_vector (4 DOWNTO 0);

Page 6: Practica DSD

CLK,RESET: IN std_logic);END;

ARCHITECTURE BEHAVIOR OF LAVADO ISCOMPONENT SHELL_LAVADO

PORT (CLK,RESET: IN std_logic;L0,L1,L2,L3,L4 : OUT std_logic);

END COMPONENT;BEGIN

SHELL1_LAVADO : SHELL_LAVADO PORT MAP (CLK=>CLK,RESET=>RESET,L0=>L(0),L1=>L(

1),L2=>L(2),L3=>L(3),L4=>L(4));END BEHAVIOR;

Se crea el símbolo de ”Lavado.vhd”Se copia divisor a la carpeta “Lavadora” y se añade al proyecto. Se abre Divisor.vhd y se modifica quedando como se muestra:

library IEEE;use IEEE.STD_LOGIC_1164.ALL;use IEEE.STD_LOGIC_ARITH.ALL;use IEEE.STD_LOGIC_UNSIGNED.ALL;

---- Uncomment the following library declaration if instantiating---- any Xilinx primitives in this code.--library UNISIM;--use UNISIM.VComponents.all;

entity Divisor is Port ( reloj : in STD_LOGIC;

--rapido: out STD_LOGIC; div : out STD_LOGIC);end Divisor;

architecture Behavioral of Divisor is

beginprocess(reloj)

variable cuenta: std_logic_vector(27 downto 0):=X"0000000";beginif rising_Edge(reloj) then

if cuenta=X"48009E0" thencuenta:=X"0000000";

elsecuenta:=cuenta+1;

end if;div <=cuenta(26);--rapido <=cuenta(10);end if;end process;

Page 7: Practica DSD

end Behavioral;

Se revisa sintaxis y se crea el símbolo de Divisor.vhd y de Lavadora.vhd.

Creamos una nueva fuente llamada Top.sch, donde se conectan los bloques.

Sintetizamos el Top.sch y creamos el área de construcción asignando los pines al reloj, el reset y los leds que simularán el funcionamiento de la lavadora.

Abrimos el archivo Top.bit desde el programa Adept y cargamos y programamos este programa en nuestra tarjeta Basys2.

Funcionamiento

Llenado de agua

Lavado

Page 8: Practica DSD

Succionado de agua

Conclusión

En esta práctica se diseñó una máquina de estados sin el uso de cartas ASM, ya que se aprendió el uso de los “State diagram”. Se obtiene más fácilmente una máquina de estado con este método además de que se tiene un mejor entendimiento ya que se relaciona más fácilmente con lo que se ve en la clase teórica. Se cumplieron satisfactoriamente los objetivos.