SOFTWARE

1.  Install the RCS-6 Software on your hard disk.
2.  Plug in the robot
3.  Run rbx.bat to automatically load the Device Driver and start the Console Program

The first time through these steps will take about 20 minutes. After that, only steps 2 and 3 will be needed when you want to run the robot, and they will generally take no more than a minute.

NOTE: If you are installing version 1.04 or later on top of version 1.03 or earlier, please first delete *.rbc files and *.rst files, but not *.rbx files. To delete these files, from the DOS prompt in the c:\rbx directory do these commands:

del *.rbc
del *.rst

Installing RCS-6 Software

(If you will be running from a floppy disk instead of a hard disk, just make a copy of the RCS-6 disk using the DOS diskcopy command and put the original away. Now you can run right from the copy).

The software generally has to be installed on your hard drive just once. First, turn on your computer if you haven't done so already.

Next, insert the RCS-6 diskette into a floppy drive and make that drive current by entering, for instance,

     a:

if the diskette is in drive A.
Then enter

     install c:      (or D: if you want to install on the D drive, etc.).

The simple installation batch program will create the directories \rbx and \rbx\lib on the designated drive and then copy the installation files to these directories.

Remove the diskette and then change to the \rbx directory. That is, enter
     c:
     cd \rbx
assuming you installed on drive C.
At some point you may want to examine the ".doc" files in each of these directories. Each directory has at least a "readme.doc" file which describe what each file in the directory does. You can examine these .doc files by entering, for instance,
     type readme.doc |more

Which will (in this case) show you the file "readme.doc" one screen at a time. You can also use the DOS edit command to view these files.

Printer Port Setup: Plugging Things In

The steps below can be done in any order you like. Your computer (a PC or compatible) can be on or off when you begin.

Unplug the printer-end of your parallel printer cable and plug it into the RCS-6 Adapter.

You can also get a separate cable just for your robot and plug it into LPT2, if your computer has that port. If you don't have a parallel printer at all, but your printer has LPT1, you'll need to obtain a printer cable and plug it into LPT1.

If you have a choice, try to use a 6-foot molded cable as longer or hand-wired cables with poor shielding can sometimes cause jittering in the robot.

Starting Up Your Robot

If you are using LPT1, then from the \rbx directory run the batch file rbx.bat by entering

     rbx h     (if you are using Hitec servos)

***Notice:  rbx f          (if you are using Futaba servos)

Which loads the Device Driver as needed and then starts the Console Program.

However, if you are using LPT2 or LPT3, you need first to edit rbx.bat (using, say, the DOS edit program) to change the
     -p1
command line option of rbxdrv.exe from -p1 to either -p2 or -p3. Then run the rbx.bat batch file as described above.

If you have picked the wrong port or have missed a connection, you will get a message to check cabling and connections, and try again.

You should now have an active robot and the Console Program should be on screen.

The very first time you run the Console Program it will report that there is no rbxcon.rst file and that default settings will be used. Hit <enter> or <space> to acknowledge this message and proceed. From then on, each time you exit the Console Program it "remembers" where it was in rbxcon.rst. So, let's exit the Console Program by pressing

     alt-x
and then restart it with

     rbx h

Notice:     rbx f

again. The "rbxcon.rst not found" message does not come up this time, since when we exited the Console Program it wrote this file.

Tutorial: Strolling Through the Console Program

The Console Program is a robotic control panel that lets you teach and run your robot. In this section we will take an exploratory stroll through much of its functionality. To fill in details later on you can read through the "Script Language" chapter in this manual to get a complete picture of the commands at your disposal.

You can also view the Console Program tutorial at the end of the "Construction Techniques" video that comes with the RCS-6.

Starting the Console Program

From DOS in the c:\rbx directory, type

     rbx h          (if you are using Hitec servos)

Notice:     rbx f          (if you are using Futaba servos)

Exiting from the Console Program: alt-x

Press alt-x, and you are back in DOS. Note that the robot is still at "attention": if you push it, it will resist.

Now type

     rbx h          (for Hitec servos)

Notice:     rbx f          (for Futaba servos)

to restart the Console Program.

