AVR-Based Stepper Motor Driver (STMD)

# An AVR-Based Microstepping Bipolar Chopper Stepper Motor Driver (STMD)

## Oct. 28th, 2006 - ROHS compliant boards are now available!

### Features

- Open Source - The schematic, parts list, and software are all freely downloadable!

- Hobbiest-friendly - No surface mount parts means allows this drive to be easily repaired!

- DMOS driver chips rated at 55V and 3 Amps.

- Easy parts availability - Electronic parts are all available at Digikey. Just add your own heat sink and mounting hardware.

- DIP Switch selectable modes of stepping:
  1. Full Step, Both Phases On
  2. Full Step, Wave Drive
  3. Half Step
  4. Quarter Step
  5. Sixth Step
  6. Eighth Step
  7. Tenth Step
  8. Twelfth Step
  9. Sixteenth Step (available on special request in place of Twelfth Step mode with a special version of firmware)

- Optically isolated step, direction, & enable signals.
  These signals are ground referenced so no +5VDC is required - hook directly to your parallel port.

- Selectable automatic idle current reduction to reduce motor heating.
  Motor current can be reduced if no steps are received for 3 seconds. Oscilloscope Image, 202 kb

- DIP switch selectable motor test mode.
  Allows for testing of motor/drive/wiring without an externally generated step signal.

- Motor braking can be activated when drive is disabled.
  Alternatively, motor braking can also be disabled such that the motor will freewheel when drive is disabled.

- Motor current is adjustable by two potentiometers. (One for each motor phase)
  Fixed resistors may be substituted in place of the potentiometers for cost savings or increased reliability.

- Removable screw terminals for all wiring connections.

- Status LED flashes during normal operation to let the user know the microcontroller is running.
  Illuminates solid during a fault condition.

- Quality double-sided printed circuit board with ground plane and silkscreen legend.
  Board size is 3.25" x 4.30" with mounting holes for #6 screws in each corner.

### Design & Configuration

- An Atmel Mega48 running on its internal 8 MHz oscillator is the brain of the system. A 10 pin ISP connector is provided in the event the user would like to modify the open source firmware. The program memory is only about 40% full so there is plenty of room for an enterprising user to add to the custom features and functions. Normal operation of the microcontroller is indicated by flashing of the 'alive' LED once per second. If a fault condition is detected, the LED will be latched on until power is cycled to the board.

- For power switching, National Semiconductor�s LMD18245T 3A, 55V DMOS Full-Bridge Motor driver chips are used. These driver chips are the most expensive part of the STMD as two of them are required per motor. Although these driver chips are rated for +55 VDC, allowance should be made for back emf from the motor. As such, I recommend a maximum of +45 VDC.

- For flexiblity, DIP switches are used to select the mode of stepping. As described below, eight modes of stepping are available.

      SW3   SW2   SW1	     Stepping Mode          Steps/Revolution
      ---   ---   ---   --------------------     ------------------
      Off   Off   Off	  Full, Both Phases On	          200
      Off   Off   On	  Full, One Phase On	          200
      Off   On    Off	  Half                            400
      Off   On    On	  Quarter                         800
      On    Off   Off	  Sixth                          1200
      On    Off   On	  Eighth                         1600
      On    On    Off	  Tenth                          2000
      On    On    On	  Twelfth/Sixteenth*             2400/3200

      *Sixteenth step mode requires a special firmware version - available upon special request.

- SW4 in conjunction with JP1 and two pull-up/down resistors selects the method of motor braking.
  - SW4 off, JP1 on, pull-up resistor R10 populated - Motor braking active when drive is disabled.
  - SW4 on, JP1 on, pull-up resistor R10 populated - Motor is allowed to freewheel when drive is disabled.
  - JP1 off and pull-down resistor R11 populated - Motor braking always disabled.
  - All other combinations of SW4, JP1 and pull-up/down resistors are invalid and drive operation is undefined. DO NOT populate both R10 and R11!

- SW5 is used to enable test mode. This allows the user to test their wiring and drive/motor operation with no external step signal. During test mode, the drive will internally generate a step signal to rotate the motor at approximately 1 revolution per second. The drive must be enabled and will respond to the direction pin. To enable the drive with no external enable signal, you can temporarily connect J1-3 (Com) to J3-1 (Opto Com) and J1-1 (+5Vout) to J3-4 (Enable). The motor will change directions if J1-1 (+5Vout) is connected to J3-2 (Direction).

- JP2 is used to enable/disable automatic idle current reduction. When JP2 is on, idle current is reducted when no step signal has been received for 3 seconds. Full motor current is restored upon the next step signal. The amount of idle current reduction can be manipulated by changing R9 in the R8/R9 voltage divider. The default value of 1k allows for a 50% reduction. Using a 2k in place of R9 will allow for a 33% reduction.

