SD02B 2A Stepper Motor Driver User’s Manual V1.0 Feb 2008 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.
ROBOT . HEAD to TOE Product User’s Manual – SD02B Index 1. Introduction and Overview 1 1.0 Introduction of SD02B 1 1.1 System Overview 2 1.2 General Description 3 2. Packaging List 4 3. Product Specification and Limitations 5 4. Board Layout 8 5. Installation (hardware) 10 5.1 Connecting Driver to a Stepper Motor 10 5.2 Connecting to microcontroller using Signal Input Pin 12 5.3 Connecting to switches (without microcontroller) 13 5.4 Connecting to microcontroller through UART 14 5.
ROBOT . HEAD to TOE Product User’s Manual – SD02B 1. INTRODUCTION AND OVERVIEW 1.0 Introduction of SD02B SD02B is the enhanced version from SD02A. 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 ready to Plug and Play. Simply add in power and a few push buttons, this driver is ready to drive unipolar or bipolar stepper motor.
ROBOT . HEAD to TOE Product User’s Manual – SD02B 1.1 System Overview Micro Controller SD02B Stepper Motor Computer/ Laptop SD02B is the enhanced version from SD02A. One of the additional features for SD02B compare to SD02A is the UART interface. UART is provided in SD02B for easier communication between user’s circuit (microcontroller) and SD02B. Besides user’s circuit, computer (PC or Laptop) is ready be used for UART communication with SD02B.
ROBOT . HEAD to TOE Product User’s Manual – SD02B 1.2 General Description Driving stepper motor is common necessity in most robotic project. A stepper motor is a brushless, synchronous electric motor that can drive a full rotation into a large number of steps. Stepper motor is ideally suited for precision control. This motor can operate in forward/reverse with controllable speed from a microcontroller through a transistor driver circuit. There are various kinds of stepper motor.
ROBOT . HEAD to TOE Product User’s Manual – SD02B 2. PACKAGING LIST Please check the parts and components according to the packing list. If there are any parts missing, please contact us at sales@cytron.com.my immediately. SD02B comes with: • 1 x SD02B board with every component is soldered properly and tested before board is shipped. • 16 x 2510 iron pin • 2 x 2510-06 female connector • 1 x 2510-04 female connector • User’s Manual and sample source codes (in VB.
ROBOT . HEAD to TOE Product User’s Manual – SD02B 3. PRODUCT SPECIFICATION AND LIMITATIONS Signal Input Pins Function Description Label Definition Function Vmotor is one of SD02B power sources. If users choose Vmotor as power source for circuit (in Single Supply Mode), Vmotor will supplies power to both Motor Supply stepper motor and SD02B circuit.
ROBOT . HEAD to TOE Product User’s Manual – SD02B UART Pins Function Description Label Definition Function RX SD02B UART Receive Pin This is SD02B’s UART receive pin. It should be interfaced to 5V logic UART. It should be connected to host’s transmit pin. TX SD02B UART Transmit Pin This is SD02B’s UART transmit pin. It should be interfaced to 5V logic UART. It should be connected to host’s receive pin. GND System Ground Common ground for both logic operation and also stepper power source.
ROBOT . HEAD to TOE Product User’s Manual – SD02B Single Supply Mode and Dual Supply Mode Voltage Selector is provided to choose either Single Supply Mode (Vmotor) or Dual Supply Mode (Vmotor and *Vin). If user selects Vmotor, Vmotor will supply power to both stepper motor and SD02B circuit. Otherwise if *Vin is selected, Vmotor will supply power to stepper motor and *Vin will supply power to SD02B circuit. Voltage selector Created by Cytron Technologies Sdn. Bhd.
ROBOT . HEAD to TOE Product User’s Manual – SD02B 4. BOARD LAYOUT A B J I C D H G F Label Function Heat sink with fan A Connector to stepper motor B E Label F G Function Push button to reset SD02B Push button to test SD02B C Stepper motor coil power indicator (4 LEDs) H Small green LED as VCC indicator D E Manufacturing test point UART communication I J Voltage selector Connector to Host (Signal) A – A heat sink with fan to dissipate the heat generated by SD02B.
ROBOT . HEAD to TOE Product User’s Manual – SD02B F– A push button acting as reset button to SD02B. If this button is pressed, SD02B will be reset to initial stage. Please DO NOT pressed this button during operation. G – A push button to activate self test on SD02B. When it is pressed and hold, SD02B will start to drive stepper motor. If power supply is connected and voltage selector is selected correctly, LEDs at C will illuminate sequentially. H – A small green LED to indicate status of power.
ROBOT . HEAD to TOE Product User’s Manual – SD02B 5. INSTALLATION (HARDWARE) 5.1 Connecting Driver to a Stepper Motor Most unipolar stepper motor comes with 5 or 6 wires. As shown in the following left figure, there will be 2 wires (1 and 2) which act as the common terminal for coil a and coil b. If these 2 wires (1 and 2) are not used, it will become bipolar stepper motor as shown in figure on the right.
ROBOT . HEAD to TOE Product User’s Manual – SD02B Connect each phase to the SD02B, and ignore the polarity (+/-) for now. User has a 50% chance of guessing right. c. Press Test button on SD02B. The stepper motor should rotate in CCW (counterclockwise) by looking at the motor shaft. If it is in the opposite direction, switch either phase X and !X or Y and !Y (effectively reversing directions). d. In case the stepper come with five coil wires, then each phase share the same common wire. b.
ROBOT . HEAD to TOE Product User’s Manual – SD02B 5.2 Connecting to Microcontroller using Signal Input Pins Typical application would require a microcontroller to generate pulses and control the direction. Following figure shows an example of SD02B connected to microcontroller. The above example shows that the PULSE pin is being connected to RC2 of PIC16F877A.
ROBOT . HEAD to TOE Product User’s Manual – SD02B 5.3 Connecting to Switches (without microcontroller) User may also use switches to generate pulses and control the direction of stepper motor. Here is an example of SD02B connected to switches.
ROBOT . HEAD to TOE Product User’s Manual – SD02B 5.4 Connecting to Microcontroller through UART A new feature for SD02B is the UART interface for easier communication between a host (user’s circuit or PC) and SD02B. By using the UART control, user can on/off, run/brake and change motor rotation direction in a simple commands.
ROBOT . HEAD to TOE Product User’s Manual – SD02B a. Sample schematic on above shows a PIC16F877A interface to SD02B. No restriction to what type or brand of microcontroller can be used, as long as it has UART peripheral. b. User needs to connect the RX and TX pin to microcontroller. These two pins should be cross connected to microcontroller.
ROBOT . HEAD to TOE Product User’s Manual – SD02B 5.4.2 Connecting SD02B to Computer Another concern in controlling stepper motor using a computer is the hard work needed to get started. However, with SD02B, interfacing with a computer is as easy as 1 2 3. Normally, user will need to develop a RS232 level shifter for communication to serial port. This generates extra work. Furthermore, laptop and computer nowadays have phase-out the serial port and replaced it with USB.
ROBOT . HEAD to TOE Product User’s Manual – SD02B b. Figure below shows the setup of SD02B to a stepper motor. c. To interface with a computer, simply connect UC00A 4-pin connector to SD02B and the USB end to PC as shown in the following figure. Please note that the TX and RX pins between SD02B and UC00A are cross-connected. Connect to PC/Laptop Created by Cytron Technologies Sdn. Bhd.
ROBOT . HEAD to TOE Product User’s Manual – SD02B d. Please refer to documents named “USB Driver Installation Guide” included in UC00A package for driver installation. e. After plugged in UC00A to computer and installed the driver, user is ready to test the functionality of SD02B using SD02B GUI. 5.5 Enable and Disable the driver As stated in the Absolute Maximum Rating in chapter 3 (Product Specification and Limitations), the current consumed may raises up to 2.53A at certain situation.
ROBOT . HEAD to TOE Product User’s Manual – SD02B 6. INSTALLATION SOFTWARE There are 2 options of sample software being provided for SD02B. The simplest way is to use the sample GUI program which can be run without the need to be installed on the computer, while another option is the sample program for PIC18F4520 to control two stepper motors through two SD02Bs. 6.1 Sample Program for Computer To ease user in using SD02B, Cytron Technologies has developed a SD02B GUI using VB.
ROBOT . HEAD to TOE Product User’s Manual – SD02B 4. After Run is clicked, a window will pop out, following figure show the window. 5. Before any setup can be done, please ensure hardware installation of SD02B is being setup correctly and power to stepper motor is connected. If you are using UC00A, UC00A’s driver must be installed. 6. After hardware installation, choose the COM Ports. Normally, the extra virtual COM port will be the largest number port after driver installation. Select it.
ROBOT . HEAD to TOE Product User’s Manual – SD02B CONNECT button has changed to DISCONNECT. Click this button to disconnect 8. Now, SD02B GUI is ready to control the stepper motor using SD02B.
ROBOT . HEAD to TOE Product User’s Manual – SD02B SD02B GUI Description Select COM port Select baudrate Click this button to connect ON/OFF, GO/BRAKE and CW/CCW for stepper motor. Show current encoder value. Set encoder value to stop stepper motor. Stepper motor will brake when encoder reach the value. Set acceleration for stepper motor. User may accelerate or deaccelerate stepper motor. Set speed for stepper motor. Disable or enable microstepping. User may choose micro-stepping types.
ROBOT . HEAD to TOE Product User’s Manual – SD02B 6.2 Sample Program for PIC18F4520 Driving stepper motor is common necessity in most robotic project based on the embedded system which uses microcontroller. Considering this reason, Cytron Technologies has also developed the sample source code for PIC18F microcontroller using MPLAB C18 C Compiler. This sample program is developed for PIC18F4520.
ROBOT . HEAD to TOE Product User’s Manual – SD02B 7. GETTING STARTED Please refer to PR7, DIY project from Cytron website for details example of using SD02B. This DIY project also shows the method to write a program to control SD02B through the Signal Input pins on SD02B. The link to PR7 DIY project is: http://www.cytron.com.my/PR7.asp This section will show how to get started with SD02B and connect to UART communication.
ROBOT . HEAD to TOE Product User’s Manual – SD02B d. Once the status is connected, user is free to control stepper motor using SD02B. e. If you wish to communicate at higher baudrate, you may select the desired baudrate from the list and click on “Set New Baudrate” button. This will change the baudrate at both the GUI and SD02B. Press Reset button on SD02B will change the baudrate to its default value, which is 9600. f.
ROBOT . HEAD to TOE Product User’s Manual – SD02B 7.2 Using SD02B with microcontroller This section will show the example of using PIC18F4520 as host to control two SD02Bs through UART interface. The sample program is based on SK40B startup kit. This sample program is developed for PIC18F4520. If user uses different PIC microcontroller, user may need to modify the sample program based on that particular microcontroller by referring to its datasheet released by Microchip Technology Inc.
ROBOT . HEAD to TOE Product User’s Manual – SD02B c. Load 18F sample program.hex to PIC18F4520 using UIC00A. User may refer to UIC00A user’s manual on how to load program into a PIC. User may use other programmer to load the program. Connect to UIC00A Connect to power source d. For communication between these two SD02Bs and SK40B, the following connections are required. i. ii. iii. iv. v.
ROBOT .
ROBOT . HEAD to TOE Product User’s Manual – SD02B e. Select Vmotor using the mini jumper at SD02B’s voltage selector. To supply power to SD02B, user has to connect SD02B Vmotor to SK40B positive (+) power supply pin and GND to SK40B negative (-) power supply pin. In this case, we use a 12V Sealed Lead-Acid battery to supply SK40B. Once power is ON, power indicator LED on both SK40B and SD02B will turn ON. Created by Cytron Technologies Sdn. Bhd.
ROBOT . HEAD to TOE Product User’s Manual – SD02B f. Next, connect the stepper motors to SD02Bs. g. Now press the SW on SK40B to test the program. Every time the switch is pressed, SK40B sends some commands to either one SD02B or both SD02Bs. Please refer to sample program 18F4520-dual uart sample.c file for the description. Created by Cytron Technologies Sdn. Bhd.
ROBOT . HEAD to TOE Product User’s Manual – SD02B 7.3 SD02B UART Protocol If you are using the UART protocol to control SD02B, both computer and microcontroller are actually sending serial command to SD02B. This section explains the protocol for send/receive commands. Created by Cytron Technologies Sdn. Bhd.
ROBOT . HEAD to TOE Product User’s Manual – SD02B On/Off, Run/Brake, CW/CCW and Reset Encoder Value Host sends 1 byte command to SD02B to On/Off, Run/Brake, CW/CCW and reset encoder value. Set Stepper Motor Speed a. Host sends ‘S’ to SD02B to set stepper motor’s speed. b. After sent the first command, host need to send 8 bit speed value to SD02B. The speed value is from 1 to 255. If SD02B receives ‘0’, the speed is assumed as 1. However, the speed for each stepper motor is different.
ROBOT . HEAD to TOE Product User’s Manual – SD02B Request Encoder Value a. Host sends command ‘E’ (1 byte) to SD02B to request encoder value. Encoder value is the number of steps upon reset. b. After sent command to request encoder value, SD02B will send 1 byte for higher 8 bits current encoder value and another 1 byte for lower 8 bits current encoder value to the host.
ROBOT . HEAD to TOE Product User’s Manual – SD02B d. AND the 16 bits variable with 0xFF00 11010110XXXXXXXX2 AND 11111111000000002 = 11010110000000002 e. After received higher 8 bits encoder value, host will receive the lower 8 bits encoder value from SD02B. Save the lower 8 bits encoder value to another 16 bits variable. x x x x x x x x 0 1 1 1 0 1 1 0 f. AND the 16 bits variable with 0x00FF XXXXXXXX011101102 AND 00000000111111112 = 000000000011101102 g.
ROBOT . HEAD to TOE Product User’s Manual – SD02B c. To get higher 8 bits, rotate/shift the 16 bits value 8 times to the right.
ROBOT . HEAD to TOE Product User’s Manual – SD02B Set UART Baudrate a. The default baudrate for SD02B is 9600. However user can define new baudrate for UART communication after the host and SD02B is connected at 9600. Host needs to send ‘U’ to set new baudrate for communication with SD02B. b. The standard baudrates for SD02B are 9600bps, 19200bps, 38400bps and 57600bps. After sent the first command, host has to send the 8 bit value to SD02B according to the explanation below.
ROBOT . HEAD to TOE Product User’s Manual – SD02B 1/10, 1/5 or 1/2 Micro-stepping and Non-micro-stepping a. Host needs to send ‘M’ and followed by 1 byte value which indicates the stepping mode to SD02B. Any values other than the given ones will be ignored by SD02B. 1 = no micro-stepping 2 = 1/2 micro-stepping 5 = 1/5 micro-stepping 10 = 1/10 micro-stepping Send this 8 bit value to SD02B to choose the stepping mode. b.
ROBOT . HEAD to TOE Product User’s Manual – SD02B 8. WARRANTY ¾ ¾ ¾ ¾ Product warranty is valid for 6 months. Warranty only applies to manufacturing defect. Damage caused by miss-use is not covered under warranty. Warranty does not cover freight cost for both ways. 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: support@cytron.com.my sales@cytron.com.