You are on page 1of 14

Chapter 4 Robotic Arm Interfacing

first introduce the parts/organization of this chapter... at least one paragtaph


4.1.1 Port Monitoring
Determining the type of connection and understanding the communication protocol between the
computer and the device is the first step for successful interfacing. The Robotic Arm Controlling
Device RACD is connected with the Computer trough a Serial Communication Port COM port,
using the RS232 protocol (fig 4.1). , Figure 4.1.

Not clear! make it


bigger.

Figure 4.1 RS232 COM port


The official software uses the COM port to control the RACD which in turn controls the servo motors
in the Robotic Arm.to conduct the desired movement with minimum error and precise feedback.
Before successfully controlling the port many uncertainties arise including.
-Buadrate.

Therefore I recommend that you start writing the report


from the beginning: Chapter 1, Chapter 2, etc.

-Data packet size and speed.


-End bit characteristics
-Type of flow control.

Once determined data can be successfully monitored and exported to a file for decoding and
analysis.
The official signals that control the RACD were determined by monitoring the communication port
between the RACD and the Computer while the official software is running and active. When the
official software sends a movement signal for example the monitoring software acquires the sent
code and exports it to a text file.

try to use present instead of past tens

The assumption was that a movement function for example will always result in the same code
combination once called again by the official software. This method proved to be successful when
interfacing in general unless some form of encryption was used to obscure the control commands.

The received data at first glance looked like a scrambled set of code as seen in Figure (4.2). This code
was analysed by locating at the commonalities and recursions while testing and repeating the
different commands using the official software.

Figure 4.2 Monitored Data in HEX Format

4.1.2 Port Monitoring Results


Advanced Port Monitor was used to monitor the transmission between the RACD and the computer.
The connection parameters were determined by estimation and trial of other known COM devices.
Data was successfully obtained through the following settings:
Buadrate: 9600
Data Packet Size: 8 Bits 1 End bit
Flow control: none
When the data acquired from the Advanced Port Monitor was analysed and viewed in the
hexadecimal format many recurring code combinations were noticed. This was explained by the
assumption that every command has a unique set of bytes that represent it, a position command for
example will result in the same code combination when called.

For example, 4d 4f 56 45 50 05 01 0D is a command that moves the base servo motor to the left
from the current position the robotic arm is stationed in. Table 4.1 dissects the movement
command.
HEX Code

Function

4d 4f 56 45

Move command

50

Separate the command from coordinates or


other parameters

05

Servo Motor identifier

01

Direction of movement

0D

Carriage Return

Table 4.1 HEX code and its relevant function

It must be taken into note that The 0D is a special ASCII character that represents a new line or
carriage return, the RACD keeps waiting for additional data when receiving a command until
Carriage return is found.
Initially the assumption was that the carriage return byte 0D was used in the end of all the
communication commands sent and received from the official software to the RACD. it was later
determined that this was true only for the case of commands being sent to the RACD. When
commands are received from the RACD the ending byte was 0A instead.
In addition, the Carriage return character was an indicator for the RACD ability to understand ASCII
raising the assumption that the monitored HEX data was ASCII code and commands. By transforming
the Hexadecimal code to its ASCII equivalent the monitored code immediately became
understandable and easier to decode with assembly like programming characteristics proving the
recursive code assumption. For example, the command 4d 4f 56 45 50 05 01 0D becomes MOVE 50
05 01 0D which is easier to decode and understand.
More commands for the different functions and modes in the official software were successfully
found and noted by repeating the previous steps.
The Robotic Arm was successfully controlled by setting up a COM port session using the found
settings and sending the noted commands and code combinations trough the COM port to the RACD
without the need for the official software.
For successful control the commands must be sent precisely as found in the decoded file, if a part
was missed or added buffer overflow might occur and the RACD will crash and require manual
reboot.

4.1.3 Robotic Arm Control Commands


All the commands that control the Robotic Arm were noted and can be used with any software or
language with the correct settings. All commands must be ended with a line terminator 0D, if a
line terminator was not sent with the command the RACD interpreter will keep waiting and
receiving.
Only one command at a time can be sent to the RACD, except for the STOP command which
interrupts any current execution and immediately stops the Robotic Arm, if the arm was executing a
command and a new command was sent before the arm ends execution a busy or Error
message will be returned.
The RACD can be directly controlled trough the COM port by the following commands

