• Jueves 28 de Marzo de 2024, 16:25

Autor Tema:  Diseño de PWM  (Leído 1837 veces)

11_8_88

  • Miembro activo
  • **
  • Mensajes: 84
    • Ver Perfil
Diseño de PWM
« en: Miércoles 16 de Febrero de 2011, 13:52 »
0
Hola a todos tengo que modificar el siguiente código para que el PWM se capaz de trabaja al 0% y al 100%,

Citar
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;

entity PWM is
  Port (
    ck      : in  STD_LOGIC;       --clock input
    cmpPwm  : in  STD_LOGIC_VECTOR(7 downto 0);    --switch input
    pwm_out : out STD_LOGIC      --pwm_out output
  );
end PWM;

architecture Behavioral of PWM is

  constant ckPwmRange: integer:= 1;
  -- LSB in the cntPwm alias of cntDiv
  signal cntPwm: unsigned(ckPwmRange+7 downto 0):=(others=>'0');
  -- the superior 8 bits are used for PW Modulator:
  -- cntPwm counts 50MHz/2^ckPwmRange

begin

  PwmCounter: process
  begin
    wait until ck'event and ck='1';
    cntPwm <= cntPwm + 1;
  end process;

  PWM: process(cntPwm, cmpPwm)  -- modulo de logica combinacional
  begin
    if cntPwm(ckPwmRange+7 downto ckPwmRange) <= UNSIGNED(cmpPwm) then
    -- counter value less than reference
      pwm_out <= '1';          -- Output HIGH
    else
    -- counter value greater than reference
      pwm_out <= '0';          -- Output LOW
    end if;
  end process;

end Behavioral;
¿me podría alguien echar una mano?

Muchas gracias.