Infanoid | Keepon | ClayBot
Nihongo | English
What is Movado

Movado is a motion control software for Pico-2, which has been used in Infanoid and Keepon. Movado receives commands from a host PC through a serial communication line, and controls four DC motors with digital encoders in addition to another four RC-servos. A signle communication line can host up to 31 Pico-2s (hereafter "nodes"), which means you can control up to 124 DC motors and 124 RC-servos on a signel communication line. For details of connections with PC and motors, please refer to "ClayBot's Spec".

This page describes the command protocol, by which you can control Movado from your PC.

Command Protocol Syntax
6-byte packet

A command to Movado is a sequence of 6 byte data, called a "packet". As illustrated below, the first byte has its MSB=1, and the following 5 bytes have their MSB=0.

figure: Command packet of Pico-2

A packet consists of address (addr), motor number (n), instruction (inst), and 4 byte argument (quad).

32bit fixed-point data

The 32bit fixed-point data (fix) has a 16bit integer part (the upper 16bit of quad) and a 16bit fractional part (the lower 16bit of quad). The following C functions make conversion between fix and double.

typedef int fix;

fix  double2fix (double d) {
    return (fix) (d * 65536);
}

double  fix2double (fix f) {
    return f / 65536.0;
}
Command Protocol Semantics

When Movado received a command packet whose address matched Movado's address, Movado performs the command. There are 10 types of commands described as follows. Most commands operate on a motor specified by the address (addr) and the motor number (n).

command inst:3 fix:32 / quad:32
upper:16 lower:16
move 0 pos [rad]
setacc 1 acc (≥ 0) [rad/s2]
movac −acc_int (< 0) [rad/s2] pos_int [rad]
setvel 2 vel (≥ 0) [rad/s]
movel −vel_int (< 0) [rad/s] pos_int [rad]
setpos 3 pos [rad]
sub 4 sub-command
getacc 5 (1), (2) [rad/s2]
getvel 6 (1), (2) [rad/s]
getpos 7 (1), (2) [rad]
  (1) Ignored in command packets.
  (2) A value is stored in returning packets.
Sub-Command Protocol

Sub-commands are described below. Some sub-commands (m in N/m column) operate on a specified motor (by addr and n); other sub-commands (N in N/m column) operate on a specified node (by addr).

Parameter accessing commands

Movado's internal parameters, like PID gains, can be set/get by the following sub-commands. To set 32bit parameters, you need to perform set_lower first, then set_upper To get 32bit parameters, you need to perform get_upper first, then get_lower. If you want to check completion of move/movac/movel, read CAMOD. If you want to check completion of calibration (described below), read MMFLG.

sub-command N/m jnst:8 index:8 word:16
set_upper m 0x00 index upper
set_lower N 0x00 0xff lower
set_word m 0x01 index word
get_upper m 0x80 index (1), (2)
get_lower N 0x80 0xff (1), (2)
get_word m 0x81 index (1), (2)
  (1) Ignored in command pckaets.
  (2) A value is stored in returning packets.
32bit fixed-point paramters (part)
name index description
MIN 0x10    min position [rad] (set by do_min)
MAX 0x11    max position [rad] (set by do_max)
KP 0x12    gain for proportional control (def: 2.0)
KI 0x13    gain for integral control (def: 40.0)
KD 0x14    gain for differential control (def: 0.05)
VMP 0x15    motor power voltage [V] (def: 12.0)
16bit (word) parameters (part)
name index description
CAMOD 0x00    submode in CAM (0 for completion)
MMFLG 0x04    flag for do_min/max (0 for completion)
Calibration commands

Movado has automatic calibration system for motors with incremental encoders. The set_zero command forces current position as zero (POS=0). The do_max/do_min commands move to positive/negative physical limit and store the position into MIN/MAX parameters. The do_minmax performs do_min first, then do_max. The do_minmaxcen performs do_minmax, then move to the center, and finally perform set_zero. The do_minmaxmax performs do_minmax, then move to the maximum position, and finally perform set_zero. The do_minmaxmin performs do_minmax, then move to the maximum position, and finally perform set_zero.

For do* commands, Movado uses the maximum velocity (setvel) for finding the physical limits. The parameter emg stands for "error magnitude". When motion delay exceeds the amount of motion for emg [ms] period, Movado detects it as a physical limit. In most cases, emg should be 100~200.

sub-command N/m jnst:8 index:8 word:16
set_zero m 0x7f 0x00 (1)
do_max m 0x7f 0x05 emg
do_min m 0x7f 0x06 emg
do_minmax m 0x7f 0x07 emg
do_minmaxcen m 0x7f 0x08 emg
do_minmaxmax m 0x7f 0x09 emg
do_minmaxmin m 0x7f 0x0a emg
  (1) Ignored in command packets.
RC-servo control

Movado can control up to 4 RC-servos in the similar way to DC motors. The commands move_rcs uses Trapezoid Velocity Control, whose acceleration and maximum velocity can be set by setacc_rcs and setvel_rcs; while, setpos_rcs makes a ballistic motion. For most RC-servos, 0x2400 is approximately at the center.

sub-command N/m jnst:8 index:8 word:16
move_rcs m 0x70 0x00 pos_rcs
setacc_rcs m 0x70 0x01 acc_rcs
setvel_rcs m 0x70 0x02 vel_rcs
setpos_rcs m 0x70 0x03 pos_rcs
Other commands

The reset command resets Movado. The get_report command is for reporting current position at a cycle of interval [ms] for count times. Having received get_report command, Movado starts reporting current positions when move/movac/movel/setpos is performed. The report will be in the same packet for getpos command.

sub-command N/m jnst:8 index:8 word:16
reset N 0x7f 0xff (1)
get_report m 0xff interval count
  (1) Ignored in command packets.
Trapezoid Velocity Control
Basic trapezoid velocity control
figure: trapezoid velocity control
Consecutive "move"s
figure: consecutive trapezoid velocity control (1)
Consecutive "move"s with small acceleration
figure: consecutive trapezoid velocity control (2)
Other Functionalities
Auto-setup for encoder resolution
Pico-2 resolution/rev ERPC8 LPFA
ADDR [pulse, count] [rad/count×28] filter coeff.
0x00〜0x07 16, 64 25.133 0.0625
0x08〜0x0f 200, 800 2.0106 0.2500
0x10〜0x1e 256, 1024 1.5708 0.2500
Parameters related to encoder resolution
32bit fixed-point parameters
name index description
ERPC8 0x0f    encoder resolution [rad/count in s0824]
LPFA 0x19    coefficient of the velocity filter (LPF)
Margin for motion limits
32bit fixed-point parameters
name index description
PMAR 0x0a    safe margin [rad] (def: 1.0)