The RobotHead has 6 servos from Hitec. These servos have only reverse engineered documentation which is linked below.
Reverse engineered documentation: hsr8498hb_servo.pdf, hsr_serial_communication.pdf
An interface board with a LPC1769 was designed to provide a high-level interface for the servos.
It communicates with a PC through UART at a 1 Mbps with 8 bits words, no parity and one stop bit with hardware flow control through RTS/CTS.
All the material produced is in the shared folder at Projects/RobotHead6DOF.
(One Time) Preparation of Servos:
All servos are connected in parallel on a data bus. Each servo is identified by an (internal) ID number. Factory default ID number for all servos is “0”. You need to change the default ID to a unique number (1..255) to avoid bus conflicts.
To change an individual Servo's ID, connect only that one servo to the board, and use the command “!I=b\n” to set the servo ID to <b>.
By convention we assign the “outmost” servo the smallest number; i.e. servos that turn other servos when moving have lower IDs. For the robot head we suggest:
- neck-pan-ID 0
- neck-tilt-ID 1
- left-eye-pan-ID 2
- left-eye-tilt-ID 3
- right-eye-pan-ID 4
- right-eye-tilt-ID 5
Supported Commands:
All commands need to be terminated by ‘\n’; i.e. <return> and are case insensitive.
These servos are connected on the same bus and they stop to process new commands so the frequency of new commands should be rather small (maybe 50 to 60Hz).
?I - get servo id and version!I=b - set servo id to b
?C - display checksums(the current and correct)
!D+b,p - enable sensors streaming, ??D to show options!D-[b] - disable sensors streaming, ??D to show options?Db - get sensor readouts according to bitfield b??D - bitfield b options
?Ex - print verbose explanation of the error x??E - print error table
?Maddress - read address from servo memory!Maddress=data - write to servo memory address?MEaddress - read address from servo EEPROM memory!MEaddress=data - write to servo EEPROM memory address
!P[0-8],p - set servo position!PA[0-8],p[|] - set multiple servos position, | as separator of id,p!PR - reset servo position to safe value?P[0-8] - get servo position?PA - get all servos positions
!R - release servos
!S[0-8],s - set servo velocity!SA[0-8],s[|] - set multiple servos velocity, | as separator of id,s?S[0-8] - get servo velocity?SA - get all servos velocities
?V - get servos voltage
!U=x - set baud rate to x!U[0,1] - UART echo mode (none, all)
?? - display (this) help
Position and Speed Arguments
The positions for each servo varies between 500 and 2500 where 1500 is the center position of the servo rotation.
The speed for servos can be set to a number between 1 and 255 although according to the available documentation, the actual velocity saturates much earlier.
Example for settings multiple motors' position with a single command
PA0,1500|1,1500|2,1900\n
This command sets the motors with id 0 and 1 to position 1500 and motor with id 2 to position 1900.
Enabling / Disabling Data Streaming
Use the !D command to enable or disable data streaming.
Format: !D[+/-]b,p
where p is the period (in milliseconds and ignored when disabling) and b is a bitfield (see below).
Example: !d+1545,8 will stream the position 0, position 3, all positions and the voltage level at 125 Hz.
Reply:-P0 1250\n-P3 550\n-PA 1250 0 0 550 0 0 0 0 0\n-V7250\n
If any value is negative, it means an error occurred while attempting to read the value.
| Bit | Decimal Values | Name | # Values | Description | Format per Value | since Version |
|---|---|---|---|---|---|---|
| 0 | 1 | POSITION0 | 1 | servo0 position | up to 4 digits | 1.0 |
| 1 | 2 | POSITION1 | 1 | servo1 position | up to 4 digits | 1.0 |
| 2 | 4 | POSITION2 | 1 | servo2 position | up to 4 digits | 1.0 |
| 3 | 8 | POSITION3 | 1 | servo3 position | up to 4 digits | 1.0 |
| 4 | 16 | POSITION4 | 1 | servo4 position | up to 4 digits | 1.0 |
| 5 | 32 | POSITION5 | 1 | servo5 position | up to 4 digits | 1.0 |
| 6 | 64 | POSITION6 | 1 | servo6 position | up to 4 digits | 1.0 |
| 7 | 128 | POSITION7 | 1 | servo7 position | up to 4 digits | 1.0 |
| 8 | 256 | POSITION8 | 1 | servo8 position | up to 4 digits | 1.0 |
| 9 | 512 | ALL POSITIONS | 9 | all servos' positions | up to 4 digits | 0.1 |
| 10 | 1024 | VOLTAGE | 1 | servos' voltages | up to 4 digits | 0.1 |