Finally, you can also exit by mouse through the Files entry on the menu bar at the top of the screen. Click on Files, then on Exit.

How to use the key board to the control the program:

The RCS-6 Console Screen

The Console Program is a control-panel for running your robots, by keyboard and/or mouse.

At the top of the screen is a menu bar for accessing different functions through pull-down menus. At the very bottom of the screen is a single line of buttons showing some available commands. Clicking on these commands with the mouse or pressing their keys performs the commands, which we'll do in a moment.

Above the bottom Button line is the Status window, which displays readings of various robot system details. Right now it just shows positions (pos) but we'll customize it in a little while.

In the lower right corner is the amount of memory left for the Console Program.

Playtime!

On the status bar is an entry reading F9-Teach. Press F9 now or click on the F9-Teach entry with your mouse. The "Teach" window opens at the upper right of the Editing screens. Your keyboard (or mouse) has been transformed into what is called in the robotics industry a "Teach Pendant". Remember that you can press F1 or click on F1 Help for context-sensitive help. Here's most of what you need to know right now, though:

The active keyboard keys on your teach pendant are:

 JOG+:    1  2  3  4  5  6
 JOG-:     q  w  e  r  t  y
 jog+:      a  s  d  f  g  h
 jog-:       z  x  c  v  b  n

Hold down the 1 key for a moment. Your robot's servo 1 moves, a little coarsely, until you release the key. Notice that the pos of servo 1 in the status window gets updated when you release the key. Press the Q key for a moment or two to go the other way.

You have just done a series of large positive and negatives "jogs" of servo 1. This is why "JOG+" and "JOG-" are shown at the left of these rows in the diagram above.

To move servo 1 more slowly and precisely, use A and Z keys. Note that these rows are labeled "jog+" and "jog-". Keys 2WSX control servo 2 while servo 6 uses keys 6YHN.

You can push several keys down at once to move several servos at the same time. Notice that even for servo outputs which don't actually have servos attached to them, the pos values change.

When you have moved your robot to an interesting position using the Teach mode, press

     alt-a

or click on the Teach button labeled

     log abs

for "log absolute". You'll see that a move command has been inserted into the editing window. The positions of each servo in the move are the pos values now shown in the status window. The first time you do log abs the positions of all motors will be recorded. After that only the motors that have been moved will be recorded. If no motors have been moved, the Console Program will tell you.

Using the "Teach Pendant" keys again, move the robot to another position, then do another log another move command. This time, however, press

     alt-r

or click on the Teach button labeled

     log rel

to add a relative (rather than absolute) move. The second move command will be inserted in the edit window below the first.

Press escape to exit Teach mode (or click on the "close" icon in the upper left of the Teach mode window). We are now in an editing window with two move commands. Let’s execute them.

Executing Lines in an Edit Window

Use the arrow keys to position the cursor somewhere on the first move command generated in the previous section using "Teach" mode.

Now press F7 that means, "execute this line". The robot will move to the position indicated by the move command. When the move is complete, the positions shown in the status window should agree with those shown in the move command, for whichever servos were in the command.

Press F7 (execute) again, with the cursor still on the first move line. Nothing much happens, though the command was executed. The reason there was no motion is that the robot is already at the position required by the move command.

Now move the cursor down to the second move command and press F7 again to execute that line, and now the robot moves. Press F7 again, and this time the robot does move a second time. This is because the second move line is a relative move. Notice that is contains the word "by" instead of "to".
If you have a mouse you can also double-click on a line to execute it.  Now press Alt-F8. The two lines are executed one after the other.

Syntax Errors

Almost all of the errors you'll see will be syntax errors, that is errors where commands have mistakes in them.  We'll make an error now.

Move the cursor up to the first line, over the "o" in "move". Delete the "o" by pressing the <del> key. Now press F7 (or double-click on the line), to try to execute it. You'll get an error.

After reading the error box, remove it by pressing <enter>, <esc> or <space>, or clicking on the "close" icon or "Ok" button. Put the "o" back in "move", then change the servo number (right after "move") to "17" from whatever it is. Remember what the number was, though so you can repair the damage later.

