Tom's RC
Hardware & Software Solutions for RC, Robotics, Animatronics

home

products

contact

projects

download

shop

 

 

SC8000 Programming

 
 
  Communication Protocol (updated 12MAY05)

For most applications, you can use the simple function calls to the included DLL. However, you may need to communicate directly to the SC8000 by sending serial data. Basic understanding of bit-wise manipulation is required. The serial port is set up as: 9600, No Parity, 8 Data bits, 1 stop bit, no flow control (9600N81)

The communication "data frame" of serial data stream consists of:

  • 2 bytes for synch. This denotes the beginning of a communication frame. The synch bytes are two tilde: "~~"; or two decimal 126; or two hex 0x7E.

  • 1 byte Servo Axis Mask. Decimal 0 to 255. With 0 as no Servo Axis being sent, and 255 as all 8 Servo Axis to follow.

  • 1 byte Digital IO Mask. This is the ASCII representation of the "HEX" digital IO mask. Since there are only 4 digital IO lines, all combinations of the 4 on/off value is within the range of 0 to 15, or hex 0 to F. Important: the actual byte sent is not the decimal 0 to F but rather the ASCII character 0 (decimal 48) to F (decimal 70).

  • 2 byte integer value(s) of the Servo Axis Position Data Pulse Width. The unit is of the data is in 0.1 usec. Acceptable range is 8000 (0.8 ms) to 22000 (2.2 ms). For the two bytes integer, the high-byte will be sent first, then the low-byte. Depending on how many Servo Axis are present in the Servo Axis Mask, the same number of 2 bytes integer values must follow.

 

Data Frame
required if necessary
byte
1
byte
2
byte
3
byte
4
byte
5
byte
6
byte
7
byte
8
byte
9
byte
10
byte
11
byte
12
byte
13
byte
14
byte
15
byte
16
byte
17
byte
18
byte
19
byte
20
synch servo
mask

digital
mask

servo
data
servo
data
servo
data
servo
data
servo
data
servo
data
servo
data
servo
data

Depending on the servo mask (byte 4), the servo data bytes will follow in 2 bytes integer (short) value for each servo axis with the bit ON. The unit is in 0.1 usec.

Typical range is integer value of 10000 (1.0000 milliseconds) to 20000 (2.0000 milliseconds)

The digital mask is a bit tricky. It's the "ASCII representation" of the HEX value, representing the binary mask of the digital ON OFF positions. See The following table for all possible values:

ASCII

decimal

representative binary value of digital axis (1:ON, 0:OFF)

0 48 0000
1 49 0001
2 50 0010
3 51 0011
4 52 0100
5 53 0101
6 54 0110
7 55 0111
8 56 1000
9 57 1001
A 65 1010
B 66 1011
C 67 1100
D 68 1101
E 69 1110
F 70 1111
The servo mask decimal value representing the binary mask of the servo axis to be updated. If the value is 0 (binary 00000000), then no axis are to be updated; no servos data to follow. If the value is 133 (binary 10000101), then there are 3 servo axis to be updated (axis 1, 3, and 8); three servo data integer values to follow.
The Synch bytes are always two ASCII tilde "~~" (decimal 126)

As you can see, the data frame can be as short as 4 bytes (no servo axis position data) to 20 bytes (all servos axis position data).
 

 
  Example

Turn on Digital axis 1 and 3, also move servos 3 and 5 to position 1.250 and 1.905 milliseconds respectively. Since we will be moving 2 servo axis, the total bytes to be sent will be 8 bytes.

(2) Synch Bytes

First, we will send the synch bytes, two tildes (~~), or two decimal 126.

(1) Servo Mask Byte

If you want to move axis 3 and 5, the binary representation of these two axis would be 00010100, or decimal 20; the servo mask (byte 4) We will send decimal 20.

(1) Digital Mask Byte

The binary mask value for axis 1 and 3 is 0101, which is hex "5". We will send the ASCII character "5", or decimal 53

(4) Servo Data Bytes

Since there are two servos axis present in the mask, we will now send 4 bytes of servo position data; two bytes (short integer) for each axis.

The first integer value is 12500, representing 1.250 miliseconds. The integer 12500 is 0011000011010100 in binary. Which is a high byte of 00110000 binary (decimal 48) and the low byte of 11010100 (decimal 212). We will first send the high-byte, decimal 48; then the low-byte, decimal 212.

Similarly, the second integer value is 19050. or decimal 74 and 106.

 
 

Windows DLL

You can use the above protocol specifications to program the SC-8000. To further ease some of the Serial Port programming learning curve, a windows DLL is provided to get you going quickly. The interface to the DLL provides an easy to use and simple API to send data to the SC8000. Up to 4 simultaneous controllers can be used with the DLL. There are only a few calls to the DLL, the following are the C function prototypes:

 

int SC8_Initialize (int PortNum);

void SC8_SendPositions (int BoardNum, unsigned char Mask, char DIO, unsigned short *pValue);

void SC8_SendPos(int BoardNum, int Axis, unsigned short Position);

void SC8_SendDigital(int BoardNum, int DigitalAxis, int ONOFF);

void SC8_CleanUP (int BoardNum);

The SC8_Initialize function will return a Board Number, to be used for subsequent calls.

If the call is successful, the Board Number will return a value starting with 1 (then 2, 3, etc... for subsequent boards).

If the communication fails (ex: not connected). The return value is 0. 

The PortNum parameter is the COM port value.

The SC8_SendPositions is the most complex function. It is used send data to update both the digital output and servo axis.

The parameter BoardNum is the Board Number returned from the SC8_Initialze function above. If the board has not been initialized, the function does nothing.

The parameter Mask is a one byte (unsigned char) value for which each axis is one bit in the binary representation. If the bit value is a binary 1, then the axis will be updated with position data to be followed. Example: Mask is decimal 27, or binary 00011011, would mean four axis are to be updated, the axis are (starting from the right, least significant):

Axis 1: YES
Axis 2: YES
Axis 3: NO
Axis 4: YES
Axis 5: YES
Axis 6: NO
Axis 7: NO
Axis 8: NO

The parameter DIO is a bit tricky. Since it's a ASCII representation of the Hex value.

Example: you would like to turn on the digital output 1, 2 and 4, and turn OFF digital outputs 3. In binary (easier to see than hex), that would be 1011, or B as a hex value; then DIO is the "ASCII character" B.

Similarly, for 0011, or 3 as a hex; DIO is the "ASCII character" 3

The parameter pValue is a pointer to an array of unsigned short values. The number of values in the array must match the number of Axis that position data is expected, indicated earlier in the Mask parameter. Using the example above for Mask, the array will contains four values, the first value is for Axis1, then Axis2, then Axis4, then Axis5.

The SC8_SendPos is a simpler function to send position data to one servo axis.

The parameter BoardNum is the Board Number returned from the SC8_Initialze function above. If the board has not been initialized, the function does nothing.

The parameter Axis is the Axis number (1 to 8) to be updated.

The parameter Position is the position data.

The SC8_SendDigital is a simpler function to turn ON or OFF one digital IO.

The parameter BoardNum is the Board Number returned from the SC8_Initialze function above. If the board has not been initialized, the function does nothing.

The parameter DigitalAxis is the digital output (1 to 4) to be updated

The parameter ONOFF is a value for the state of the digital output. A value of 0 will turn the digital output OFF (low), any other values will turn the output ON (high).

The SC8_CleanUp function should be used just before your application end. The parameter BoardNum is the Board Number returned from the SC8_Initialze function above