Introduction

''A. Please read this manual carefully before power on the device.

B. Do not use this device for military or medical purpose as they are not designed to.''

This Sensor/Motor Drive Board (Cortex M3 CPU) is the integration of multiple communication interfaces that quickly build robotic systems. This board (Cortex M3 CPU) features the SPI Interface and works as a bridge between the whole system. There are many types of sensors on the board such as I2C bus communication protocol sensors, Ultrasonic sensors, SP03 TTS, CMP03 electronic compass, RS485-bus sensors, analog output sensors, infrared distance sensors, gyro sensors, acceleration sensors, and light sensors etc. The RS23 serial port is used to send signals to the host PC or other embedded systems. At the same time SDB plates with two-way DC motor-driven, two-way rotary encoder interface and a PID motor control algorithms which can be controlled through the serial port. The mounting hole structure is compatible with PC104.

Specification

Pin out diagram

SDB Pin out Diagram

Compatible with PC104

Applying Power

sdb_v2.2_4.png

To power the SDB boards, simply connect the ground wire from your supply to the screw terminal labeled “GND”, and then connect the positive wire from your supply to the screw terminal labeled “+12V”. NOTE: DO NOT apply voltage over 15V DC.

Serial hardware configuration

RS232/TTL Selection Jumpers

The SDB board supports RS232/TTL interface. The RS232/TTL output mode is selected by jumpers.

Command Sets

Configure Servo Control Mode

Header Add Length Cmd I/O status SUM
0x55 0xaa 0x10 0x01 0x01 IO7~IO0

This command is used to configure the DIO to servo control mode.

The I/O status byte is calculated from Bit0:Bit7 which is mapped on IO0-IO7.

IO7 IO6 IO5 IO4 IO3 IO2 IO1 IO0
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0

When the IO Bit is set to 1, the servo mode is enabled. When IO bit is set to 0, the servo mode is disabled.

Examples:

For example, to set IO3 and IO4 as servo mode, the bit table is as the following:

I/O status = 0x18

IO7 IO6 IO5 IO4 IO3 IO2 IO1 IO0
0 0 0 1 1 0 0 0

And the I/O status byte is 00011000 = 0x18.

Set DIO Input/output Mode

Header Add Length Cmd I/O status H I/O status L SUM
0x55 0xaa 0x10 0x02 0x02 IO10~IO8 IO7~IO0

This command is used to set Digital Pin to input or output mode individually.

I/O status L

IO7 IO6 IO5 IO4 IO3 IO2 IO1 IO0
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0

I/O status H

N/A N/A N/A N/A N/A IO10 IO9 IO8
N/A N/A N/A N/A N/A Bit2 Bit1 Bit0

''NOTE: Before configure this DIO mode; the servo control mode must be disabled first. ''

Example:

IO7 IO6 IO5 IO4 IO3 IO2 IO1 IO0
0 0 0 0 0 1 1 0
N/A N/A N/A N/A N/A IO10 IO9 IO8
N/A N/A N/A N/A N/A 0 1 0

Set DIO Output

Header Add Length Cmd I/O Value H I/O Value L SUM
0x55 0xaa 0x10 0x02 0x03 IO10~IO8 IO7~IO0

I/O Value L

IO7 IO6 IO5 IO4 IO3 IO2 IO1 IO0
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0

I/O Value H

N/A N/A N/A N/A N/A IO10 IO9 IO8
N/A N/A N/A N/A N/A Bit2 Bit1 Bit0

When the Bit is set to 1, the output is HIGH, When the Bit is set to 0, the output is LOW.

NOTE: If one of the DIO is configured as Digital Input Mode, the command to set its output will be invalid.

Examples:

Read DIO Input

Header Add Length Cmd SUM
0x55 0xaa 0x10 0x00 0x04

This command reads the value on DIO when they are configured as Input Mode.

Return Data:

Header Add Length Cmd High Byte Low Byte SUM
0x55 0xaa 0x10 0x00 0x04 IO10~IO8 IO7~IO0

Example:

Servo Control

Header Add Length Cmd S0 Pos S0 Speed ... S10 Pos S10 Speed SUM
0x55 0xaa 0x10 0x22 0x05 0xD0 0xS0 ... 0xD10 0xS10

This command moves the servo at specific speeds.

After configuring the DIO0-7 to Servo control mode, this command is used to play the Servo with position and speed control.

"S0 Pos" is the position value of the servo. The value is from 0 to 180, and 90 is corresponding to the center position. "S0 Speed" is the speed value of the servo. The value is from 0 to 0xFF, and 0xFF stands for the highest speed.

Examples:

Read Analog Input (12 bits)

Header Add Length Cmd SUM
0x55 0xaa 0x10 0x00 0x06

This command reads the values on analog pins.

Returns:

Header Add Length Cmd AD0H AD0L ... AD7H AD7L SUM
0x55 0xaa 0x10 0x16 0x06 H L ... H L

The returned analog value consists of two bytes HIGH and LOW. 0xFF is mapping to 3.3V and 0x00 is mapping to 0V. ''NOTE: If the analog input exceeds 3.36V, the returned data may not be correct. ''

Example:

Configure RS485 Baud Rate