When you press F7 now you'll see a new error. The cursor will also have moved onto the offending "17". Put it back the way it should be.

Now move the cursor to the word "to" and make it "tx" instead. Press F7 and see the resulting error, and then fix it.

Customizing the Status Window

Press Alt-O to open the Options submenu, and press M for the Servo Parameters dialog box. You'll see only the "pos" entry checked. Check the entries for accel and maxspd as well, by arrow keys and space bar (or mouse). Press escape or close the window to accept your changes.

Now select Options/Sensors and check off Show Sensors. If you have connected switches to the RCS-6 Adapter, activate them now and see their readings change on screen. If you attached sensors to the analog inputs, check off their numbers in the ADC's box and you'll be able to see continuously updated readings from them. Don't check off unused sensors, since they will generally show up with meaningless, jumpy and distracting readings.

If you have sensors, you'll want to leave them in the status window so press <enter> to keep this change. Otherwise press <esc> to cancel the addition.

After you have changed the size of the status window you may also want to execute Windows/Tile or Windows/Cascade to have your edit window(s) adjust for the new status window size.

Files
Name and save the current file by selecting File/Save as from the menu, then entering a name for the file. The extension .rbx will be appended automatically, which marks script files.

Now that the file has a name you can just select File/Save, or just press F2, to save it again.

Macros

Macros allow a sequence of commands to be grouped and called by a single user-selected name. Macros also provide an important link between the Console Program and your programs written in C or QB4.5.

Let's turn the simple sequence we've composed so far into a macro, named "test".

Move the cursor to the top line at the left column. Add a line by pressing enter and then up arrow to go to be back on the new blank line. Type

     macro test

and then below the last line, type

     end

You should now have something like this:

     macro test
     move 1 to ...
     move 1 by ...
     end

This macro must be compiled before it is used. This is a simple process, which can be done automatically or by hand. We'll do it first by hand, to show the details.

Move the cursor to the top line ("macro test"). Press the F8 key, which executes the line as does F7, but also moves the cursor down one line after execution for convenience in stepping through sequences.

Because the macro is compiled into the Device Driver, even when you exit from the Console Program the macro will not be lost. In particular, the macro may be called from a C or QB4.5 program.

Press F8 3 more times to execute the line with end, completing the macro. The macro may then be executed. Type its name test on a new line and press F7 with the cursor on that line to execute the macro.

Now change the line to

     test 3

and execute it. test will execute 3 times.

Now execute

     test 0

which will execute test indefinitely.

While this execution is in progress, press <space> once. This will pause (but not terminate) the macro (or any running command). Pressing <space> again to resume. When you want to end execution, press <esc>.

You can also pause and resume the motion by clicking the right mouse button (the location is not important), and you can end execution using the left mouse button.

Select Control/Macros from the menu to see a list of macros known to the Device Driver. Only "test" will be shown now. Press <esc> to close the window.

Macros can execute other macros. For instance, a new macro named test2 could call test as long as test had already been compiled. Macros that call other macros should be below the macros that they call: test2 should be after test. This ordering simplifies recompilation when a macro is changed.

Forgetting (Deleting) Macros

As we've learned, the Device Driver has learned the macros as you compiled them. In order to change a macro, you must first delete its old definition from the Device Driver.

Often it is simplest to forget all macros, then recompile them all since this only takes a few moments and can be automated as follows. At the top of your file, put the command

     forget all

and then to recompile files you just re-execute the file with Alt-F8, either from the keyboard or by mouse, which will execute all lines in the file. To make this method effective, you'll want to have all of your macros at the beginning of the file. Thus, if you had a file that looked like this:

forget all
macro bingo; ....; end;
macro bongo; ....; end;
macro bango; ....; end;
macro test; bingo; bango; bongo; end;

test 3

and you then made a change to any of the macros, you could forget and recompile them all, and then run test three times by just hitting Alt-F8.

Though it is less-use, you can also forget an individual macro along with all macros compiled after it. Do this through the Control/Macros Dialog, or from the edit window by typing

     forget <macro name>

for instance,

     forget bongo

