SERVO CONTROLLER - SCORPION board V1.0

Elementz Engineers Guild have introduced the new Scorpion board which can be used to control 16 servos at the same time. It comes with a very affordable price and a good design. This wiki gives an idea about how the scorpion board can be used.

# Features

1. Offers a resolution less than 0.5 degrees
2. Can connect and control 16 Servo motors at the same time.
3. Board addressing feature is introduced for use of multiple boards at the same time.
4. The input is given serially (UART: baud rate 9600, 8 Data bits, 1 Stop bit, No Parity.)
5. Servos with any time range can be connected to the same board.
6. Servos can be controlled individually or as a block.
7. Block commands and independent commands can be mixed together for efficient coding.

# Pinout

Servo controller requires two power supplies(both 5 Volt) to turn the connected servos according to the command given.

User needs to give **5V supply** to the servo controller through Supply pins near the UART interface (RX and TX pins).

Servo power which is **5V** is supplied through terminal block(**SVCC** and **GND**) provided on board. This will give power for turning the servo. The supply current should be sufficient enough to turn all servos connected to the board. Consult the servo datasheet for determining the working current required for each servo.

## Pinout description

* Supply pins: Power supply input pins for the controller. 5V DC supply is to be given
* Supply input pins for servo: This is the supply pins for servo motor. 5V DC supply is to be given
* Servo Pins 1-16: This is where we connect the servo motors. They can be directly plugged into the board. The servo pins consist of a set of three pins and they are
	+ **SVCC**: The VCC pin of servomotor is connected here
	+ **Gnd**: The Ground pin of servo motor is connected here
	+ Control signal pins: The signal pin of servo motor is connected here

These pins are arranged such that the servo motor can be directly connected to
the board.

* UART pins: These are the pins used for giving input to the servo board.
* Reset Button: Used for resetting the board. Resetting does not change the address set and the last output written to the servo.

# Communication

Communication is done through the onboard serial interface. The serial pins are **TTL compatible**. Thus RS232 levels **should not** be used!!.

## Connecting to PC/Laptop

For connecting the Scorpion board to a PC, **USB to Serial** converters are required. TTL pins of the USB to Serial converters are to be connected to the scorpion board as follows.

*Connecting to a USB to TTL converter*
 TX
 RX
 GND
 VCC

## Connecting to a Microcontroller

Microcontrollers having UART communication, running with 5V/3.3V supply can be used to connect with the scorpion board for controlling the Servos attached. Connection details are given below.

*Connecting to a Microcontroller*
 TX
 RX
 GND
 VCC

### Using Arduino

#### Using hardware serial

```
/*
Author: Dhanish
Created on: 19-08-2015
Company: Elementz Engineers Guild Pvt Ltd
*/

void setup() {
   // initialize serial communications at 9600 bps:
   Serial.begin(9600);

   delay(10000);
   // print the serial data to Servo controller
   Serial.println("ADDR0C7P1500" ); // For rotating the 7th servo (channel 7)
   // wait 5 seconds before the next loop
   delay(5000);
   Serial.println("ADDR0C13P2400" ); // To move the 13th servo to 180 degree
}

void loop() {
}

```

#### Using software serial

```
/*
Author: Dhanish Vijayan
The circuit:
* RX is digital pin 10 (connect to TX of Servo controller)
* TX is digital pin 11 (connect to RX of Servo controller)
*/
#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11); // RX, TX

void setup()
{
   // Open serial communications and wait for port to open:
   Serial.begin(9600);

   Serial.println("Interfacing with Servo controller");

   // set the data rate for the SoftwareSerial port
   mySerial.begin(9600);
   delay(2000);
   mySerial.println("ADDR0C7P1500"); // For rotating the 7th servo (channel 7)

}

void loop() // run over and over
{
   // print response over serial port
   if (mySerial.available())
      Serial.write(mySerial.read());
}

```

### Using Rapberry-Pi

