Waveshare HAT User manual

Stepper Motor HAT User Manual
1/ 24
Stepper Motor HAT
User Manual
OVERVIEW
Stepper Motor HAT is designed for Raspberry Pi, can drives two stepper motors and
support up to 1/32 microstepping
FEATURES
⚫Raspberry Pi connectivity, compatible with Raspberry Pi Zero/Zero W/Zero
WH/2B/3B/3B+
⚫Onboard dual DRV8825 motor controller IC with built-in microstepping indexer,
drives two stepper motors, easy to use
⚫6 available microstepping modes, configured with the DIP switches: full-step, half-
step, 1/4-step, 1/8-step, 1/16-step, and 1/32-step
⚫Adjustable motor drive current via potentiometer, maximum 2.5A current output
⚫Protection features: Overcurrent Protection (OCP), Thermal Shutdown (TSD), VM
Undervoltage Lockout (UVLO)
⚫Integrates 5V regulator, allows providing power to Raspberry Pi
⚫Onboard multi connector options for stepper motors in different specifications
⚫Comes with development resources and manual (examples in BCM2835, wiringPi,
and python)

Stepper Motor HAT User Manual
2/ 24
SPECIFICATIONS
⚫Motor controller: DRV8825
⚫Motor drive voltage: 8.2V~28V
⚫Motor drive current: 2.5A
⚫Logic voltage: 3.3V
⚫Dimension: 65mm × 56mm
⚫Mounting hole size: 3.0mm

Stepper Motor HAT User Manual
3/ 24
CONTENT
Overview....................................................................................................................................................... 1
Features................................................................................................................................................ 1
Specifications ..................................................................................................................................... 2
Hardware...................................................................................................................................................... 5
Pinout.................................................................................................................................................... 5
Power .................................................................................................................................................... 7
Motor Driver....................................................................................................................................... 7
Cotnrol protocol......................................................................................................................................10
H-bridge.............................................................................................................................................10
protocol of motor...........................................................................................................................11
Microstepping..................................................................................................................................12
DRV8825 ............................................................................................................................................12
Demo codes..............................................................................................................................................13
Preparation .......................................................................................................................................13
Downloading............................................................................................................................13
Libraries Installation ..............................................................................................................13
Setting.................................................................................................................................................15
Microstepping .........................................................................................................................15
Current setting ........................................................................................................................16
Running demo code ......................................................................................................................18
BCM2835 ...................................................................................................................................18

Stepper Motor HAT User Manual
4/ 24
WiringPi .....................................................................................................................................18
Python ........................................................................................................................................18
Code Analysis ...........................................................................................................................................19
BCM2835 ...........................................................................................................................................19
files ..............................................................................................................................................19
Codes..........................................................................................................................................20
wiringPi...............................................................................................................................................22
Files..............................................................................................................................................22
Python.................................................................................................................................................22
Files..............................................................................................................................................22
Codes..........................................................................................................................................22
FAQ...............................................................................................................................................................24

Stepper Motor HAT User Manual
5/ 24
HARDWARE
PINOUT
PIN
Description
VIN
8.2~28V Power Input
5V
5V Power
GND
Ground
A1
Output 1 of bipolar stepper motor M1
winding A

Stepper Motor HAT User Manual
6/ 24
A2
Output 2 of bipolar stepper motor M1
winding A
B1
Output 1 of bipolar stepper motor M1
winding B
B2
Output 2 of bipolar stepper motor M1
winding B
A3
Output 3 of bipolar stepper motor M2
winding A
A4
Output 4 of bipolar stepper motor M2
winding A
B3
Output 3 of bipolar stepper motor M2
winding B
B4
Output 4 of bipolar stepper motor M2
winding B
A1、A2、B1、B2: Control pins of stepper motor M1;
A3、A4、B3、B4: Control pins of stepper motor M2;
Power switch: Control power supply for Raspberry Pi;
Switch D0-D5: Control subdivision format;
D0-D2: Control stepper motor 1;
D3-D5: Control stepper motor 2;
Potentiometers: Control output current

Stepper Motor HAT User Manual
7/ 24
POWER
MP1584 regular supports wide 4.5V to 28V input, and up to 2A current output. Even
thought that MP1584 support low to 4.5V input, however, VM also supply power for
motor controller, which require at least 8.2V. So, the recommend input voltage is
8.2~28v.
MOTOR DRIVER

Stepper Motor HAT User Manual
8/ 24
The DRV8825 is e has two H-bridge and a microstepping indexer, and is intended
to drive a bipolar stepper motor. It supports up to 1/32 microstepping. Internal
shutdown functions are provided for overcurrent, short circuit, under voltage lockout
and over temperature.
VM:Voltage input, range: 8.2V~45V, consider of regular, the actual input range is:
8.2V~28V
nSLEEP: Should keep High, otherwise chip will enter sleep mode, and module cannot
work properly.
nENBL: Enable pin. Low: H-bridge is enabled and rise edge of STEP is sampled; High:
H-bridge is disabled, output is high impedance. Note that you should disable it if
you don’t use it, otherwise the chip and motor will keep heating!
STEP: Step clock input
DIR: Direction control
MODE0, MODE1, MODE2: Mcirostepping input
PIN 12/PIN 13: Adjust output current
R13/R16: Sample resistors, they are 0.2Ω
According to datasheet Page11:
Ichop = V(xREF)/(5*R(ISENSE))
and resistor is 0.2Ω, then we can get that output current is proportional to voltage of
potentiometer.
I = Vref

Stepper Motor HAT User Manual
9/ 24
So, if you need to increase the output current, you can adjust potentiometers on
board.

Stepper Motor HAT User Manual
10 / 24
COTNROL PROTOCOL
H-BRIDGE
H-bridge is a popular motor control circuit. It is named because it looks like character
“H”. It consists of four transistors/MOSFET, motor is connected on the center, you
should through two transistors in diagonal line to drive motor.
When Q1 and Q4 is accessed, current flow from positive pole->Q1 to Q4->negative
pole, then motor moves forward.
When Q2 and Q4 is accessed, current flow from positive pole->Q2 to Q4->negative
pole, then motor moves backward.
If it is two H-bridge, there will be two set of output lines, for example, stepper motor
has four wires which is two H-bridge.
Other manuals for HAT
1
Table of contents

