Forgetting the macro bongo also deletes any macros that were compiled after it, since they may have depended on bongo. In the above example, forgetting bongo would also forge bango and test.

The Script Language

The script language is designed for programming motion sequences and setting motion parameters and is fairly simple.

While many interesting and useful programs can be written directly in the scripts, the language intentionally lacks general programming constructs including variables, conditionals (e.g. "if"), loop constructs (e.g. "while", "do", "for"), function calls, etc. These missing pieces may be added through the general-purpose programming languages C or QB4.5, or potentially other languages as well. The Device Driver interface libraries are supplied for these languages, with source included.

The script language is case insensitive, so you can use upper or lower case, or any combination, as is convenient. You may also add extra spaces between elements of a command for clarity, though a single command may not be split onto two lines.

The notation

     <servo list>

Which appears in many places below indicates that a list such as

     1,2,4
is needed. The list show above means that the servos 1, 2 and 4 are to be used by the command. A servo list may have only one servo, or may consist of the single word
     all

Which means that all servos are involved. In the default settings, servos are numbered starting at 1. For advanced users, this may be changed to 0, if desired, by a script command or by a command line parameter when the Device Driver is loaded or with the enumbase command discussed later.

Angle brackets around the word value

     <value>

mean that a number is expected. The specifics of the number are discussed in the descriptions accompanying commands below. For example

     accel <servo list> <value>

might show up in an actual command as

     accel 1,2 100

Where the servo list is 1 and 2, and <value> became 100, meaning that acceleration for servos 1 and 2 is set to 100. Note that the angle brackets <> are included not around 100.

Multiple commands may generally occur on a single lines, with some exceptions: the program will give an error message about these exceptions if they come up . Multiple commands should be separated by semicolon (;) characters.

The units of position, speed and acceleration in the RCS-6 are not related to any specific unit system.  And so are arbitrary though they are internally consistent: a move of 50 will rotate a servo twice as far as a move of 25, within the servos own physical limits of the servo's positional accuracy. An acceleration of 10 will bring the servo up to its maximum speed for a given motion twice as fast as an acceleration of 5.

The script language command set follows.

accel
     syntax
          accel <servo list> <value>

     description
          Sets the acceleration of the servos in <servo list> to
<value>. <value> must be in the range 1..10000.

     See the "accdec" command for further discussion.

accdec
     syntax
          accdec <servo list> <value>

     description

Sets both the acceleration and deceleration of the servos in <servo list> to <value>. <value> must be in the range 1..10000.

     Proper setting of acceleration and deceleration of a servo can help minimize "bouncing" of the servo as it starts and stops. This is particularly important when the servo is moving a sizable mass.

Acceleration and deceleration may be set independently by the accel and decel commands. Making the two values different is helpful, for example, in creating a "snapping of the wrist" motion as when striking a drum with a stick.

auxa, auxb
     syntax
          auxa on|off
          auxb on|off

     description
Turns Auxiliary output A or B on or off. The output is useful for powering small loads, such as LED's, postage stamp motors, etc. See the "Sensors" section of this manual.

decel
     syntax
          decel <servo list> <value>

     description
          Sets the deceleration of the servos in <servo list> to
<value>. <value> must be in the range 1..10000.

     See the "accdec" command for further discussion.
 

end -- see macro

enumbase
     syntax
          enumbase 0|1

     description
          This command is for advanced users.
Changes the numbering of servos, sensors, parameters, etc. to zero-based or one-based, according to <value> which may be either 1 or 0. The default value is 1.
If you work in a language such as C you may prefer to number arrays starting at 0, and may wish to adopt that convention here. This is particularly true if they are also controlling the robot from C programs.

If you always want to use an enumbase of 0, you can edit the rbx.bat  file, adding a -e0 command line argument to the Device Driver rbxdrv.exe.

It is recommended that you decide on basing as early as possible, since changing the base after scripts have been created will cause those scripts to have syntax errors or operate incorrectly.

forget
     syntax
          forget <macro name>
          forget all

     description
          The first form deletes the <macro name> and any other macro that was defined after it.  The forgot all form deletes all macros.  Refer to the Tutorial section for examples.

