Using FORTH to control a robot arm

Using FORTH to control a robot arm

Using FORTH to control a robot arm The cost of a small robot arm can be low enough for one to be treated as a computer peripheral. FORTH is fast enoug...

736KB Sizes 42 Downloads 156 Views

Using FORTH to control a robot arm The cost of a small robot arm can be low enough for one to be treated as a computer peripheral. FORTH is fast enough and compact enough to control a robot arm through one of today's 'home' computers, as David Sands outlines The characteristics o f the Cyber 3 robot arm are outlined, with a brief history o f programming languages used to control it. The advantages o f FORTH over its rivals are given. A program sequence for a robot to reorient an ob/ect is given. microsystems



The Cyber 3 (Figure 1 ) is a lightweight robot arm suitable either for training or for light industrial tasks. Cyber robots are powered by stepping motors. There are no servo systems, feedback loops or proportional control. Stepping motors make the Cyber 3 suitable as a computer peripheral. With printers, digital plotters and disc drives, the physical position of print heads, pen, and record/playback heads is determined by issuing trains of pulses metered out by a local processor or controller. Since there is no feedback, the processor only knows where the mechanics are by computation. Conventional robots learn tasks by memorizing movements being recorded by the same sensors which act as feedback elements when the arm is switched to playback mode. This system needs a very large RAM overhead since thousands of discreet points in space must be memorized. Such a system cannot be employed on a small device such as the Cyber 3 with its stepping motors. What is required instead is a versatile and user-friendly control language, to enable control and teaching from the computer keyboard. Cyber Robotics Ltd has developed a robot language using FORTH. On the 6502 microprocessor a version of FIGFORTH was used, while for the ZS0 microprocessor a version implemented by the writer was used. The robotextended FORTH is called ROBOFORTH. Using this language it soon becomes apparent that quite complex tasks can be accomplished by defining relatively few absolute positions in space. Thus the RAM overhead is very small and magnetic storage requirements are small or zero. Since the robot software and the FORTH itself are very compact the whole system will run in a personal computer or small microprocessor system and yet easily outperform Cyber Robotics Ltd, 61 Ditton Walk, Cambridge CB5 8QD, UK


(in terms of articulation and intelligence) the larger industrial robots.


In the early stages, the designer of Cyber 3's forerunner used BASIC to implement a robot control language based on VAL. We soon found, however, that neither VAL nor BASIC are suitable for our type of robot. For one thing we wanted a design in which all the control was carried out in the host computer and BASIC was far, far too slow. FORTH was chosen because ~t is more compact and some 20 to 40 times faster than BASIC. It is still only 17% efficient compared to machine code, but the advantage comes from ease of programming, without the execution speed penalty of BASIC. FORTH is slightly more difficult to learn than BASIC or FORTRAN, but once fluent in the language the programmer can easily build up new and complex functions. These functions are defined in terms of lower level functions previously defined in terms of machine-coded 'primitives' built into the 'kernel' of the language. The functions are named and the names or 'words' stored in a linked dictionary, which is only used for defining newer, still higher level functions. The robot language itself uses the same syntax as the FORTH it is built upon. The robot language and the FORTH become merged into one larger FORTH with a vocabulary suited to robots. Higher level functions can be implemented by end users by using the FORTH and robot vocabular)es in new definitions, for example for handshaking with other computer equipment or with production hnes. At present the software is available for an expanding range of personal computers including PET and the tiny Jupiter Ace, which has FORTH as its one and only language.


The Jupiter Ace is a small UK built microcomputer (Figure 1). It is based on the Z80A microprocessor running at 3.25 MHz. There is 3k of RAM on board and 8k of ROM. Output is a memory mapped 32 x 24 character display. Integer, floating point and string data may be held as constants, variables or arrays with multiple dimensions and mixed data types. Once ROBOFORTH had been developed on disc based machines we set about installing it on the Ace. After work space and screen RAM are taken into account there is only about 0.5k left for user programs. Nevertheless we were able to get the first four screens of ROBOFORTH into ~t, enough to carry out multiple movements, grip operation, but without the ability to learn moves. For that a RAM expansion pack was necessary. This is, however, an indication of how compact FORTH code is. For hardware interface between the Ace and the Cyber 3 we designed a plug-on board with the bus extended, using

0 1 4 1 - 9 3 3 1 / 8 3 / 1 0 0 2 2 8 - 0 2 $03.00 © Butterworth & Co (Publishers) Ltd

microprocessors and microsystems

8255 programmable adaptor. Additionally we installed a row of LED lights to indicate which joints are selected.

An example of programming a simple robot move, to re-orientate an object:

LEARN Learn the position. When the robot program is played back the gripper may come into a position at an angle and knock into the object, so the position immediately above the object must be logged first. S+ 50 MOVE Lower gripper round object.

SETHOME NEW This zeroes all counters; robot should be in a suitable mechanical 'home' position.

I00 GRIP Grip object.

5+ This selects the shoulder to move.

50GRIP A bit tighter.

500 MOVE The shoulder moves down 500 steps.

LEARN S+ - 50 MOVE Lift object up.

E+ W+ Now the shoulder, elbow and wrist tilt are all selected. 300 MOVE Shoulder, elbow and wrist all move 300 steps. The gripper is now near the object. ALLOFF B+ 50 MOVE The other joints are de-selected and the base swivels to position the gripper over the object. -5 MOVE Too far! Back a bit. BO S+ 50 MOVE Base off, move shoulder down.

LEARN 150 TWIST Turn object round. 50 MOVE Lower object down. UNGRIP Let go of object. LEARN -50 MOVE UNTWIST LEARN Raise gripper and untwist it.

SO W- 10 MOVE Wrist was in wrong place, adjust position. Now it is ready to pick up.

HOME LEARN Restore arm to rest position. Program complete. Memory usage 96 bytes!

WO S- 50 MOVE Raise shoulder so that gripper is poised above the object.

RUN Do it all again.

Figure I. Cyber 3 lightweight robot arm

vol 7 no 5 june 1983

Figure 2. Jupiter Ace microcomputer