Header Add Length Cmd Baud Rate SUM
0x55 0xaa 0x10 0x01 0x07 Baud

This commands set the baud rate for RS485 Bus.

Baud Rate:

Example:

RS485 Communication

Send:

Header Add Length Cmd Data 0 ... Data n SUM
0x55 0xaa 0x10 N 0x08 Data 0 ... Data n

This command transmits the data via RS485 BUS from RS232/TTL. The length of data must not exceed 64.

Response:

Header Add Length Cmd Data 0 ... Data n SUM
0x55 9xaa 0x10 N 0x08 Data 0 ... Data n

The response data is transmitted to RS232/TTL.

Example:

Write Data via I2C

Header Add Length Cmd Device Add Start Add Data 0 ... Data n SUM
0x55 0xaa 0x10 N 0x09 Deviceaddr StartAddr Data0 ... Data n

This command writes data to device via I2C. The total data length must be less than 64 bytes.

Read Data via I2C

Header Add Length Cmd Address Start Add Data Length SUM
0x55 0xaa 0x10 0x03 0x0A Deviceaddr StartAddr Len

This command reads data from device via I2C. The total data length is less than 4 bytes.

Example:

Set Motor Parameters

Header Add Length Cmd ENCODER_PPR GearRatio WheelPerimeter SUM
0x55 0xaa 0x10 0x06 0x0B H L H

This commands set the parameters for DC motor speed control.

ENCODER_PPR: The pulse per rotation of encoder. (Default value 12) GearRatio: Gear ratio. For a 64:0 gear ratio, the value should be 640(0x02 0x80). (Default value 640) WheelPerimeter : The perimeter and the wheel (Default value 502 mm)

Set Motor Speed

Header Add Length Cmd M1_SPEED M2_SPEED MOTO_DIR SUM
0x55 0xaa 0x10 0x05 0x0C H L H

This commands set the speed of motor.

Motor 2 Motor 1
Bit7 Bit6
0 0

0 is forward, F is backward. For example, to set Motor 1 move forward while set Motor 2 move backward. The MOTO_DIR will be look like:

Motor 2 Motor 1
Bit7 Bit6
1 1

The actual value of the MOTO_DIR will be 0xF0.

Example:

Read Motor Speed

Header Add Length Cmd SUM
0x55 0xaa 0x10 0x00 0x0D

Return:

Header Add Length Cmd M1_PV_CPS M2_PV_CPS SUM
0x55 0xaa 0x10 0x04 0x0D H L

Read Motor Current

Header Add Length Cmd SUM
0x55 0xaa 0x10 0x00 0x0E

This command reads the motor current.

Return:

Header Add Length Cmd M1_Curent M2_Curent SUM
0x55 0xaa 0x10 0x04 0x0E H L

The current value is 16 bit which consists of two bytes (HIGH and LOW). The current unit is mA.

Set PID Parameters

Header Add Length Cmd P I D SUM
0x55 0xaa 0x10 0x03 0x0F Kprop Krate Kint

Kprop: Proportional gain Krate: Derivative gain Kint : Integral gain

''NOTE: The gain value must multiple by 10. For example, if the actual K is 0.1, then the Kprop must be 0.1x10 which 1(0x01). ''

Set Motor Driven Mode

Header Add Length Cmd Drive Mode SUM
0x55 0xaa 0x10 0x01 0x10 Mode

This command sets the motor driven mode. Mode:

Example:

Set Motor Power

Header Add Length Cmd Motor 1 Power Ratio Motor 2 Power Ratio SUM
0x55 0xaa 0x10 0x02 0x11 S1 S2

This commands set the power of the motors.

The value of power ratio S1/S2 is from 0-200. 100(0x64) stands for a full stop. 200(0xC8) stands for the maximum forward power. 0(0x00) stands for the maximum backward power.

Read encoder data

Header Add Length Cmd SUM
0x55 0xaa 0x10 0x00 0x12

Return:

Header Add Length Cmd M1_ENCODE M2_ENCODE SUM
0x55 0xaa 0x10 0x04 0x12 H L

M1_ENCODE、M2_ENCODE:Two bytes 16 bit value。Represent the rotation counter of the motors.

When change the direction of the motor, the encoder needs to be reset.

Example:

Reset Encoder Reading

Header Add Length Cmd SUM
0x55 0xaa 0x10 0x00 0x13

This commands reset the encoder’s counters.

Example

Read Board Version

Header Add Length Cmd SUM
0x55 0xaa 0x10 0x00 0xFF

This command reads the board version.

Return Data:

Header Add Length Cmd Board Code Version Revision SUM
0x55 0xaa 0x10 0x03 0xFF 0x01 V1 V2

Board Code: 0x01 (SDB Board) Version: Board main version Revision: Board revision

Example

Version Date Author Content
0.1 2010/4/25 Chen Create Document
1.0 2010/6/1 Chen First Version Released

DFshopping_car1.png Get Sensor/Motor Drive Board - Version 2.2 (SKU:DFR0057) from DFRobot Store or DFRobot Distributor.

Category: DFRobot > Arduino > Microcontrollers

category: Product Manual category: DFR Series category: Motor Controllers

Turn to the Top