- Current Limiting is set by adjusting potentiometers R4 and R5. The resistance as seen from pin 13 to ground on each of the LMD18245T driver chips (test points 6 & 7) should be set to 18750/I where I is the maximum desired winding current. (Where this comes from?) R2 and R3 (6.2 kohm resistors) are in series with the potentiometer to prevent the motor current from being set higher the driver chips's maximum rate load current. Potentiometers R4 and R5 should be set to identical values. Here is a picture (246 kb) showing how to adjust R4 when measuring from TP6.

          Maximum
           Motor
          Current    Resistance
          --------   ----------
          0.6 Amps   31.3  kohm
          0.8 Amps   23.5  kohm
          1.0 Amps   18.8  kohm
          1.2 Amps   15.7  kohm
          1.4 Amps   13.4  kohm
          1.6 Amps   11.8  kohm
          1.8 Amps   10.5  kohm
          2.0 Amps    9.38 kohm
          2.2 Amps    8.53 kohm
          2.4 Amps    7.82 kohm
          2.6 Amps    7.22 kohm
          2.8 Amps    6.70 kohm
          3.0 Amps    6.25 kohm

- Heat sinking is required for the driver chips and voltage regulator. I have had good success using this heat sink, made from a piece aluminum, with a small fan blowing on it. Heat sink sizing depends on motor current, ambient temperature, airflow, etc. Enabling automatic idle current reduction helps reduce unnecessary heating. The temperature of the driver chips and voltage regulators must not exceed 110°C. Be sure to use a thermally conductive grease between the heat sink and the driver chips/voltage regulator.

### Wiring Connections

- Motor connections (including motor voltage) are made on the removeable screw terminals on right side of the board.
  1. V+ is the Motor Power and must be externally fused. (TP4) The driver chip can is rated up to +55 VDC, but allowance should be made for back emf from the motor. As such, I recommend a maximum of +45 VDC.
  2. V- is the Motor Power common (TP5)
  3. Motor Winding, B+
  4. Motor Winding, B-
  5. Motor Winding, A+
  6. Motor Winding, A-

- Logic power connections are also made on removeable screw terminals on the right side of the board.
  1. Vout is the +5 VDC output from the on-board LM7805 voltage regulator. (TP1)
  2. Vin is the +8-20 VDC input to the on-board voltage regulator. At higher input voltages, the LM7805, heat sinking will be required. (TP2)
  3. Com is the DC Common for the two previously mentioned signals. (TP3)

- Connections for the optically isolated signals are made on the removeable screw terminals on the bottom edge of the board.
  1. Opto Com is the DC Common for the optically isolated signals. This is not connected to the the logic DC common. (TP8)
  2. Direction - The motor will revese directions when a +5 VDC signal is applied. This signal must be set 2 us prior to the step signal.
  3. Step - The motor will take a step on the rising edge of a +5 VDC signal when it is applied to this terminal. Maximum step frequency is 100 kHz. The Direction signal must be set for 2 us prior to the step signal becoming active.
  4. Enable - The motor will be disabled unless a +5 VDC signal is applied to this terminal. If you do not have an enable signal and want your drive to always be enabled... do not populate OP1 and where OP1 would have been installed, short the pads corresponding to pins 4 and 5. A photo of this modification can be found here. (206 kb) Please note that the motor shaft may 'jerk' when the drive is enabled/disabled; exact position is not maintained.

  #### Be sure to double and triple check all connections before power is applied!!

### Documentation

- Schematic is available either as a GIF file (52 kb) or a PDF file (56 kb).

- Parts List (Opens in a new window.)

- Full-Size Board Layout, 13 kb

- Full-Size Image of Board, 104 kb

- User's Gallery with photos and videos!

- QuickTime Video of Mill in Action, 5302 kb

- Board Dimensions, 7 kb, showing mounting hole locations.

  Heat Sink Dimensions, 9 kb. These dimensions are what I use to make my heat sinks out of a piece of aluminum. Be sure to use a thermally conductive grease between the heat sink and the driver chips/voltage regulator!

  Alternatively, you may download this zipped dxf file (20 kb). It contains both drawings which you may print out 1:1 and use as templates.

- Wave Form Photos

- Power Supply used for original testing. Schematics included.

- Motor used for original testing.

- Zip file containing AVR ASM Source Code (23 kb)

- PDF containing assembly instructions. (3129 kb)

- Obsolete Documentation for older v3.0 boards
  - Schematic (74 kb)
  - Full-Size Board Layout (12 kb)

- Frequently Asked Questions

- Limitations
  1. The LMD18245T only has a 4 bit DAC. With this resolution the waveform approximation becomes rather crude as the number of microsteps increase.
  2. More to be added as I run across them!

### Purchasing Information

This site contains all the information you need to build your own STMD. If you'd like to purchase a tested product, kit, bare PCB, or other components, details can be found here. (Opens in a new window.)

© 2007 WebRing Inc.

AVR
<< Prev | Ring Hub | Join | Next >>

© 2005, 2006

Last Updated: October 28th, 2006

Questions or Comments? (email me)

Hits since last reset.

This Page: `http://www.bright.net/~agarb/STMD/AVR_STMD.html`