```
"""
author: dhanish
company: Elementz Engineers Guild Pvt Ltd
Created on Tue Aug 12 20:17:12 2015

"""

import serial
import time

ser = serial.Serial('/dev/ttyUSB0',9600,timeout=1) # 9600 is the default Baudrate for SIM900A modem
ser.flush()
ser.write('ADDR0C7P1500\r') # For rotating the 7th servo (channel 7)
#ser.read(2) # read 2 bytes of data from the serial port
time.sleep(5)   # wait for 5 seconds

ser.write('ADDR0C13P2400\r')  # To move the 13th servo to 180 degree
time.sleep(5)  # wait for 5 seconds
ser.close()    # close the serial port

```

## Connecting to Bluetooth module

Scorpion boards are capable of being controlled by Serial Bluetooth modules like HC-05 or HC-06. Thus, the servos can be controlled through PC or Mobile over Bluetooth SPP connection after pairing to the attached Bluetooth modules. The connection details are as below.

*Connecting to a Serial Bluetooth module*
 TX
 RX
 GND
 VCC

## Connecting to Zigbee module

Zigbee modules such as **XBEE/XBEE PRO, TARANG F4/P20** are proven to work with the scorpion 16 channel controller. The connection details are as follows.

*Connecting to a Zigbee module*
 TX
 RX
 GND
 VCC

# Command set and examples

## Controlling Servo motors individually

**Command** : ADDR<Address of the Board>C<Servo number>P<Required position><cr>

where

*servo control command(Single)*
 ADDR
 C
 P
 cr

**Response** : OK
 If the values given to the board are correct, the scorpion board replies with an **OK** response.

### Examples

Note: The servo used for examples is TOWER PRO MICRO SERVO SG90. The actual timings to be given varies with the servos used.

E.g.1: For rotating the 7th servo (channel 7) to 90 degree

```
                   ADDR0C7P1500<cr>

```

E.g.2: To move the 13th servo to 180 degree

```
                   ADDR0C13P2400<cr>

```

E.g.3: Instructions to control “multiple” servos at the same time. Move the 1st servo 180 degree and the 9th servo 90 degree and 15th servo also to 90 degree

```
                   ADDR0C1P2400C9P1500C15P1500<cr>

```

## Connecting Multiple servo motors using block commands

The servo pins are divided into four blocks. This helps when multiple servos are required to move together.

*Block mappings*
 1
 2
 3
 4

The command is given as below

**Command** : ADDR<Address of the Board>B<Block number>P<Required position>cr

*servo control command(Single)*
 ADDR
 B
 P
 cr/lf

**Response** : OK
 If the values given to the board are correct, the scorpion board replies with an **OK** response.

### Examples

Note: The servo used for examples is TOWER PRO MICRO SERVO SG90. The actual timings to be given varies with the servos used.

E.g.1: To move servos 13-16 to 180 degree

```
                   ADDR0B3P2400<cr>

```

E.g.2: To move servos 1-4 to 180 degree and servos 9-12 to 90 degree

```
                   ADDR0B1P2400B4P1500<cr>

```

E.g.3: To move all the servos to 90o

```
                   ADDR0B1P1500B2P1500B3P1500B4P1500<cr>

```

## Mixing individual and block commands

In some cases mixing the block and independent commands together can use for ease of coding.

E.g.1: To move servos 1-7 to 180 degree and servo 8 to 90 degree

```
                   ADDR0B1P2400B2P2400C8P1500<cr>

```

E.g.2: To move the third servo to 90 degree while all other servos to 180 degree

```
                   ADDR0B1P2400B2P2400B3P2400B4P2400C3P1500<cr>

```

Note: The Block command should precede the independent command for the mixing to be
effective

# Using multiple boards at the same time

For connecting multiple boards, the address of each Servo controller should be different.

Note: Connecting multiple servo does not support the cascading of TX pin of the Scorpion boards. So TX pins of the Scorpion boards which are connected in the same serial bus should be left open.

Use the following command to change the address of the scorpion board.

**Command** : AT+ADDR=<Address of the Board><cr>

*servo address configuration command*
 ADDR

For connecting multiple servo controllers to the same bus, the address of each Servo controller should be different.

Eg: Servo condroller 1 address = 0, Servo controller 2 address = 1, etc...