Sie sind auf Seite 1von 5

Maker studio

Balanbot Communicate Protocol

Version

Data

Responsibility

Remark

V1.0

2014/10/13

Ryan.Qin

New

Maker studio

Overview
This protocol describes packet that needed to communicate with balanbot, the packet contains
messages like adjusting PID parameter,controlling movement, robot status etc.And at last,some
examples are giving.
Using Master-Slaver mode, the controller is master, and balanbot is slaver.
Using USART: Baud:9600,Data:8bit, Stop:1bit, No check.

2 Packet format
Master transmits one packet, slaver receive it and takes action right now.
There is no address info in packet, so pairing is needed before communication.Recommend using
blue-tooth method,set it into transparent transport mode.
Every packet is limited-length6Byte length as show below
Start

Type

Data

Check

Byte 5

Byte 4

Byte 3

Byte 2

Byte 1

Byte 0

0xAA

0x00

0x00

0x00

0x00

0xAA

Start byte transmit fist,the others transmit one by one until the check byte finishing.The same as
receiving.
Check byte: XOR operation: Byte0 = Byte1^Byte2^Byte3.
Suggestion: Every packet must be checked before confirmation.The XOR operation cost less CPU
computational power.

3 Definition

1Type

Type (Byte4)

meaning

0x01

No use

0x02

Update PID parameters

0x03

Control movement

0x04

Apply for uploading PID parameters

0x05

Write current PID parameters in EEPROM

0x06

Balanbot Mode

0x07

Control LED
1

Maker studio

0x08

Control sound

2Data
2.1Type: 0x01
2.2Type: 0x02
Byte 3
PID
0x01P_angle
0x02D_angle
0x03P_position
0x04I_position
0x05Base(must be positive)

Byte 2

Byte 1

Byte2:high byteByte1:low byte


Combine Byte2 and Byte1 together then divide 100,you can get
the real PID parameter
Rang0.00~655.35

Slaver dont return anything after it receives packet.


About base:
The reference angle Rang is -5.00~5.00corresponding to the Base value:5.00~15.00
Base = 5.00 reference angle:-5
Base = 10.00reference angle:0
Base = 15.00reference angle:5
2.3Type:0x03
Byte 3

Byte 2

Byte 1

Direction
0x00Stop
0x01Forward
0x02Backward
0x03Left
0x04Right
0x05Left-Forward
0x06Right-Forward
0x07Right-Backward
0x08Left-Backward

No use

Speed0~255

Slaver dont return anything after it receives packet.


2.4Type:0x04
Byte 3

Byte 2

Byte 1

PID

No use

No use

Maker studio

0x01P_angle
0x02D_angle
0x03P_position
0x04I_position
0x05Base(must be positive)
Slaver will return a packet after it receive this type of packet.
The return packet format:
Byte3:the type of PID that apply for
Byte2 and Byte1: Byte2(High byte) and Byte1(low byte) get together then divide 100 is the real
PID value.
2.5Type:0x05
Byte 3

Byte 2

Byte 1

0x05

No use

No use

Slaver dont return anything after it receives packet.


2.6Type:0x06
Byte 3

Byte 2

Byte 1

Robot Mode
0x01work
0x02snooze
0x03sleep

No use

No use

Slaver dont return anything after it receives packet.


2.7Type:0x07
Byte 3
LED
0x00off
0x01on
0x02Blink
0x03Breathing

Byte 2

Byte 1

Only when Byte3 is 0x02,this two Bytes are useful,the two bytes
represent period of blink.
Byte2 is high byte,Byte1 is low byte.

Slaver dont return anything after it receives packet.


2.8Type:0x08
Byte 3

Byte 2

Byte 1

Sound
0x00off
0x01on
0x00alarm

No use

No use

Slaver dont return anything after it receives packet.

Maker studio

4 Example
1Turn the P value of angle to 24.56
Master send
Byte 5

Byte 4

Byte 3

Byte 2

Byte 1

Byte 0

0xAA

0x02

0x01

0x09

0x49

0x41

24.56 * 100 = 2456 = 0x0949


2Read the P value of angle
Master send
Byte 5

Byte 4

Byte 3

Byte 2

Byte 1

Byte 0

0xAA

0x04

0x01

0x00

0x00

0x01

Byte 5

Byte 4

Byte 3

Byte 2

Byte 1

Byte 0

0xAA

0x04

0x01

0x09

0x49

0x41

Slaver reply

Byte2 and Byte1is the value of P


3Write current PID parameter into EEPROOM
Byte 5

Byte 4

Byte 3

Byte 2

Byte 1

Byte 0

0xAA

0x05

0x00

0x00

0x00

0x00

4Make balanbot move forward


Master send
Byte 5

Byte 4

Byte 3

Byte 2

Byte 1

Byte 0

0xAA

0x03

0x01

0x00

0x14

0x15

Speed : Byte1 = 0x14 = 20

Das könnte Ihnen auch gefallen