Ладно поделюсь я, может кому-то пригодиться...
Реализация разгона/торможения шагового двигателя (пока по трапециидальному закону, в дальнейшем можно встроить закон параболы и S образный закон, добавив дробный коеффициент для частоты reg_Fn).
Документ с описанием алгоритма, do файлы для моделсима, скриншот работы(jpg картинка), файлы описания, тестбенч - во вложении (архив 7z).
В общем:
Код
entity SMC is -- Stepper_Motor_Controller
generic ( M : natural := 32 );
Port (
clk : in STD_LOGIC;
rst : in STD_LOGIC;
en : in STD_LOGIC; --enable work
dir : in STD_LOGIC; --choice of direction acceleration/deceleration
Tmax : in STD_LOGIC_VECTOR (31 downto 0); -- maximum timing
Nsegment : in STD_LOGIC_VECTOR (7 downto 0); -- total segment acceleration/deceleration
T0 : in STD_LOGIC_VECTOR (31 downto 0); -- not used
Fmin : in STD_LOGIC_VECTOR (31 downto 0); --minimum frequency
Fmax : in STD_LOGIC_VECTOR (31 downto 0); --maximum frequency
ena_work : out STD_LOGIC; --acceleration / deceleration time signal
out_shim : out STD_LOGIC );
end SMC;
generic ( M : natural := 32 );
Port (
clk : in STD_LOGIC;
rst : in STD_LOGIC;
en : in STD_LOGIC; --enable work
dir : in STD_LOGIC; --choice of direction acceleration/deceleration
Tmax : in STD_LOGIC_VECTOR (31 downto 0); -- maximum timing
Nsegment : in STD_LOGIC_VECTOR (7 downto 0); -- total segment acceleration/deceleration
T0 : in STD_LOGIC_VECTOR (31 downto 0); -- not used
Fmin : in STD_LOGIC_VECTOR (31 downto 0); --minimum frequency
Fmax : in STD_LOGIC_VECTOR (31 downto 0); --maximum frequency
ena_work : out STD_LOGIC; --acceleration / deceleration time signal
out_shim : out STD_LOGIC );
end SMC;
Сильно не оптимизировал...
Конструктивная критика принимается.