COMMAND: REMOTE 0D
Check for the states of the Robotic Arm
RETURNS:
OK Robotic Arm is ready for commands
BUSY Robotic Arm is executing a movement or not connected.
ERR An error occurred or Robotic Arm is not connected.

COMMAND: HARDHOME 0D
Calibrate the Robotic Arm and the RACD by testing the Arms physical limit setting the Arm
position and checking the arm states.
RETURNS:
The command keeps returning the feedback position of the Robotic Arm while conducting
the different boundary tests. In the end the RACD returns the final calibrated position
closing with an END message.

COMMAND: SHUTDOWN 0D
Finalize and shutdown the RACD and the Robotic Arm
RETURNS:
closing with an END message.

COMMAND: MOVE 50 Y X 0D
Move one selected joint of the robot until a stop order is initiated or arm reaches its physical
limit.
INPUT:
Y Identifies which servo motor is targeted for movement
X Identifies the direction
RETURN:
None
Y=0
Move Gripper until physical limit is reached or a stop command is ordered.
X = 1 Grippers motor conducts an opening movement
X =-1 Grippers motor conducts a closing movement

Y=1
Rotate gripper physical limit is reach or a stop command is ordered
X = 1 Grippers rotates to the right
X =-1 Grippers rotates to the left

Y=2
Move wrist until physical limit is reached or a stop command is ordered.
X = 1 Wrist motor conducts an ascending movement
X =-1 Wrist motor conducts a descending movement

Y=3
Move arm until physical limit is reached or a stop command is ordered.
X = 1 Arm motor conducts an ascending movement

X =-1 Arm motor conducts a descending movement

Y=4
Move shoulder until physical limit is reached or a stop command is ordered.
X = 1 Shoulder motor conducts an ascending movement
X =-1 Shoulder motor conducts a descending movement

Y=5
Move shoulder until physical limit is reached or a stop command is ordered.
X = 1 Shoulder motor conducts an ascending movement
X =-1 Shoulder motor conducts a descending movement

COMMAND: STOP 0D
Override any order and immediately stop the Robotic Arm
RETURN:
None

COMMAND: SET ESTOP 0 0D


Release the emergency stop lock. This command is used to resume a session after the
physical emergency button was pressed and physically released.
RETURN:
none

COMMAND: FREE 0D
Free servo motors if torqued.
RETURN:
none

COMMAND: TORQUE 0D
Torque servo motors if free
RETURN:
None

COMMAND: GET POS 0D


Return the current articulate position of the arm.
RETURN:
The command returns the position as one array with all the positions of the servo motors.
P A B C D E F 0 0
P indicates a position array and the coordinates are presented with articulate values and 0 0
as ending bytes.
A Base, B Shoulder, C Elbow, D Arm, E Rotation, F Gripper
Example:
P 247 -7 -7 37 -86606 -99540 0 0
Specifies the current position of the arm in terms of the feedback system.

COMMAND RUN 50 0 A B C D E F 0 0 1 0D
Go to required articulate position, in this command all the servo motors work together in
parallel to reach the designated location.
INPUT:
A Gripper, B Rotation, C Wrist, D Arm, E Shoulder, F Base
The 50 separates the command from the coordinates and the 0 0 1 0D are end bits
Example:
RUN 50 0 50000 50691 44054 -3195 -4660 7000 0 0 1 0D
Moves the arm to the specified coordinates where all motors run in parallel to reach
destination
RETURN:
The robotic arm returns its position when the final position is reached.

The RACD uses a special articulate coordinate system that only uses integers to define degrees and
angles. For example, 64995 in RACD articulate coordinates equal 89.9 degrees in world articulate
coordinates.
To Transform from RACD articulate coordinates to world articulate coordinates a number Linear
equations must be used. Each joint has its own linear transform equation based on its position and
characteristics.

= 0.001699 1

1
666.66667

= ( 0.0015) + 105
=
=

(4.1)
(4.2)

(4.3)

666.667

(4.4)

525

(4.5)

4.2 Matlab Robotic Arm Library


