PWM控制电路基本原理与FPGA
process(clk,reset)
begin
if(reset=‘1)then
Qs=“00000000”;
elsif clkevent and clk=‘1 then
Qs=Qs+‘1;
end if;
end process;
reset=‘1 when Qs=255 else
‘0;
caolock=‘1 when Qs=0 else
‘0;
Q=Qs;
cao=reset or caolock;
end a_counter;
在原理图中,延迟模块必不可少,其功能是对PWM波形的上升沿进行延时,而不影响下降沿,从而确保桥路同侧不会发生短路.其模块的VHDL程序如下:
entity delay is
port(clk: in std_logic;
input: in std_logic_vector(1 downto 0);
output:out std_logic_vector(1 downto 0)
end delay;
architecture a_delay of delay is
signal Q1,Q2,Q3,Q4: std_logic;
begin
process(clk)
begin
if clkevent and clk=‘1 then
Q3=Q2;
Q2=Q1;
Q1=input(1);
end if;
end process;
Q4=not Q3;
output(1)=input(1)and Q3;
output(0)=input(0)and Q4;
end a_delay;
3 结束语
采用可编程逻辑器件和硬件描述语言,同时利用其供应商提供的开发工具可大大缩短数字系统的设计时间,节约新产品的开发成本,另外,还具有设计灵活,集成度高,可靠性好,抗干能力强等特点.本文设计的PWM控制电路用于某光测设备的传动装置时,取得了良好的效果.
pwm相关文章:pwm原理
评论