initpos
     syntax
          initpos <servo list> <value>

     description
          Sets the servos' initial position, that is, where the servos will go when a restart command is executed.

          Sets the initial position of the servos in <servo list> to <value>. <value> may be positive or negative. Values above maxpos for a servo will be treated as if the value had been maxpos. Similarly, values below minpos will be treated as minpos. <value> may also be the word here, in which case the initpos value of each servo in <servo list> will be set to the servo's current position.

     see restart command.

invert
     syntax
          invert <servo list> on|off

     description
          This command is for intermediate and advanced users.
          Turn inversion on or off for each servo in <servo list>.
          Inverting a servo effectively makes it run opposite to its normal rotation. This can be useful when a servo's uninverted (default) direction feels backward to the programmer.
When a servo is inverted, move and jump commands that used to turn the servo clockwise will turn it counterclockwise, and vice versa. Similarly, moves and jumps to a specific position will result in motion to a position on the other side of p0pos, but on the other side of it. p0pos, the physical zero position, is not affected by the invert command.

At the time a servo's invert setting is changed, its pos, initpos, minpos and maxpos all take on the opposite sign. Their physical positions don't change.

In practice it is common to put commands like the following at the top of a script.

               invert all off      # cancel any settings from
other scripts
               invert x,x,x on     # invert servos x,x,x

macro, end
     syntax
          macro <name>; <command>; .. <command>; end;

Description
A macro is a series of script commands that are executed by using the macro name as a command.

When defining a macro, the macro command must be the first on its line. It labels the following commands, up to the end command, as a new command, <name>. The end command must be the last command on its line. The commands in between macro and end may occupy multiple lines, or an entire macro may occupy only a single line.

A macro is executed by using its name as a command, optionally followed by a count indicating the number of times to execute the macro. A count of 0 indicates indefinite repetition of the macro, or until the <esc> key is pressed. For example

               macro pen_up; move 3 to 50; end
               macro pen_down; move 3 to -140; end;
               macro pen_tap; pen_down; pen_up; end;
               pen_tap    # tap the pen one time
               pen_tap 1  # tap the pen one time
               pen_tap 10 # tap the pen ten times
               pen_tap 0  # tap the pen indefinitely (until
<esc>)

               macro dot_space   # multi-line; indented for
clarity
                   pen_tap;      # make a dot
                   move 4 by 10; # move for space between dots
               end;

               dot_space 5       # make 5 dots, spaces after
each.

For advanced programmers: Macros may be called from your C or QB4.5 programs. In fact, in a C or QB4.5 program, a text file, created and saved from within the Console Program, which containing macros may be loaded and executed with a single
C or QB4.5 to function call. Thus your C or QB4.5 programs can use all the macros saved in a script.

To delete a macro, which is required before you can redefine it, see the forget command.

maxpos/minpos
     syntax
          maxpos <servo list> <value>

     description
Sets the minimum/maximum position that will be allowed for the servos in the list. If a move command would cause a servo to go past minpos/maxpos in a negative/positive direction, the move command will be interpreted as a move to the minimum/maximum position.

When a minpos/maxpos command is executed, either initpos or minpos/maxpos or both may be below/above the new value of minpos/maxpos, which would be inconsistent. In this case, one or both will be set equal to minpos/maxpos.

<value> may also be the keyword here, in which case the current position of each servo in <servo list> will become the servo's minimum/maximum position.
 

maxspd
     syntax
          maxspd <servo list> <value>

     description
Sets the maximum speed that a servo may reach during execution of a move command. The maxspd of a servo may not actually be reached during a move command, but it will not be exceeded.

Note that during a restart command the maxspd may be exceeded since the servos move to their initial positions as quickly as possible.
 

minpos
     see maxpos
 

move
     syntax
          move <servo list> to <value>
          move <servo list> by <value>
          move <servo list> to|by {val} [[,<servo list> to|by
{val}]..]

     description
          The first type of move command, called an absolute
move, is of the form

               move <servo list> to <value>

          which moves each listed servo to the position given by
<value>.

          The second type of move command, called a relative