Using the decoded commands from the previous section, any standalone software can be written to
control the Robotic Arm. Once the RACD receives a command it immediately executes it without the
need of the official software.
In this specific project Matlab was used as the controlling software. Matlab is a high-performance
language for technical computing. It integrates computation, visualization, and programming in an
easy-to-use environment where problems and solutions are expressed in familiar mathematical
notation.
Matlab Instrument Toolbox includes a number of low level serial port manipulating functions that
can be used to send signals trough the COM port with the needed specification. These low level I/O
functions are the backbone for The Robotic Arm Control Library.
The Robotic Arm Control Library functions are stored in a directory with separate .m files for each
function, because Matlab only allows functions to call other functions that are in a .m file with the
same name.
The following sections will introduce the Library, its different aspects.

4.2.1 Robotic Arm Initialization and Shutdown


The first step for using the Robotic arm is to initialize the Serial Port connection between Matlab and
the RACD. This step will create a serial object and adjust the connection parameters to be
compatible with the RACD.
Matlab looks at the COM ports as an object that can be defined and adjusted based on the specific
application required, the COM object must be opened after creation and closed before termination.
The following function must be called to start using the Robotic Arm Library.

Obj = Init_Robot("Port Name")


Reserve and initialize the COM port with the RACD specified settings and open the specified
port for use.
INPUT:
Port Number: COM port name connected to the RACD
RETURN:
Obj: Matlab created object with the specified COM port settings.

After finishing with the Robotic Arm, the serial port COM connected with the RACD must be shut
down by releasing the COM port object and initiating an end signal. The RACD will release the
connection from its side and shutdown.
The following function is used to terminate Matlabs connection with the COM port and release it for
final shutdown.

States = Close_Robot(Obj)
Release COM port and initiate shutdown with the RACD
INPUT: Obj COM port object
RETURN: The states of the Port

4.2.2 Robotic Arm Calibration


After initialization and before use the RACD must be calibrated using the Calib_Robot() In the Matlab
Robotic Arm Library. If the Robotic Arm was not calibrated before use the RACD feedback system will
calculate wrong coordinate results and assume the robot is on the calibrated position when turned
on.

The RACD calibrates the Robotic Arm by testing the limits of all the servo motors. For example, when
calibrating the base motor, the robotic arm will rotate towards the right limit until the right base
motor limit sensor activates. Once reached the Robotic Arm will rotate towards the left limit until
the left limit sensor activates. The same process is repeated with all the servo motors ending in the
final calibrated position in Figure (4.3).

Figure 4.3 Robotic Arm


Calibrated Position
Calib_Robot is a locked function where Matlab cannot be used until the end of the calibration
processes. The reason behind locking Matlab during calibration is to prevent any signal from being
sent to the RACD. If a signal is sent while the Arm is busy the RACD will send a Busy signal or in some
cases crash.

Pos= Calib_Robot(Obj)
Calibrate Robot
INPUT: Obj COM port object
RETURN: The location of the arm after calibration ideally 0,0,0,0,0

4.2.3 Robotic Arm Positioning


Once calibration is set and the Arm is in its final calibrated position, the arm can be used as needed
in different applications.
The robotic Arm has two systems of movement.:

1- Cartesian System:
A coordinate system that uses Cartesian dimension (X, Y, Z) as the bases for positioning the
Robotic Arm in space. This system is complex to analyse from the RACD prospective, but easy to
visualize from a humans prospective.
The RACD built in Cartesian system processing is minimal and unpractical for position
applications. For example, the official software can only processes and initiate Cartesian
movement if the wrist angle 3 in (Figure 4.4) doesn't change and remains constant.
For the reasons mentioned new methods to solve this problem will be discussed in the next
chapter.

Figure 4.4 Robotic Arm DOF


2- Articulate System:
The articulate system is a coordinates system defined in terms of degrees of freedom and
feedback in space. The Labvolt 5250 Robotic Arm has 5 degrees of freedom.
Using the Articulate System is straight forward and easy for the RACD to processes, however
because humans naturally processes space in Cartesian coordinates, the articulate system is
unfavourable in dynamic position applications and problem solving.
To move the arm to a target five angles must be defined Base, Shoulder, Arm, Wrist, Wrist
rotation, in addition to gripper length.
As mentioned the RACD strictly uses integers and doesn't accept floating point values, the angles
must be transformed from the regular angle system to the RACD value system using Equations
(1.1,1.2,1.3,1.4,1.5)
The following function can be used for different positioning tasks:

Position = Get_Degree_Robot(Obj)

Get position in world articulate coordinates.


INPUT: Object connected to the RACD COM port
OUTPUT: Regular world articulate coordinates

Position = Go_Robot(Obj,Gripper,Wrist_Rotate,Wrist,Arn,Shoulder,Base)
Move Robotic Arm to designated position.
INPUT:
Obj: Object connected to the RACD COM port
Gripper: Size of gripper
Wrist_Rotate, Wrist ,Arm ,Shoulder , Base: World articulate angles for the destination
RETURN: The final position after movement.

Position = Go_Robot_Lock(Obj,Gripper,Wrist_Rotate,Wrist,Arn,Shoulder,Base)
Move Robotic Arm to designated position, lock Matlab and wait until arm reaches
designated position.
INPUT:
Obj: Object connected to the RACD COM port
Gripper: Size of gripper
Wrist_Rotate, Wrist ,Arm ,Shoulder , Base: World articulate angles for the destination
RETURN: The final position after movement.

Stop_Robot(Obj)
Stop any current movement the Robotic Arm is conduction
INPUT: Object connected to the RACD COM port
OUTPUT: Regular articulate coordinates

Wait_Robot(Obj)
Check if arm is moving and lock Matlab and force user to wait until arm finishes conducting
its movement.
INPUT: Object connected to the RACD COM port
OUTPUT: Regular articulate coordinates

mJoint_Robot(Obj)
Move one joint of the robot until a stop order is initiated or arm reaches its physical limit
INPUT: Object connected to the RACD COM port
OUTPUT: Regular articulate coordinates

4.2.4 Robotic Arm Additional Functions

The RACD has a number of other options that can help enhance the experience of using the Robotic
Arm. The emergency button available as a separate unit can be used as a safety measure when
pressed however the RACD remains locked until it is release by a specific command.
In addition, the servo motors in the Robotic Arm can be torqued or freed based on the application
used, for example if the application needed deals with weight it is better to set the Robotic Arm in
torque mode to give sustained power to the Robotic Arm.
The following functions represent the different modes

Emergency_Robot(Obj)
Release the RACD to continue work after the emergency button is physically released. If the
physical emergency button is still pressed an error message will be returned.
INPUT: Obj COM port object
RETURN: Message from the RACD stating the action performed

Release_Robot(Obj)
Release servo motors
INPUT: Obj COM port object
RETURN: Message from the RACD stating the action performed

Torque_Robot(Obj)
Torque servo motors
INPUT: Obj COM port object
RETURN: Message from the RACD stating the action performed

4.2.5 Robotic Arm Remarks


All the function in the Robotic Arm Library check for the availability of the arm and its states before
conducting their respective functions.
The functions mentioned above use "Printf" for sending and "scanf" for receiving data from the
RACD. Both function are low level I/O functions and caution should be taken when sending
commands manually to make sure that the line terminator is sent.
In addition, the RACD waits for a line terminator 0d when sending data which can be specified in
Matlab however when the RACD sends data the receiving user should look for 0A as a line
terminator. By trial it was found that Matlab cannot change between terminators in the middle. A
better solution to check if data is received is by checking into the Input Buffer.
When busy the robotic arm usually sends a busy signal however there is a chance that the RACD will
crash if data is sent while busy or unknown commands are sent.
If the gripper in the Robotic Arm is not moving, make sure that the gripper is set manually to SERVO
mode using the physical manual controller provided with the RACD.

4.3 Conclusion
The Robotic Arm Controller Device was successfully interfaced and the Robotic Arm now can be used
independently without the Original Software.
Using the provided low level commands, the RACD can be interfaced in any system required with
any programming language specified for example C++. The only requirement is to setup a successful
connection with the parameters mentioned in the previous sections and send the commands
exactly.
For this project A Matlab library was developed and ready for use. the functions in the library handle
all the low level tasks and give the user the opportunity to focus on higher level problems.

You might also like