You have no items in your shopping cart.

Subtotal: 0.00

Stepper Motor interfacing with Spartan3 FPGA Development Kit

Interfacing stepper motor with Spartan3 FPGA Development Kit

Stepper motor

The basic principle of stepper motor or any other motor is electromagnetic induction which means while apply a current to the circuit, the EMF will be induced due to change of magnetic field of the circuit.

Working of stepper motor

The rotor shaft of the stepper motor is surrounded by the electromagnetic stator. The rotor and stator have poles which would be teethed or depends upon the motor type. When apply the electrical pulse to the stator which gets energized and produced EMF. The EMF cuts the conductor of the rotor. Now the torque will be introduced. This torque (force) is used to rotate the rotor shaft which means the rotor align itself along with stator.

 Type of stepper motor

  • Variable reluctance stepper motor
  • Permanent magnet stepper motor
  • Hybrid stepper motor

Permanent magnet stepper motor

The stator and rotor do not have any teethed poles. Instead of this which have alternative north and south poles and it is parallel to the axis of motor. When a stator is energized which develops the magnetic field and the rotor align itself along the magnetic field of the stator. As if while the other magnetic field will introduce, the rotor align itself to new field.

  Permanent magnet stepper motor

                    Fig 1: Permanent magnet stepper motor

Variable reluctance motor

It has toothed poles. When apply pulse to the stator the coil is energized and the rotor moves to have maximum gap with stator.

 Variable reluctance motor

                                   Fig 2: Variable Reluctance motor

Hybrid stepper motor

As it name implies which has the advantage of both Permanent magnet and Variable reluctance motor to improve the efficiency. It provides high torque and runs very high step rate. The application of hybrid motor is CD player and disk drive in computer, robotics.

Step mode

A full rotation of stepper is divided into number of steps which would be around 200 steps. The stepper receives only one pulse at the time for one step. Normally the rotating angle of stepper motor typically is 1.8 degrees.

The stepper motor operates at various modes such as full step, half step.

Full step

The full step of stepper motor is 200 steps per revolution. So the angle of rotation is 1.8 degrees which is calculating from given formula.

Step angle = 360 degrees / no of steps.

Step angle = 360 / 200 = 1.8 degrees.

 

Half step

The half step of stepper motor is 400 steps per revolution. So the angle of rotation is 0.9 degrees which is calculating from given formula.

Step angle = 360 degrees / no of steps.

Step angle = 360 / 400 = 0.9 degrees.

 

 

Micro step

The advanced stepper motor has come with micro step system. Micro stepping of stepper motor means which subdivides the number of positions between poles for increasing the steps.  Some micro stepping has a capable of divide a full step (1.8 degrees) into 256 micro steps. The result would be 51200 steps in one revolution (0.007 degrees/step). 

Interfacing stepper motor with Spartan3 FPGA Development Kit

The motor is used to covert mechanical energy into electrical energy. Stepper motor is not like as any other motor which means is not rotating continuously. It is rotating step by step according to given electrical pulse. The FPGA cannot drive stepper motor directly. Because of the I/O capability of FPGA is 3.3v. So for the driver circuit are required able to drive the stepper motor. A full rotation divides into a number of equal steps. So this motor called as also stepper motor.

Stepper motor driver

The voltage capability of FPGA GPIO is only 3.3v standard logic level. So the FPGA output cannot drive the stepper motor with 3.3v. Hence the driver circuit is needed to energize the stepper motor. Here the driver circuit helps to increase the output voltage of FPGA for stepper motor that voltage often called as bus voltage. The driver controller circuit provides step and direction output as an electrical signal to the step motor. The rated voltage of driver circuit must be five to ten times of stepper motor rating voltage. Because of the driver output is related to the speed versus torque of stepper motor. Therefore if output increases, the speed of the stepper motor will increase and if the output decreases, the speed of the stepper motor will decrease. On the other hand the driver circuit current should be limited to the step motor current rating.

Stepper motor driver

                                                         Fig 3: Interfacing stepper motor with Spartan3 FPGA Development Kit

Normally the ULN2803 have eight input and output which is operated by 5v supply. Here only eight pins are needed to make a connection between FPGA and stepper motor. The ULN2803 IC is used to drive the stepper motor with individual electrical pulse for each winding of the stepper motor. Here A, B, C, D is a winding of stepper motor.

 Stepper motor driver

                                 Figectors for stepper motor

 Stepper Motor Driver Placement in FPGA Development Kit

Stepper Motor Driver Placement in Spartan3 FPGA Development Kit

VHDL Code Description

The code has been written as control the stepper motor through various functions such function as forward and reverse, half step and full step selection with step enable. VHDL code for stepper motor

library IEEE;

use IEEE.std_logic_1164.all;

