|
主板有两块芯片组成,主芯片为STM32公司的ARM系列,功能:主控制程序,比如发送脉冲,正转翻转,加减速等,从芯片为XILINX公司的CPLD型号为XC9572XL,经硬件形成3路信号PA,PB,PC进入CPLD,然后分6路输出,AH,AL,BH,BL,CH,CL到驱动板,即可控制电机运转。
我把CPLD这块的程序贴上,有做过步进控制器的给分析分析,不吝指教,先谢了! 目前的情况为电机可以转动,但在突然加减速的时候会出现丢步。
不知道有没有人用过或者做过KND步进电机控制器,原理同。
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity pwm_2 is
port(clock,pa,pb,pc : in std_logic;
c39 : in std_logic;
c37 : out std_logic;
ah,al,bh,bl,ch,cl : out std_logic);
end;
architecture dianji of pwm_2 is
signal q1 : std_logic_vector(7 downto 0) := "00000000";--死区发生器8位
signal q2 : std_logic_vector(7 downto 0) := "00000000";--
signal q3 : std_logic_vector(7 downto 0) := "00000000";--
signal dead_time : std_logic_vector(7 downto 0):= "00101101";--死区寄存器,死区时间3us45
begin
process(clock)
begin
if (clock'event and clock = '1') then
if ((pa = '1') and (q1 /=dead_time)) then
q1 <= q1 + 1;
elsif ((pa = '0') and (q1 /= "00000000")) then
q1 <= q1 - 1;
end if;
if ((pa = '1') and (q1 = dead_time)) then --上桥臂导通
ah <= '1';
else
ah <= '0';
end if;
if ((pa = '0') and (q1 ="00000000")) then --下桥臂导通
al <= '1';
else
al <= '0';
end if;
end if;
end process;
process(clock)
begin
if (clock'event and clock = '1') then
if ((pb = '1') and (q2 /=dead_time)) then
q2 <= q2 + 1;
elsif ((pb = '0') and (q2 /= "00000000")) then
q2 <= q2 - 1;
end if;
if ((pb = '1') and (q2 = dead_time)) then --上桥臂导通
bh <= '1';
else
bh <= '0';
end if;
if ((pb = '0') and (q2 ="00000000")) then --下桥臂导通
bl <= '1';
else
bl <= '0';
end if;
end if;
end process;
process(clock)
begin
if (clock'event and clock = '1') then
if ((pc = '1') and (q3 /=dead_time)) then
q3 <= q3 + 1;
elsif ((pc = '0') and (q3 /= "00000000")) then
q3 <= q3 - 1;
end if;
if ((pc = '1') and (q3 = dead_time)) then --上桥臂导通
ch <= '1';
else
ch <= '0';
end if;
if ((pc = '0') and (q3 ="00000000")) then --下桥臂导通
cl <= '1';
else
cl <= '0';
end if;
end if;
end process;
end; |
阿莫论坛20周年了!感谢大家的支持与爱护!!
知道什么是神吗?其实神本来也是人,只不过神做了人做不到的事情 所以才成了神。 (头文字D, 杜汶泽)
|