Beruflich Dokumente
Kultur Dokumente
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
0x03
Control movement
0x04
0x05
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
Byte 2
Byte 1
Direction
0x00Stop
0x01Forward
0x02Backward
0x03Left
0x04Right
0x05Left-Forward
0x06Right-Forward
0x07Right-Backward
0x08Left-Backward
No use
Speed0~255
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
Byte 2
Byte 1
Robot Mode
0x01work
0x02snooze
0x03sleep
No use
No use
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.
Byte 2
Byte 1
Sound
0x00off
0x01on
0x00alarm
No use
No use
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
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
Byte 4
Byte 3
Byte 2
Byte 1
Byte 0
0xAA
0x05
0x00
0x00
0x00
0x00
Byte 4
Byte 3
Byte 2
Byte 1
Byte 0
0xAA
0x03
0x01
0x00
0x14
0x15