OpenCores
URL https://opencores.org/ocsvn/steppermotordrive/steppermotordrive/trunk

Subversion Repositories steppermotordrive

[/] [steppermotordrive/] [tags/] [v1_1_1_1/] [StepperMotorDrive.vhd] - Blame information for rev 18

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 6 franksdeve
library IEEE;
2
use IEEE.STD_LOGIC_1164.ALL;
3
use IEEE.STD_LOGIC_ARITH.ALL;
4
use IEEE.STD_LOGIC_UNSIGNED.ALL;
5
 
6
-- c2003 Franks Development, LLC
7
-- http://www.franks-development.com
8
-- !This source is distributed under the terms & conditions specified at opencores.org
9
-- 
10
-- Please see the file "StepperMotorWiring.bmp" for info on connecting 4 & 6 
11
-- wire motors to your device.  This source should drive either type, though connection
12
-- to 4-wire motors requires significantly more FET's to buffer outputs.  The
13
-- circuitry for 6-wire motors is more straightforward.
14
--
15
-- Another practical consideration is the threshold voltage of the FET's used to
16
-- buffer the logic outputs & provide current drive to the motor.  Most power
17
-- FET's have a threshold voltage in the 5-12V range (or even higher),
18
-- while logic devices now run in the 3.3V and lower range.  Thus, you must be 
19
-- careful to choose a FET with a low threshold voltage, or a level-converter must
20
-- be utilized between the logic output and the gate of the drive FET's.
21
--
22
-- One of the most advantageous abilities of stepper motors is the ability to 
23
-- provide static holding force in any position.  Of course this consumes power
24
-- and heats the motor up significantly (though steppers are rated to handle this)
25
-- use of the "static holding" input port will specify this behavior.
26
 
27
entity StepperMotorPorts is
28 10 franksdeve
    Port (
29
                                StepDrive : out std_logic_vector(3 downto 0);
30
                                clock : in std_logic;
31
                                Direction : in std_logic;
32
                                StepEnable : in std_logic --;
33
                                --ProvideStaticHolding : in std_logic
34 6 franksdeve
                );
35
end StepperMotorPorts;
36
 
37
architecture StepDrive of StepperMotorPorts is
38
 
39
        signal state : std_logic_vector(1 downto 0);
40
        signal StepCounter : std_logic_vector(31 downto 0);
41
        constant StepLockOut : std_logic_vector(31 downto 0) := "00000000000000110000110101000000";
42
 
43
begin
44
 
45
        process(clock)
46
        begin
47
 
48
                if ( (clock'Event) and (clock = '1') ) then
49
 
50
                        StepCounter <= StepCounter + "0000000000000000000000000000001";
51
 
52
                        if (StepCounter >= StepLockOut) then
53
 
54
                                StepCounter <= "00000000000000000000000000000000";
55
 
56
                                StepDrive <= "0000";
57
 
58
                                if (StepEnable = '1') then
59
 
60
                                        if (Direction = '1') then state <= state + "01"; end if;
61
                                        if (Direction = '0') then state <= state - "01"; end if;
62
 
63
                                        case state is
64
 
65
                                                when "00" =>
66
 
67
                                                        StepDrive <= "1010";
68
 
69
                                                when "01" =>
70
 
71
                                                        StepDrive <= "1001";
72
 
73
                                                when "10" =>
74
 
75
                                                        StepDrive <= "0101";
76
 
77
                                                when "11" =>
78
 
79
                                                        StepDrive <= "0110";
80
 
81
                                                when others =>
82
 
83
                                        end case; --state
84
 
85
                                end if;
86
 
87
                        end if;
88
 
89
                end if;
90
 
91
        end process;
92
 
93
end StepDrive;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.