Description

With this circuit you can drive a unipolar stepper motor. It operates in full step mode. You can get a stepper motor from an old 5.25 disk drive. The AVR attiny2313 micro controller controls the pulses for the stepper motor. The pulses are amplified by the ULN2003 driver. The driver accepts 5V inputs, the output for the driver is up to 30V so you can connect an stepper motor of up to 30V. With the two push switches you can drive the stepper motor CW or CCW.

Hardware

The hardware consist of the AT2313 microcontroller which drives the ULN2003 driver and two push buttons to control the direction.

Software

The program code is made with the AVR BASCOM compiler

BASCOM Program Code

' ***************************************************************************

' *

' * Title         : Stepper motor driver

' * Version       : 1.0

' * Last Updated :  28.11.2002

' * Target        : At90s2313

' * Author        : r.meurs@planet.nl

' * Program code  : BASCOM AVR

' * Hardware req. :

' * Description

' * This application can drive a stepper motor and let it turn left or right

' *

' *

' ***************************************************************************

 

 

 

      Dim Testin As Integer , Wa As Integer

 

      Config Portb = Output

      Config Portd = Input

 

      Wa = 5 ; delay between steps

 

      Lus:

      If Pind.0 = 0 Then Gosub Cw

      If Pind.1 = 0 Then Gosub Ccw

 

 

      Goto Lus

Ccw:

      Portb = 9                                             ' turn on Q1

      Waitms Wa                                             ' wait 2wa ms

      Portb = 0                                             ' turn off Q1

 

 

      Portb = 3                                             ' turn on Q2

      Waitms Wa                                             ' wait 2wa ms

      Portb = 0

 

 

      Portb = 6                                             ' turn on Q3

      Waitms Wa                                             ' wait 2wa ms

      Portb = 0                                             ' turn off Q3

 

 

      Portb = 12                                            ' turn on Q4

      Waitms Wa                                             'wait wams

      Portb = 0                                             'turn off Q4

      Return

 

Cw:

      Portb = 12                                            ' turn on Q1

      Waitms Wa                                             ' wait 2wa ms

      Portb = 0                                             ' turn off Q1

 

 

      Portb = 6                                             ' turn on Q2

      Waitms Wa                                             ' wait 2wa ms

      Portb = 0

 

 

      Portb = 3                                             ' turn on Q3

      Waitms Wa                                             ' wait 2wa ms

      Portb = 0                                             ' turn off Q3

 

 

      Portb = 9                                             ' turn on Q4

      Waitms Wa                                             'wait wams

      Portb = 0                                             'turn off Q4

      Return

 

Hex file of the BASCOM program code

:100000000AC018951895189518951895189518956B

:100010001895189518958FE181BD87E181BD8FED09

:100020008DBFC0ECEEE84E2EDD275D2EEEE7F0E052

:10003000A0E6B0E088278D933197E9F766248FEF2B

:1000400087BB80E081BB85E090E0A2E68D939C9326

:100050000027A0E38C9180FB0EF401E040E0041740

:1000600009F001C02DD00027A0E38C9181FB0EF494

:1000700001E040E0041709F001C001D0E9CF89E0B8

:1000800088BBA2E68D919C9145D080E088BB83E03F

:1000900088BBA2E68D919C913DD080E088BB86E034

:1000A00088BBA2E68D919C9135D080E088BB8CE026

:1000B00088BBA2E68D919C912DD080E088BB0895ED

:1000C0008CE088BBA2E68D919C9124D080E088BB17

:1000D00086E088BBA2E68D919C911CD080E088BB15

:1000E00083E088BBA2E68D919C9114D080E088BB10

:1000F00089E088BBA2E68D919C910CD080E088BB02

:1001000008953197F1F70895689462F80895E89496

:1001100062F80895EF93FF93E8EEF3E03197F1F77B

:0A0120000197D1F7FF91EF910895C8

:00000001FF