Controlling Stepper Motor Using SD02B

Controlling Stepper Motor Using SD02B
PR7
Controlling Stepper Motor
Using SD02B (Unipolar)
Version 1.4
Aug 2010
Cytron Technologies Sdn. Bhd.
Information contained in this publication regarding device applications and the like is intended through suggestion only and may be superseded by
updates. It is your responsibility to ensure that your application meets with your specifications. No representation or warranty is given and no liability
is assumed by Cytron Technologies Incorporated with respect to the accuracy or use of such information or infringement of patents or other
intellectual property rights arising from such use or otherwise. Use of Cytron Technologist’s products as critical components in life support systems
is not authorized except with express written approval by Cytron Technologies. No licenses are conveyed, implicitly or otherwise, under any
intellectual property rights.
OVERVIEW
This document describes the development of Cytron
Technologies DIY (Do It Yourself) Project No.7
(PR7). This project is using PIC16F876A to control
SD02B (stepper motor driver) further drive a stepper
motor with variable speed and bi-directionally.
Start/stop instruction and CW/CCW instruction are
controlled by push buttons meanwhile the speed of
motor is controlled by potential meter. Circuit
schematic and PIC source code is provided.
FEATURES
PIC16F876A
- 8-bit microcontroller with 22 I/O
- operate with 5V supply
- operating speed: 20MHz
SD02B stepper motor driver
- operate with 5V supply
- Maximum speed up to 1000 steps per second
- 2/5/10 micro-stepping feature
ROBOT . HEAD to TOE
PR7 – Controlling Stepper Motor Using SD02B(Unipolar)
SYSTEM OVERVIEW
Push
button
PIC16F876A
Stepper
Motor
SD02B
Potentiometer
GENERAL DESCRIPTION
Cytron Technologies offers stepper motor driver,
SD02B to ease the control of stepper motor. This
model supports 2 general types of stepper motor which
is unipolar and bipolar stepper motor. It provides easy
control of start/stop, speed and even direction.
Combining of PIC and SD02B offers a simple and fast
development yet reliable result.
All of these features make it ideal for advanced
applications in automotive, industrial, appliances and
consumer product. Figure 1 shows the pin diagram for
PIC16F876A. For more information about the PIC
microcontroller, please refer to the datasheet. The
datasheet can be obtained from microchip website at:
http://www.microchip.com
Stepper Motor
PIC16F876A
This powerful (200 nanosecond instruction execution)
yet easy-to-program (only 35 single word instructions)
CMOS FLASH-based 8-bit microcontroller packs
Microchip's powerful PIC® architecture into an 28-pin
package and is upwards compatible with the
PIC16C5X, PIC12CXXX and PIC16C7X devices.
Feature of the device:
• 8 Kbytes of Flash Program Memory
• 368 bytes of Data Memory (RAM)
• 256 bytes of EEPROM data memory
• 5 channels of 10-bit Analog-to-Digital (A/D)
converter
• 2 capture/compare/PWM functions
• MSSP (Master Synchronous Serial Port) can be
configured as either 3-wire Serial Peripheral
Interface(SPI™) or the 2-wire Inter-Integrated
Circuit (I²C™) bus
• Universal Asynchronous Receiver Transmitter
(USART)
Figure 2
There are various kinds of Stepper motor. Some
example are variable reluctant stepper motor,
permanent magnet stepper motor, bipolar/unipolar
stepper motor, bifilar stepper motor and hybrid stepper
motor.
In this project, unipolar stepper motor (MO-STEP17PM-J3X-Minebea Stepping Motor product code, just
for reference) is used. User has the option to include
the stepper motor in the hardware set or not. If a user
tends to use another stepper motor, sequence of the
internal coils must be known first. Different brand of
stepper motor has difference sequence of cable and
also different color.
Figure 1
Created by Cytron Technologies Sdn. Bhd. – All Rights Reserved
2
ROBOT . HEAD to TOE
PR7 – Controlling Stepper Motor Using SD02B(Unipolar)
Please refer to the schematic diagram of PR7. The
schematic is provided free therefore Cytron
Technologies will not be responsible for any further
modification or improvement.
SD02B
Interface PIC16F876A with SD02B
To Stepper Motor
To Control
and Power
Source
Figure 3
SD02B is designed to drive unipolar or bipolar stepper
motor. The board incorporates most of the components
of the typical applications. With minimum interface,
the board is plug and play and ready to drive the
unipolar or bipolar stepper motor. SD02B will actually
drive stepper motor in bipolar method. However, since
unipolar stepper motor can also be used as bi-polar
stepper motor, thus this driver can be used to drive
both unipolar and bipolar stepper motor. It has been
designed with capabilities and features of:
•
•
•
•
•
•
•
•
•
•
UART interface for easier communication
between the user’s circuit (or PC) and SD02B.
Support up to 1A per phase
Smoother stepper motor rotation with 2/5/10
micro-stepping feature
Able to drive stepper motor from 3V to 40V.
8V to 24V compatible for driver circuit supply
voltage
5V logic level compatible inputs.
Maximum speed up to 1000 steps per second
or 1KHz pulses
Enable/Disable
pin
for
low
power
consumption mode.
Heat sink with fan for fast thermal release
UART baud rate and micro-stepping mode are
saved in the non-volatile flash memory
(Factory default is baud rate = 9600, microstepping mode = 10).
UART interface
Figure 4
Figure 5
For further information, please download the User’s
Manual at www.cytron.com.my
HARDWARE
This project will require following hardware:
a.
b.
c.
d.
e.
1 x PIC16F876A
1 x PR7 Printed Circuit Board (PCB)
1 x SD02B stepper motor driver
1 x unipolar stepper motor
Related electronic components
Created by Cytron Technologies Sdn. Bhd. – All Rights Reserved
Figure 6
3
ROBOT . HEAD to TOE
PR7 – Controlling Stepper Motor Using SD02B(Unipolar)
Figure 5 visualizes the input and output pins of the
motor driver (SD02B). The input consists of 6 pins
which are connected to the PIC board. The pins
description is shown at Figure 6. The output of SD02B
also consists of 6 pins which are connected to stepper
motor. The sequence and polarity of the motor should
be taken care. Figure 7 shows the schematic of
connections between PIC I/O pins and SD02B.
1
2
3
4
5
6
7
8
Figure 7
Interface SD02B with unipolar stepper
motor
The unipolar stepper motor used is included in the
hardware set. But, user still has the option to exclude it
from hardware set and choose another stepper motor
instead. Be alert of the colors of cable for other brand
of stepper motor, it may differ from the stepper motor.
Wrong sequence will not damage the stepper motor,
but it surely will fail to operate.
Figure 8 shows the connection of cable from SD02B to
MO-STEP-17PM-J3X Minebea Stepping Motor. The
stepper motor not comes with cable connector. User
need to build your own cable. Figure 9 show guides for
making 6 ways 2020 cable for interface SD02B with
unipolar stepper motor.
9
Figure 9
Figure 8
Guide for making 5 ways 2020 cabel for interface
SD02B with unipolar stepper motor.
Repeat step 5 to 7 for every single cable to achieve step
8.
Figure 10
Created by Cytron Technologies Sdn. Bhd. – All Rights Reserved
4
ROBOT . HEAD to TOE
PR7 – Controlling Stepper Motor Using SD02B(Unipolar)
For the other end of that cable show in figure 10, user
may refer figure 23 to connect the wire to 2510
connector.
Figure 12
!Y
GND
Y
!X
GND
X
Power supply for the circuit
Figure 11 shows the connection of cable from SD02B
to 42BYGHD-439 Linix Stepping Motor. Be alert of
the colors of cable for other brand of stepper motor, it
may differ from the stepper motor shown in Figure 11.
Figure 13
User can choose either use the AC to DC adaptor or
12V battery to power up the circuit. Higher input
voltage will dissipate more heat at LM7805 voltage
regulator. Typical voltage is 12V. Anyhow, LM7805
will still dissipate some heat at 12V. Please take note
that the 12V used in the circuit board will also be the
power supply to stepper motor. There are two type of
power connector for the circuit, DC plug (J1) and
2510-02 (JP1). Normally AC to DC adaptor can be
plugged to J1 type connector. Shown in Figure 13, D1
is uses to protect the circuit from wrong polarity
supply. C1 is use to stabilize the voltage at the input
side of the LM7805 voltage regulator, while the C2 is
use to stabilize the voltage at the output side of the
LM7805 voltage supply. LED3mm is green LED to
indicate the power status of the circuit. R1 is resistor to
protect LED3mm from over current that will burn the
LED3mm.
Push Button as input for PIC
Microcontroller
Figure 11
Figure 12 shows the connection of cable from SD02B
to MO-STEP-17PM-K58 Minebea Stepping Motor.
The stepper motor not comes with cable connector.
User need to build your own cable. Refer figure 9 to
for making 6 ways 2020 cable for interface SD02B
with unipolar stepper motor.
Figure 14
Created by Cytron Technologies Sdn. Bhd. – All Rights Reserved
5
ROBOT . HEAD to TOE
PR7 – Controlling Stepper Motor Using SD02B(Unipolar)
One I/O pin is needed for one push button as input of
PIC microcontroller. The connection of the push button
to the I/O pin is shown in Figure 14. The I/O pin
should be pull up to 5V using a resistor (with value
range 1K-10K) and this configuration will result an
active-low input. When the button is being pressed,
reading of input pin will be in logic 0, while the button
is not pressed, reading of that input pin will be logic 1.
consult the manufacturer of that particular PIC
programmer.
For the instruction of using UIC00A/B, please refer to
its User’s Manual at: www.cytron.com.my
PCB circuit board
LED as output for PIC microcontroller
9
8
7
6
1
2
3
4
5
Figure 17
Component:
Figure 15
One I/O pin is needed for one LED as output of PIC
microcontroller. The connection for a LED to I/O pin is
shown in the schematic above. The function of
R7/R8/R9 is to protect the LED from over current that
will burn the LED. When the output pin is logic 1, the
LED will ON, while when the output is in logic 0, the
LED will OFF.
In Circuit Serial Programming (ICSP)
1.
2.
3.
4.
5.
6.
7.
8.
9.
Reset button.
Start button (ON/OFF).
Direction button (CW/CCW).
Run button (run/stop).
Speed control potential meter.
Slides switch (Power ON/OFF).
Power connector (12V).
DC plug socket (to 12V adapter).
Box header (To ICSP Programmer).
Please refer to Appendix A for the PCB board of PR7.
Cytron Technologies will not be responsible for any
further modification or improvement.
Figure 16
MCLR, RB6 and RB7 are needed for ICSP purpose.
These pins should be connected to the USB ICSP PIC
Programmer (UIC00A/B) via the 2x5 box header for
loading and reading program from computer. The
programmer (UIC00A/B) is not included in DIY
project set since it can be used for different project set.
User can also choose other type of PIC programmer to
load the program; however, the interface and method to
load program might differ from UIC00A/B. Please
Created by Cytron Technologies Sdn. Bhd. – All Rights Reserved
6
ROBOT . HEAD to TOE
PR7 – Controlling Stepper Motor Using SD02B(Unipolar)
SOFTWARE
GETTING START
User can obtain the hardware set for this project (PR7)
either by online purchasing (www.cytron.com.my) or
purchase it in Cytron Technologies Shop.
Flowchart:
1.
Start
=2
Test start
variable
=0
Once user has the hardware set, soldering
process can be started. Please solder the
electronic components one by one according
the symbols or overlays on the Printed Circuit
Board (PCB). Ensure the component value
and polarity is correctly soldered. Please refer
to Board Layout in Appendix A.
Caution: Make sure all the connectors (2510) are
soldered in proper side. Those electronic
components have polarity such as capacitor,
diode, PIC, LM7805 and LED should be
soldered in right polarity or it may cause the
circuit board fail to work.
=1
Press CCW/CW
Button.
Test start
variable
=1
Test ‘turn’
variable
=0
Motor run in
other direction
Motor run in a
direction
Press Run Button
to Rotate
Warning:Before the battery (Power) is plugged in,
make sure the polarity is correct to prevent the
exploration. Wrong polarity of capacitor also
may cause exploration.
To Author: Make the above standard with new format.
2.
Please download the necessary files and
document from Cytron Technologies website.
These included documentation, sample source
code, schematic, component list and software.
3.
Please install MPLAB IDE and HI-TECC C
PRO into computer. The MPLAB IDE and
HI-TECH C PRO can be downloaded from
www.cytron.com.my . Please refer MPLAB
IDE installation step document to install the
software. The documents can be used to any
version of MPLAB IDE software.
4.
After the installation complete, create project
for the sample file provided using MPLAB
IDE. Please refer to MPLAB Open Project
document.
5.
Connect PR7 to SD02B and stepper motor.
6.
Plug in power supply for the circuit. User can
choose to use battery or AD to DC adaptor.
7.
Build the project and load the hex file into the
PIC microcontroller using the USB In Circuit
Programmer (UIC00A/B). When user build
the project, MPLAB IDE will generate hex
file. The hex file generated from MPLAB IDE
will be named according to project name, not
C file name. Cytron Technologies also
provide hex file for user. Do not forget to
switch ON the power. The programmer is not
included in the hardware set but it can be
found at Cytron website. (User manual is
provided at website).
Run/stop button
Motor is in idle state
For more information about the software for this
system, please refer to the source code provided. The
explanation of each instruction is provided in the
source code as the comment of each line.
The source code is provided free and Cytron
Technologies will not be responsible for any further
modification or improvement.
Created by Cytron Technologies Sdn. Bhd. – All Rights Reserved
7
ROBOT . HEAD to TOE
PR7 – Controlling Stepper Motor Using SD02B(Unipolar)
8.
PIC is now completely programmed.
9.
Turn ON the switch and will ON the LED.
12V lead acid battery and connector:
10. Press reset button to reset all function.
11. Press on/off button and will ON the LED1.
Figure 20
12. Press run/stop button to running the motor and
LED3 will turn ON.
13. To change the motor direction, press ccw/cw
button and LED2 will turn ON.
14. The potential meter will control the motor
speed.
Figure 21
Note! Different brand of stepper motor has different
arrangement of input cable. So check the user manual
and make sure the sequence of the cable before plug in
to the motor driver.
AC to DC adaptor:
User can decide either uses a 12V battery or an AC to
DC adaptor as the power source to the circuit. The
picture and the way to use the adaptor are shown in
Figure 18 and 19.
Figure 22
Figure 20 and 21 shows the method to connect cable
leg to lead acid battery. Follow the standard; the red
cable leg should be connected to terminal positive
while the blue cable leg should be connected to
negative terminal. Cable used to connect the cable leg
and 2510 connector is provided in the project set. Red
cable is connected to positive terminal and black cable
is connected to negative terminal. Be careful on the
polarity of the 2510 socket on the board (refer the
Board Layout at Appendix A).
How to connect the wire to 2510 connector
to interface PR7 with SD02B:
12V Polarity
Figure 18 (Not included in DIY project set)
Figure 23 shows the method of connecting the cable to
2510 header using rainbow cable. Repeat step 5 to 7
for every single cable to achieve step 8.
1
2
3
4
Figure 19
Created by Cytron Technologies Sdn. Bhd. – All Rights Reserved
8
ROBOT . HEAD to TOE
PR7 – Controlling Stepper Motor Using SD02B(Unipolar)
5
6
WARRANTY
No warranty will be provided as this is DIY project.
Please check the polarity of each electronic component
before soldering it to board.
7
8
9
Figure 23
Repeat step 1 to 9 to get the cable connector shown in
figure 24.
Figure 24
BASIC OPERATION
1.
2.
3.
4.
5.
6.
7.
8.
9.
Switch ON the power
ƒ Power Led (green) will turn ON.
Press ON/OFF button
ƒ LED 1 (red) will turn ON
Press CCW/CW button
ƒ LED 2 (red) will turn ON
Press Run/Stop button
ƒ LED 3 (red) will turn ON
ƒ Motor will rotate in a direction.
Press Run/Stop button
ƒ LED 3(red) will turn OFF
ƒ Motor will stop (in idle state)
Press CCW/CW button
ƒ LED 2 (red) will turn OFF
Press Run/Stop Button again
ƒ LED 3 (red) will turn ON
ƒ Motor will rotate in other direction.
Adjust the potentiometer to control the speed
If all steps mention above can be executed,
your project is done successfully.
Congratulations!!
Created by Cytron Technologies Sdn. Bhd. – All Rights Reserved
9
ROBOT . HEAD to TOE
PR7 – Controlling Stepper Motor Using SD02B(Unipolar)
Appendix A
PCB Layout:
10K
Box
Header
1N4148
Diode
C-cap
30pF
20MHz
Crystal
220R
2510-06
Connector
1K
PIC
16F876A
C-cap
104
1N4001
Diode
2510-02
Connector
LM7805
Slide
switch
1K
1K
LED 3mm
1K
Adaptor
Socket
LED 3mm
LED 3mm
E-cap
100uF
220R
C-cap
104
10K Potential meter
Prepared by
Cytron Technologies Sdn. Bhd.
19, Jalan Kebudayaan 1A,
Taman Universiti,
81300 Skudai,
Johor, Malaysia.
Tel:
Fax:
+607-521 3178
+607-521 1861
URL: www.cytron.com.my
Email: [email protected]
[email protected]
Created by Cytron Technologies Sdn. Bhd. – All Rights Reserved
10
Was this manual useful for you? yes no
Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Download PDF

advertisement