Smart Peripheral Controller Neo DC Motor 1.2A Trademarks & Copyright AT, IBM, and PC are trademarks of International Business Machines Corp. Pentium is a registered trademark of Intel Corporation. Windows is a registered trademark of Microsoft Corporation. CodeVisionAVR is copyright by Pavel Haiduc, HP InfoTech s.r.l.
Table Of Contents 1 Introduction... 3 1.1 SPC NEO DC MOTOR 1.2A Specification... 3 1.2 Suggested System... 3 2 SPC NEO DC MOTOR 1.2A Hardware... 3 2.1 SPC NEO DC MOTOR 1.2A Component Layout... 3 2.2 Connectors and Jumpers Configurations... 4 3 SPC NEO DC MOTOR 1.2A Interface... 5 3.1 UART TTL Interface... 5 3.2 I 2 C Interface... 5 3.3 Set... 5 3.3.1 M1 Forward... 6 3.3.2 M1 Reverse... 6 3.3.3 M1 Stop... 7 3.3.4 M1 Brake... 7 3.3.5 M2 Forward... 8 3.3.6 M2 Reverse... 8 3.3.7 M2 Stop... 9 3.3.8 M2 Brake... 9 3.3.9 All Stop... 10 3.3.10 All Brake... 10 3.3.11 All Forward... 10 3.3.12 All Reverse... 11 3.3.13 Set PWM Frequency... 11 3.3.14 Set I 2 C Address... 12 3.3.15 Read I 2 C Address... 12 4 Testing Procedure... 13 5 Application and Program Example... 13 Attachment A. SPC NEO DC MOTOR 1.2A Schematics... 15 2
1. INTRODUCTION Smart Peripheral Controller / SPC NEO DC MOTOR 1.2A is a DC motor controller module which is compact, reliable, and compatible for robotic applications. This module can be used to control the direction and speed of 2 DC motors using Pulse Width Modulation (PWM) method. This module is equipped with dual full H-bridge driver, UART TTL interface, and I 2 C interface, so that it can easily be connected with other systems. 1.1. SPC NEO DC MOTOR 1.2A SPECIFICATION SPC NEO DC MOTOR 1.2A specification is as follows: The module requires 4.8 5.4 VDC power supply. The motor requires 2.5 13.5 VDC power supply. Uses a TB6612FNG motor driver IC. Each driver's maximum continuous current is 1.2 A. Available PWM frequencies are 21.68 khz, 2.71 khz (default), 338.8 Hz, and 84.7 Hz. Input/Output pins are compatible with TTL and CMOS voltage level. Equipped with UART TTL and I 2 C interface. Using I 2 C, SPC NEO DC MOTOR 1.2A can be cascaded up to 8 modules. Module uses a 16 pins 600mil DIP connector configuration which is easier to connect directly to project board or PCB matrix. 1.2. SUGGESTED SYSTEM Suggested system for SPC NEO DC MOTOR 1.2A is as follows: Hardware: PC AT Pentium IBM Compatible with USB port. DT-AVR Low Cost Series. DVD-ROM Drive and Hard disk. Software: Windows XP Operating System. CodeVisionAVR. Program CD/DVD contents: Contoh_i2c folder, contoh_uart folder, TB6612FNG.pdf, and SPC Neo DC Motor 1.2A Manual.pdf. 2. SPC NEO DC MOTOR 1.2A HARDWARES 2.1. SPC NEO DC MOTOR 1.2A COMPONENT LAYOUT 3
2.2. CONNECTORS AND JUMPERS CONFIGURATIONS INTERFACE PORT (J2) connector functions as a connector for module power supply input, UART TTL, and I 2 C interface. Pin Name 1,2 VIN Connected to power supply (4.8 5.4 Volts) 3 SCL I 2 C-bus clock input 4 SDA I 2 C-bus data input / output 5 RX TTL TTL serial level input to SPC module 6 TX TTL TTL serial level output from SPC module 7,8 PGND Ground reference for SPC module power supply MOTOR (J3) connector functions as a connector for motor power supply input and motors. Pin Name 1,2 VM Connected to motor power supply (2.5 13.5 Volts) 3 M11 1 st Output from H-Bridge M1 pair 4 M12 2 nd Output from H-Bridge M1 pair 5 M21 1 st Output from H-Bridge M2 pair 6 M22 2 nd Output from H-Bridge M2 pair 7,8 MGND Ground reference for motor power supply M11 and M12 are connected to DC motor 1, while M21 and M22 are connected to DC motor 2. SCL-SDA (J4) jumpers are used to activate pull-up resistors for SDA and SCL on I 2 C interface. Jumper SCL-SDA J4 SCL SDA Pull-up inactive (jumpers disconnected) SCL SDA Pull up active (jumpers connected) Important! If more than one module is connected to I 2 C-bus, then only one set of SCL- SDA (J4) jumpers needs to be connected. I 2 C address configuration can be done through UART TTL interface. LED M1 IND (D3) functions as DC motor 1's condition indicator. LED M2 IND (D4) functions as DC motor 2's condition indicator. 4
3. SPC NEO DC MOTOR 1.2A INTERFACE SPC NEO DC MOTOR 1.2A has UART TTL and I 2 C interfaces that can be used to receive commands or send data. 3.1. UART TTL INTERFACE UART TTL communication parameters are as follows: 38400 bps 8 data bits 1 stop bit no parity bit no flow control All commands sent through UART TTL interface begin with 1 byte data that contains <command number>, followed by (if needed) n-byte data command parameter. If the command sent is a command requesting data from the SPC NEO DC MOTOR 1.2A module, then SPC NEO DC MOTOR 1.2A will send the data via TX TTL line. Available commands and parameters can be seen in section 3.3. 3.2. I 2 C INTERFACE SPC NEO DC MOTOR 1.2A module has an I 2 C interface. In this interface, SPC NEO DC MOTOR 1.2A module acts as a slave with an address that has been determined via UART command (see section 3.3.14). I 2 C interface in SPC NEO STEPPER MOTOR 1.2A module supports bit rate up to a maximum rate of 50 khz. All commands sent through I 2 C interface begin with start condition, followed by 1 byte of SPC NEO DC MOTOR 1.2A module address. After the address is sent, the master must send 1 byte data that contains <command number>, followed by (if needed) n-byte command parameter data. After all command parameters have been sent, the command is ended with stop condition. The following is the sequence that must be done to send a command via I 2 C interface. Start + 1 1 1 0 X X X 0 + Write Address X X X X X X X X + X X X X X X X X + Parameter (if available) Stop Available commands and parameters can be seen in section 3.3. 3.3. COMMAND SET The following is a complete list of commands on UART and I 2 C interface: 5
3.3.1. M1 FORWARD Parameter Controls DC motor 1 forward rotation 0x30 <pwm level> 0-255 assigned duty cycle percentage (0 = 0% ; 255 = 100%). Description On forward condition, M11 will produce voltage proportional to the PWM value while M12 will be connected with MGND. On forward condition, M1 indicator LED will lit up green. Motor direction and PWM value will not be saved in EEPROM. When the SPC module is powered on, PWM value is 0 (zero), and the motor will be in a stop condition (M1 indicator LED will lit up orange). Example with UART interface to control the forward speed of DC motor connected to M1. If the desired duty cycle is 50% (0.5 * 255 = 128) or equal to 128 decimal and 0x80 hexadecimal: User : 0x30 0x80 i2c_write(0x30); i2c_write(0x80); // M1 Forward command // PWM value 3.3.2. M1 REVERSE Parameter Controls DC motor 1 reverse rotation 0x31 <pwm level> 0-255 assigned duty cycle percentage (0 = 0% ; 255 = 100%) Description On reverse condition, M12 will produce voltage proportional to the PWM value while M11 will be connected with MGND. On reverse condition, M1 indicator LED will lit up red. Motor direction and PWM value will not be saved in EEPROM. When the SPC module is powered on, PWM value is 0 (zero) and the motor will be in a stop condition (M1 indicator LED will lit up orange). Example with UART interface to control the reverse speed of DC motor connected to M1. If the desired duty cycle is 20% (0.25 * 255 = 64) or equal to 64 decimal and 0x40 hexadecimal: User : 0x31 0x40 6
i2c_write(0x31); i2c_write(0x40); // M1 Reverse command // PWM value 3.3.3. M1 STOP Stops DC motor 1 0x32 Parameter - Description On stop condition, M11 and M12 will be in a three state / high impedance condition. On stop condition, M1 indicator LED will lit up orange. Example with UART interface to stop DC motor connected to M1: User : 0x32 i2c_write(0x32); // M1 Stop command 3.3.4. M1 BRAKE Stops DC motor 1 quickly 0x33 Parameter - Description On brake condition, M11 and M12 will be connected to MGND. On brake condition, M1 indicator LED will lit up green and red alternately. Example with UART interface to quickly stop DC motor connected to M1: User : 0x33 i2c_write(0x33); // M1 Brake command 7
3.3.5. M2 FORWARD Parameter Controls DC motor 2 forward rotation 0x34 <pwm level> 0-255 assigned duty cycle percentage (0 = 0% ; 255 = 100%). Description On forward condition, M21 will produce voltage proportional to the PWM value while M22 will be connected with MGND. On forward condition, M2 indicator LED will lit up green. Motor direction and PWM value will not be saved in EEPROM. When the SPC module is powered on, PWM value is 0 (zero), and the motor will be in a stop condition (M2 indicator LED will lit up orange). Example with UART interface to control the forward speed of DC motor connected to M2. If the desired duty cycle is 10% (0.1 * 255 = 26) or equal to 28 decimal and 0x1A hexadecimal: User : 0x34 0x1A i2c_write(0x34); i2c_write(0x1a); // M2 Forward command // PWM value 3.3.6. M2 REVERSE Parameter Controls DC motor 2 reverse rotation 0x35 <pwm level> 0-255 assigned duty cycle percentage (0 = 0% ; 255 = 100%) Description On reverse condition, M22 will produce voltage proportional to the PWM value while M21 will be connected with MGND. On reverse condition, M2 indicator LED will lit up red. Motor direction and PWM value will not be saved in EEPROM. When the SPC module is powered on, PWM value is 0 (zero) and the motor will be in a stop condition (M2 indicator LED will lit up orange). Example with UART interface to control the reverse speed of DC motor connected to M2. If the desired duty cycle is 90% (0.9 * 255 = 230) or equal to 230 decimal and 0xE6 hexadecimal: User : 0x35 0xE6 8
i2c_write(0x35); i2c_write(0xe6); // M2 Reverse command // PWM value 3.3.7. M2 STOP Stops DC motor 2 0x36 Parameter - Description On stop condition, M21 and M22 will be in a three states / high impedance condition. On stop condition, M2 indicator LED will lit up orange. Example with UART interface to stop DC motor connected to M2: User : 0x36 i2c_write(0x36); // M2 Stop command 3.3.8. M2 BRAKE Stops DC motor 2 quickly 0x37 Parameter - Description On brake condition, M21 and M22 will be connected to MGND. On brake condition, M2 indicator LED will lit up green and red alternately. Example with UART interface to quickly stop DC motor connected to M2: User : 0x37 i2c_write(0x37); // M2 Brake command 9
3.3.9. ALL STOP Stops DC motors 1 and 2 simultaneously 0x38 Parameter - Description This command runs the M1 STOP and M2 STOP simultaneously. Example with UART interface to stop DC motors connected to M1 and M2 simultaneously: User : 0x38 i2c_write(0x38); // All Stop command 3.3.10. ALL BRAKE Stops DC motors 1 and 2 quickly and simultaneously 0x39 Parameter - Description This command runs the M1 BRAKE and M2 BRAKE simultaneously. Example with UART interface to quickly stop DC motors connected to M1 and M2 simultaneously: User : 0x39 i2c_write(0x39); // All Brake command 3.3.11. ALL FORWARD Parameter Controls DC motors 1 and 2 forward rotation simultaneously 0x3A <pwm level> 0-255 assigned duty cycle percentage (0 = 0% ; 255 = 100%) Description This command runs the M1 FORWARD and M2 FORWARD simultaneously with the same PWM value. 10
Example with UART interface to control the forward speed of DC motors connected to M1 and M2. If the desired duty cycle is 100% or equal to 255 decimal and 0xFF hexadecimal: User : 0x3A 0xFF i2c_write(0x3a); i2c_write(0xff); // All Forward command // PWM value 3.3.12. ALL REVERSE Parameter Controls DC motors 1 and 2 reverse rotation simultaneously 0x3B <pwm level> 0-255 assigned duty cycle percentage (0 = 0% ; 255 = 100%) Description This command runs the M1 REVERSE and M2 REVERSE simultaneously with the same PWM value. Example with UART interface to control the reverse speed of DC motors connected to M1 and M2. If the desired duty cycle is 75% (0.75 * 255 = 191) or equal to 191 decimal and 0xBF hexadecimal: User : 0x3B 0xBF i2c_write(0x3b); i2c_write(0xbf); // All Reverse command // PWM value 3.3.13. SET PWM FREQUENCY Parameter Sets the PWM frequency 0x40 <select> 0-3 0 means PWM frequency is = 21.68 khz 1 means PWM frequency is = 2.71 khz 2 means PWM frequency is = 338.8 Hz 3 means PWM frequency is = 84.7 Hz Description The default frequency is 2.71 khz. The selected PWM frequency will be saved in EEPROM. When the SPC module is powered on, the last saved frequency will be use as the PWM frequency. 11
Example with UART interface to set PWM frequency to 338.8 Hz: User : 0x40 0x02 i2c_write(0x40); i2c_write(0x02); // Set PWM Freq command // Selected frequency 3.3.14.SET I 2 C ADDRESS Changes I 2 C address 0x41 Parameter <0xAA> <0x55> <newaddress> Description This command can only be performed via UART communication line. SPC module will use the new I 2 C address after going through power off sequence. The allowed I 2 C address <newaddress> can be seen in the table below. If the new address given is incorrect, then the I 2 C address will not be changed (the previous address will be used). The default I 2 C address is 0xE0. I 2 C address data will be saved in EEPROM so it won't be erased when it's powered off. I 2 C Address I 2 C Write Address I 2 C Read Address 0xE0 0xE1 0xE2 0xE3 0xE4 0xE5 0xE6 0xE7 0xE8 0xE9 0xEA 0xEB 0xEC 0xED 0xEE 0xEF Example with UART interface to change the I 2 C address from 0xE0 to 0xE2: User : 0x41 0xAA 0x55 0xE2 3.3.15.READ I 2 C ADDRESS Reads the current I 2 C address 0x42 Parameter - Response <I 2 CAddress> Description This command can only be performed via UART communication line. SPC module's I 2 C address can also be seen through the number of blinks on the indicator LED when the module is 12
Example with UART interface: powered on. If the I 2 C address is 0xE0 then the indicator LED will blink green once. If the I 2 C address is 0xE2 then the indicator LED will blink green twice. If the I 2 C address is 0xE4 then the indicator LED will blink green 3 times, and so on until I 2 C address 0xEE at which the indicator LED will blink green 8 times. User : 0x42 SPC module : <I2CAddress> 4. TESTING PROCEDURE 1. Connect the 5 Volts power supply to VIN and VM SPC NEO DC MOTOR 1.2A module. 2. After the indicator LED blinks green according to I 2 C address, M1 and M2 indicator LEDs will lit up orange. 3. Send M1 Forward command with PWM value of 255 via UART TTL interface. 4. M1 indicator LED will lit up green. When the voltage between pin M11 and M12 is measured, the result will be close to the motor power supply voltage given on the VM pin. 5. Send M2 reverse command with PWM value of 255 via UART TTL interface. 6. M2 indicator LED will lit up red. When the voltage between pin M22 and M21 is measured, the result will be close to the motor power supply voltage given on the VM pin. 5. APPLICATION AND PROGRAM EXAMPLE As an application example, SPC NEO DC MOTOR 1.2A is used to run 2 DC motors with I 2 C or UART interface. DT-AVR Low Cost Micro System (LCMS) module with ATmega8535 microcontroller is used as master. VM (2.5V 13.5V ) VIN (+5 V ) M1 M2 M11 M12 M21 M22 SPC NEO DC MOTOR 1.2A (address 0xE0) SDA SCL SDA (PORTD.2) SCL (PORTD.3) DT-AVR LCMS MGND (Motor Power Supply Ground) PGND (Digital Power Supply Ground) 13
M1 M2 M11 M12 M21 M22 VM (2.5V 13.5V ) VIN (+5 V ) SPC NEO DC MOTOR 1.2A (address 0xE0) TXD RXD RX (PORTD.0) TX (PORTD.1) DT-AVR LCMS MGND (Motor Power Supply Ground) PGND (Digital Power Supply Ground) As an example program for the above application, there are two programs named contoh_i2c.c and contoh_uart.c (included in the CD/DVD) written using CodeVisionAVR 1.25.2 evaluation. In the program, DT-AVR LCMS will send "M1 Forward" and "M2 Forward" commands with PWM value of 255 for each motor to SPC module (for example, SPC's I 2 C address is 0xE0). After all of the commands are sent, DT- AVR LCMS will wait for 3000 ms. Afterward "All Brake" command will be sent to SPC followed by another 3000 ms delay. Then DT-AVR LCMS will send "M1 Reverse" and "M2 Reverse" command with PWM value of 128 for each motor to SPC module followed by another 3000 ms delay. The program ends with DT-AVR LCMS sending "All Stop" command to the SPC module. Thank you for your confidence in using our products, if there are difficulties, questions, or suggestions regarding this product please contact our technical support: support@innovativeelectronics.com 14
ATTACHMENTS A. SPC NEO DC MOTOR 1.2A Schematics 15