move, is of the form

               move <servo list> by <value>

          which moves each listed servo by the amount <value>.

          For example,

               move 1,2,3 to 0

          would move the listed servos to position 0,
          while

               move 3 by -50

          would move servo 3 by 50 units negatively.

If several servos need to move at once to different positions and/or by different amounts, then the third and most general form of the move command is used. Note that this form allows a combination of absolute and relative moves. In the example

               move 1 by 20, 2 to -400, 5,6 to -100

          servo 1 will move by 20 units, 2 will move to position -400 and servos 5 and 6 will move by -100.

Servos in a single move command move so that they start and stop together so that the motion is "coordinated". Each servo accelerates according to its accel setting and ecelerates according to its decel setting, and for each servo its speed does not exceed (and may not reach) maxspd.

If a move command would carry a servo beyond its maxpos or minpos, that servo's portion of the move is interpreted as a move to the maxpos or minpos, as appropriate.

For absolute moves, <value> may be the word initpos, maxpos or minpos, causing each listed servo to move to the appropriate position. Thus, the command

               move all to initpos

would have an effect similar to the restart command, though without the suddenness.
 

p0pos
     syntax
          p0pos <servo list> <value>

     description
          This command is for advanced users.

Set the "physical zero position" (hence the name "p0pos") of the listed servos to the physical position given by <value>.  <Value> may also be the keyword here in which case the physical zeros points of the listed servos become the servos' present positions.

This command is typically used when unusual hobby servos are used in a robot. Using the recommended servos (Hitec STD TS-52) usually means that p0pos may be left at its startup value for satisfactory performance. These values are established at startup of the software, with either rbx h for Hitec servos. Mixing the two types in a single robot will require setting p0pos for the Hitec's at 3000 and for the Futaba's at 2400.
 

pause
     syntax
          pause <value>

     description
          Pause approximately <value> tenths of a second before executing the next command.

power

SAFETY NOTE: THIS COMMAND DOES NOT TURN OFF ROBOT POWER, AND
SO IN CASE OF MALFUNCTION THE ROBOT MIGHT BEGIN TO MOVE UNEXPECTEDLY AND WITHOUT WARNING. TO REMOVE POWER FROM THE ROBOT UNPLUG THE POWER CORD.

     syntax
          power <servo list> on|off

     description
          This command is for advanced users.
          Applies power to (on) or removes power from (off) the listed servos. When power to a servo is turned off, the servo becomes "relaxed" or "compliant". When power is restored, the servo returns immediately to its former position in a rather fast and sudden motion, even if it has been moved manually to a new position.

          move commands may be applied to servos with their power off. When power is reapplied, the servo will move immediately to the position implied by the series of move commands, and shown as pos in the status window, if visible. The same is true of the restart command.

restart
     syntax
          restart

description
Moves all servos immediately to their initial positions, as specified by the initpos command.

This command is typically run at the beginning of a robotic session to bring the robot from whatever position it currently has to its initial position.

If power has been interrupted to the controller, restart should be executed after power is restored.

Execution of the restart command may cause motion which is fast and sudden as the robot jumps all servos to their initial positions, initpos.

How motion is computed by the Device Driver

How accel, decel and maxspd Govern Motion

Robots can shudder and vibrate as they start and stop. While vibration is a characteristic of machines in general, modern design techniques have greatly reduced vibration in the machines we use. Early cars, airplanes and electrical appliances, for example, shook liberally but over the years the vibration has been engineered out of these machines.

In the case of robots, sophisticated control systems are continually evolving to minimize vibration and overshoot. The Device Driver in the RCS-6 software uses an elementary but instructive technique to reduce these effects. Using "trapezoidal velocity profiles", the Device Driver can produce fairly smooth starts and stops for each servo. By adjusting accel and decel settings on each axis, you may tune your robot's performance. (See "Tuning Your Robot".)

The maxspd setting, which sets the maximum speed at which a servo will move, is useful when you want to ensure that a servo moves slowly, say for visual effect, or when you just don't want it to move too fast.

Remember, the settings accel, decel and maxspd may be individually set for each servo. The settings may be changed between moves if desired. For convenience, you may want to define macros with names like "quick", "moderate", and "slow", which set these parameters with a single command.