use IEEE.std_logic_arith.all;

use IEEE.std_logic_unsigned.all;

 

entity stepper is

port

(  Clk: in STD_LOGIC;-- clock I/P

   CW_CCW: in STD_LOGIC;-- direction control

   Rs : in STD_LOGIC;-- system reset

   Step_En:in STD_LOGIC;-- step enable

   FS_HS:in STD_LOGIC;-- Half step / Full step control

   W1, W2, W3, W4: out STD_LOGIC); -- Winding o/ps

end stepper;

 

architecture behave of stepper is

signal div: std_logic_vector(16 downto 0);-- clock divider

signal clk_s: std_logic;-- divided clock signal

type state is(reset,first, second, third, fourth, half1,half2,half3,half4);

signal  Ps_state, Nx_state : state;

signal  motor:std_logic_vector(3 downto 0);

begin

 

process (Clk,rst)

begin

if Rst = '0' then    -----starting process

div <=  (others=>'0');

elsif  Clk'event and Clk='1' then

div  <=  div + 1;

end if;

end process;

 

------------------------------------------------------------------------

-- divided clock signal

-- change this value to control the speed of motor.

clk_s <= div(16);

 

process (clk_s,rst)

begin

if Rst = '0' then

Ps_state <= reset;

elsif clk_s'event and clk_s='1' then

if Step_en = '1' then

Ps_state <= Nx_state;

end if;

end if;

end process;

 

process (ps_state,CW_CCW,Step_en,rst,FS_HS)

begin

case(ps_state) is

when reset  =>                                                        

Nx_state  <= first;

when first  =>                                                        

if FS_HS = '0' then ---FS_HS='1' then HALF STEPs

if CW_CCW = '1' then

Nx_state <= second;   ----assigning each step of motor rotation

else

Nx_state  <= fourth;

end if;

else

if CW_CCW = '1' then

Nx_state  <= half1;

else

Nx_state  <= half4;

end if;

end if;

when half1 =>                                                         

if CW_CCW = '1' then

Nx_state  <= second;

else

Nx_state  <= first;

end if;

when second  =>                                                       

if FS_HS = '0' then-- FS_HS='1' then HALF STEPs

if CW_CCW = '1' then

Nx_state  <= third;

else

Nx_state  <= first;

end if;

else

if CW_CCW = '1' then

Nx_state  <= half2;

else

Nx_state  <= half1;

end if;

end if;

when half2  =>                                                        

if CW_CCW = '1' then

Nx_state  <= third;

else

Nx_state  <= second;

end if;

when third =>                                                         

if FS_HS = '0' then -- FS_HS='1' then HALF STEPs

if CW_CCW = '1' then

Nx_state <= fourth;

else

Nx_state  <= second;

end if;

else

if CW_CCW = '1' then

Nx_state  <= half3;

else

Nx_state  <= half2;

end if;

end if;

when half3  =>                                                        

if CW_CCW = '1' then

Nx_state  <= fourth;

else

Nx_state  <= third;

end if;

when fourth =>                                                        

if FS_HS = '0' then  -- FS_HS='1' then HALF STEPs

if CW_CCW = '1' then

Nx_state  <= first;

else

Nx_state  <= third;

end if;

else

if CW_CCW = '1' then

Nx_state  <= half4;

else

Nx_state  <= half3;

end if;

end if;

when half4  =>                                                        

if CW_CCW = '1' then

Nx_state  <= first;

else

Nx_state  <= fourth;

end if;

when others  => Nx_state  <= reset;

end case;

end process;

------------------------------------------------------------------------

-- Assigning O/Ps

W4  <= motor(3);

W3  <= motor(2);

W2  <= motor(1);

W1  <= motor(0);

------------------------------------------------------------------------

process(ps_state)

begin

case  ps_state is

when reset  =>

Motor  <= "0000";    ----assigning motor control on/off

when first  =>                                                        

Motor <= "1000";

when half1 =>                                                         

Motor  <= "1100";

when second  =>                                                       

Motor  <= "0100";

when half2  =>                                                        

Motor  <= "0110";

when third  =>

Motor  <= "0010";

when half3  =>                                                        

Motor  <= "0011";

when fourth  =>                                                       

Motor <= "0001";

when half4 =>


Motor <= "1001";

when others =>

Motor <= "0000";

end case;

end process;

------------------------------------------------------------------------

end behave;

User Constraint File

NET "CW_CCW" LOC = P51;
NET "Clk" LOC = P181;
NET "FS_HS" LOC = P46;
NET "Rst" LOC = P48;
NET "Step_En" LOC = P50;
NET "W1" LOC = P131;
NET "W2" LOC = P130;
NET "W3" LOC = P128;
NET "W4" LOC = P126;