Moves with One Servo

During a move command involving a single servo, such as

move 1 by 100

The servo is accelerated according to its accel setting, up to a, maximum speed no greater than its maxspd setting. The servo then moves at a constant speed (this is called "slewing") for a while and finally decelerates according to its decel setting, ending up
100 units from where it started. The motion may be graphed as a "velocity trapezoid". The vertical axis shows speed and the horizontal axis represents time. The area under the trapezoid (velocity * time) represents the distance traveled.

Note on "speed" and "velocity": These two terms mean almost but not quite the same thing. Speed tells how fast something is moving, while velocity also specifies direction. For example, a personal standing on a carousel may move at constant speed, but their direction of motion and so their velocity is constantly changing since they are going in a circle, not a straight line. A velocity trapezoid representing the command

move 1 by -100

Which moves in the negative direction would have a velocity trapezoid pointing down from the horizontal axis.

             slewing ("maxspd") phase
   |        _________________________
   v      l/e                         d\p
   e     e/s                             e\h
   l    c/a      area = distance (100)          c\a
   o   c/h                                    e\s
   c  a/p                                         l\e
   |  ------------------------------------------------------------
          --- time ---

The graph shows the speed of the servo increasing over time on the slope at left labeled accel. The flat area on top of the trapezoid shows the part of the motion made at constant speed.  The back slope shows the servo slowing down.

The Device Driver program computes the time needed for each portion of the move, according to the settings for accel, decel, maxspd, and the length of the move for the servo.

When computing the velocity trapezoid for a move, the accel and decel settings are always used as they are. This is because you may have tuned these values differently for each servo to minimize shake.

For a given accel, decel and distance, many different velocity trapezoids could be constructed with the same slope of the sides and equal areas. For instance, the two velocity trapezoids shown next have equal accel, decel and area. Since the areas are equal, the moves cover the same distance.

               ___
              /      \
   |         /         \
   v      l/e       d\p
   e    e/s          e\h
   l    c/a             c\a
   o  c/h  a = 60   e\s
   c a/p                  l\e
   | ---------------------------------------
          --- time ---
 

   |
   v
   e       _________________________
   l     c/a                           d\p
   o   c/h        a = 60                     e\h
   c  a/p                                 c\a
   |  ------------------------------------------------
          --- time ---

However, the upper trapezoid accelerates to a higher slewing speed (maxspd) and so covers the distance in less time.

The fastest trapezoid for a given accel, decel and distance is actually a triangle, where there is no slewing period at all. However, there is no "slowest" trapezoid for a move, since the trapezoid can get shorter (slower) and wider (more time consuming), and still cover the same area (distance).

Since there is a continuous range of possible trapezoids using the same accel, decel and covering the same distance, the Device Driver needs a rule to choose which one will be used for a single-servo move. Here's the rule:

For a single servo move, use the fastest (tallest) trapezoid possible that does not exceed the maxspd setting of the servo. If fastest trapezoid (really a triangle) would be too tall, i.e., it would exceed maxspd, squash it down until the top of it (the slewing speed) is equal to the maxspd of the servo.

Moves with More Than One Servo

The situation changes a little when more than one servo is involved. In the command

     move 1 by 100, 3 by -400, 5 by 95

we would expect a different velocity trapezoid for each servo. Yet the Device Driver assures that all servos will start and stop together. It does this by applying the following rule:

For multiple-servo moves, find the servo that would have taken the longest for the move, then make all servos take that long.

In more conceptual detail: Compute how wide each servo's trapezoid would be if it were making a single-servo move. Now squash (and widen) all but the widest (longest duration) of these trapezoids until all are as wide (take as long) as the widest (longest) one. Since the trapezoids are now the same width, their moves take the same amount of time. They start and stop together.
 

Cracking the Whip

                    ____
                   /       \
   |             /         \
   v          l/e      d\p
   e        e/s        e\h
   l      c/a           c\a
   o    c/h            e\s
   c  a/p              l\e
   | ---------------------------------------
          --- time ---

accel and decel are typically equal, which is why the accdec command is available to set both to a single value. For certain effects, however, you may want unequal values.