Chapter 7: Integrating Sensors, Actuators and Controller in a Robotic Arm

On a school visit to a small packaging unit, a group of students stood behind a yellow safety line and watched one machine for most of the morning. A metal arm swung to the left, dipped, closed a gripper around a carton, lifted it, turned, and set it down on a moving belt. Then it did the same thing again. And again — each carton landing in nearly the same spot every time.

One student asked the supervisor how the arm knew when to stop turning. She pointed to a small black cylinder fitted at the base of the arm. That part measures the angle of the joint, she said. The motor turns the joint, the sensor keeps reporting how far the joint has reached, and the controller keeps comparing the two.

That one answer describes this whole chapter. A robotic arm is not a single clever machine. It is a sensor, an actuator and a controller, joined into a loop that keeps checking itself.

Diagram

Fig. 7.0-1 – simple labelled sketch of a robotic arm lifting a carton onto a belt; label the base joint, the links, the gripper at the end, and the motor at the joint; alongside, draw a small loop of three boxes joined by arrows — sensor → controller → motor → back to sensor

NoteCuriosity Corner

Q1. How does a robotic arm know how far its joint has already turned? Q2. If the power goes off in the middle of a job, will the arm still know where its joints are? Q3. Why do some robotic arms use compressed air or pressurised oil instead of an electric motor? Q4. What does a controller actually do with the reading it receives from a sensor? Q5. Why must a robotic arm keep checking its own position while it is still moving?

Keep these five questions in mind as you read. Each one is answered somewhere in this chapter.

7.1 A Robotic Arm as One Working System

Think of a job in a packaging unit where a carton has to be picked up from a table and placed on a moving belt, once every few seconds, right through the day. A person can do this, but not without tiring, and not with the same accuracy every single time. A conveyor belt cannot do it either, because a belt only carries things along one fixed path. The job needs a machine that can reach out, change direction, hold something, and come back. In other words, it needs a machine shaped roughly like an arm.

That is exactly what a robotic arm is. It is a mechanical arm that can be programmed, and it moves in a way that is similar to a human arm.

NoteDefinition

A robotic arm is a programmable mechanical arm that lifts, moves and handles objects, or works with other machines and tools, in a precise and controlled way.

Robotic arms are used in a wide range of places. In industrial automation they weld, paint and stack. In medicine they hold instruments steady during a procedure. In research laboratories they handle samples that are unsafe or too delicate for a person to touch. In all these places the same three strengths matter: the arm can repeat a movement many times over with high accuracy, it can keep working without a break, and it can be sent into spaces that are hot, sharp or otherwise unsafe for people.

There is an honest limit to this. A robotic arm only carries out the movements it has been programmed to make. If the carton is left slightly to one side and the arm has no sensor that notices the change, the gripper will still close at the old spot and come back empty. Accuracy comes from measuring, not from the arm being clever.

Q. Why is a robotic arm built from several moving joints instead of one long sliding part?

A. One sliding part can only travel along a single path. Several joints let the far end of the arm reach many different points in the space around it.

7.1.1 The Parts of a Robotic Arm

Before you can follow how an arm controls itself, it helps to know what it is built from. The key components of a robotic arm are joints, links, end effector, actuators, sensors, controllers and power supply. These are shown in Fig. 7.1-1.

Diagram

Fig. 7.1-1 – labelled side view of a three-joint robotic arm standing on a base; label the links (the straight rigid sections), the joints (the circles where two links meet), the end effector (a gripper at the far end), a motor drawn at one joint marked “actuator”, a small sensor drawn on the same joint, a controller box beside the base, and the power supply feeding the controller and motor

A link is a rigid section of the arm. Links do not bend or stretch. They are the bones of the arm, and their lengths decide how far the arm can reach.

A joint is the place where two links meet and move with respect to each other. A revolute joint turns, in the way your elbow turns. A prismatic joint slides in and out, in the way a drawer slides. Most robotic arms use revolute joints at the shoulder, elbow and wrist.

The end effector is the tool fitted at the far end of the arm. It is the part that actually does the job — a gripper for holding a carton, a suction cup for lifting a sheet of glass, a welding tip for joining two metal panels.

An actuator is the part that produces the movement. There is usually one actuator at each joint, most often a motor. Without actuators the arm is only a stack of metal links.

A sensor is a part that measures something and reports the measurement back as a signal — for example, how far a joint has turned, or how hard the gripper is squeezing. Sensors are how the arm finds out what is really happening, rather than what was expected to happen.

The controller is the small computer that runs the arm. It reads the values coming from the sensors, works out what should happen next, and sends commands to the actuators.

The power supply provides the energy that the motors and the electronics need. The motors usually need far more power than the controller does, so the two are often supplied separately.

None of these parts is useful on its own. A motor with no sensor cannot tell how far it has turned. A sensor with no controller has nobody to report to. A controller with no actuator can decide on a value but cannot move anything. The rest of this chapter looks at each part in turn, and then puts them back together into one loop.

A robotic arm can begin moving without warning, and a moving joint can trap a finger. Stay outside the arm’s working area whenever it is powered on, and never hold or push a joint to test it. Switch the arm off and disconnect the power supply before adjusting, tightening or rewiring anything.

7.2 Sensors in a Robotic Arm

Suppose the controller sends a command: turn the elbow joint by 90 degrees. Has the joint actually turned by 90 degrees? The controller cannot know. The carton may be heavier than expected, a belt inside the gearbox may slip, or the motor may push against something and stall. Without a measurement, the controller only knows what it asked for, not what happened.

This is why every serious robotic arm carries sensors. A sensor measures something real and sends that measurement back to the controller. Information sent back in this way is called feedback.

NoteDefinition

Feedback is information about what a system has actually done, sent back to the controller so that it can compare the actual result with the desired result.

The sensors on an arm report two kinds of information. Some report the state of the arm itself — the position of each joint, how fast it is moving, how much force the gripper is applying. Others report the environment around the arm — whether an object is nearby, what the workspace looks like, how hot a motor has become. The rest of this section looks at the sensors used most often.

7.2.1 Encoders

Almost every joint of a robotic arm turns, and almost every joint is driven by a motor shaft that turns with it. So the single most useful measurement in an arm is rotation. An encoder is the sensor built for that job.

An encoder measures the rotational position, speed and direction of a rotating component, such as a motor shaft or a joint of the arm. It is mounted on the shaft, so it turns exactly as much as the shaft turns, and it reports this movement to the controller as an electrical signal. There are mainly two types of encoders: the incremental encoder, also called a rotary encoder, and the absolute encoder.

7.2.1.1 The Incremental/Rotary Encoder

An incremental encoder, also known as a rotary encoder, tells the controller how much the shaft has turned since it started counting.

Inside it there is a disk with a pattern of evenly spaced lines or slots, an optical or magnetic sensor that watches the pattern, and a signal processing unit. As the disk rotates, each slot passing the sensor produces one pulse. The pattern of the disk and the position of the sensor are shown in Fig. 7.2-1.

Diagram

Fig. 7.2-1 – cut-away sketch of an incremental encoder: a slotted disk mounted on a motor shaft, a light source on one side of the disk and a detector on the other, and a small graph beside it showing the square pulse train produced as the disk turns

The number of pulses corresponds to the amount of rotation. If you know how many slots the disk has, you can convert a pulse count into an angle.

finding the angle a joint has turned from an encoder pulse count

Given: an encoder disk with 200 slots, so it produces 200 pulses in one full revolution (a typical value for a small encoder). The controller has counted 35 pulses since the joint started moving.

Find: the angle through which the joint has turned.

Working:

One full revolution is 360 degrees, spread over 200 pulses.

Angle for one pulse \(= \dfrac{360^\circ}{200} = 1.8^\circ\)

Angle for 35 pulses \(= 35 \times 1.8^\circ = 63^\circ\)

the joint has turned through 63 degrees.

In the formula \(\theta = \dfrac{N}{P} \times 360^\circ\), the symbol \(\theta\) is the angle turned, \(N\) is the number of pulses counted, and \(P\) is the number of pulses the encoder produces in one revolution.

Notice what this working also tells you. This encoder cannot report any movement smaller than 1.8 degrees, because a movement that small does not complete a pulse. That value is the finest step the sensor can measure.

Counting pulses gives the amount of rotation, but not its direction. To supply direction, the encoder produces two signals, usually called A and B, from two sensors placed slightly apart so that their pulses do not line up. This offset pair is called a quadrature signal. If A changes first, the shaft is turning one way; if B changes first, it is turning the other way.

Q. What happens to the count if the arm is switched off in the middle of a movement?

A. The count is lost. When power returns the encoder starts counting again from zero, wherever the joint happens to be resting.

An incremental encoder therefore reports change in position, not position itself. It suits any system where relative position is enough, and where the arm can be sent back to a known starting point and re-zeroed if power is lost.

7.2.1.2 The Absolute Encoder

An absolute encoder solves the problem the incremental encoder leaves behind. Instead of counting movement, it reports a unique position value for every angle of rotation within a single revolution.

Its disk carries a pattern of tracks or segments, and each angular position on the disk has its own pattern. A stationary sensor reads whatever pattern is in front of it at that moment, as shown in Fig. 7.2-2. The value read out is typically in the form of binary code or Gray code.

Diagram

Fig. 7.2-2 – top view of an absolute encoder disk with four concentric coded tracks made of alternating light and dark segments, a row of stationary detectors reading across all four tracks along one radius, and a callout showing the code read at that angle

Because the pattern itself carries the position, the reading stays valid even if power is lost. Switch the arm back on and the sensor immediately reads the pattern in front of it and reports the true angle of the joint. No re-zeroing is needed. Absolute encoders are used wherever precise position information is required without recalibrating after a power cut or a system restart.

Q2. If the power goes off in the middle of a job, will the arm still know where its joints are?

A. It depends on the sensor fitted at the joint. A joint with an incremental encoder loses its count and must be driven back to a known starting position before work can continue. A joint with an absolute encoder does not, because the coded disk pattern carries the angle itself, so the correct position is read again the moment power returns.

The two encoders are compared in Table 7.1.

Table 7.1 – Incremental/rotary encoder vs absolute encoder

Feature Incremental/rotary encoder Absolute encoder
What it reports Change in position, as a count of pulses A unique position value for each angle
Reading after power loss Lost; the joint must be re-zeroed Retained; the angle is read again straight away
Output A pulse train, with A and B signals for direction A code, typically binary or Gray code
Disk pattern Evenly spaced identical slots or lines A different pattern at every angular position
Suited to Systems where relative movement is enough Systems that must know the true angle at all times

7.2.2 The Potentiometer as a Position Sensor

Not every joint needs an encoder. For a joint that swings through a limited angle — a shoulder, an elbow or a wrist that turns less than one full circle — a simpler and cheaper sensor is often enough. A potentiometer is commonly used to measure the angular position of such joints.

The potentiometer is connected to the rotating part of the joint, so its shaft turns with the joint.

the potentiometer as a joint position sensor What it is: a sensor with a curved strip of resistive material and a movable contact, called the wiper, that slides along the strip as the shaft turns. How it works: moving the wiper changes the resistance between the wiper and the end terminals. With a fixed voltage applied across the strip, this produces a voltage at the wiper that is proportional to its position. The controller reads that voltage and works out the exact angle of the joint. Used for: measuring the angle of the shoulder, elbow or wrist joint of a robotic arm. Watch out: the wiper rubs against the strip, so the contact wears down over long use and the readings become unsteady. A potentiometer also cannot turn endlessly — it works only over a limited range of angles.

Q1. How does a robotic arm know how far its joint has already turned?

A. A position sensor fitted at the joint measures it and reports the value to the controller. An incremental encoder counts pulses as the shaft turns and the count is converted into an angle. An absolute encoder reads a coded disk and reports the angle directly. A potentiometer produces a voltage that changes with the angle, and the controller converts that voltage into the angle.

7.2.3 Force/Torque, Proximity, Vision and Temperature Sensors

Position is not the only thing worth measuring. Four other kinds of sensors are commonly fitted to robotic arms.

A force/torque sensor detects the amount of force or turning effort being applied at a particular point, usually at the wrist or in the gripper. It is what lets an arm hold an egg firmly enough not to drop it and gently enough not to crush it, because the controller can stop closing the gripper once the measured force reaches the right value.

A proximity sensor detects the presence of an object near the arm without touching it. It is used to notice that a part has arrived at the pick-up point, or that something has entered the arm’s path.

A vision sensor captures images or video to guide the arm’s movements. Where an encoder tells the arm about itself, a vision sensor tells it about the scene in front of it — where the carton is lying and which way round it is facing. This is useful when objects are not always placed in exactly the same spot.

A vision sensor watching a work area also records the people working in it. Footage of workers can easily be used to judge individuals rather than to guide the robot. Point the camera only at the working area it needs to see, keep the images only as long as the task needs them, and tell the people working there what is being recorded and why.

A temperature sensor monitors the temperature of components such as motors and drive electronics, so that the controller can slow the arm down or stop it before anything overheats.

Q. Why does an arm need a proximity sensor when it already has a vision sensor?

A. A proximity sensor gives a simple, fast answer about one spot — object present or not. A vision sensor gives far more information, but the images take much longer to process.

7.3 Actuators in a Robotic Arm

Sensors tell the controller what is happening. Nothing moves until an actuator acts. Every actuator does the same basic job: it takes energy in some form — electrical, fluid or air — and turns it into movement at a joint.

Arms do very different jobs, though. A laboratory arm places a small glass tube onto a stand. A foundry arm lifts a red-hot casting weighing more than a person. These two arms cannot use the same kind of actuator. The choice depends on three things: what the task is, how precisely the arm must move, and how much force it needs. The types described below are the ones commonly used in robotic arms.

7.3.1 Electric Actuators

Electric actuators run on electric current and are by far the most common choice in ordinary robotic arms. They are clean, easy to wire, and easy for a controller to command. Three kinds are used.

A DC motor turns continuously as long as a voltage is applied across it, and turns faster as the voltage is raised. It is simple and cheap, but on its own it has no idea where its shaft is pointing, so a DC motor at a joint always needs an encoder beside it to report the position back.

A stepper motor turns in fixed steps rather than smoothly. Each electrical pulse sent to it advances the shaft by one step of a fixed size, so the controller can count out an angle without any sensor at all. This works well as long as the load stays within what the motor can handle. If the arm is pushed too hard, the motor can miss a step, and the controller will not know it has fallen behind.

A servo motor is a complete package rather than a bare motor.

the servo motor What it is: a small motor with a gearbox, a position sensor and a control circuit built into one unit. How it works: you send it the angle you want. The built-in sensor reports the angle the shaft has actually reached, and the built-in circuit keeps driving the motor until the two match. It then holds that angle against small pushes. Used for: the joints of small robotic arms, where a given angle has to be reached and held. Watch out: a common servo turns only through a limited range, often about 180 degrees, so it cannot be used where a joint must rotate freely.

expecting a servo motor to keep spinning like a DC motor What goes wrong: a student writes a program that switches a servo on, expects the joint to rotate continuously, and finds it moves once and stops. The fix: send a servo an angle, not an on or off command. To rotate a joint continuously, use a DC motor or a stepper motor instead.

7.3.2 Hydraulic and Pneumatic Actuators

Some arms have to lift loads that no small electric motor can shift. Others have to work in places where an electric spark would be dangerous. For these, the energy is carried into the arm by a fluid instead of by a wire.

Hydraulic actuators use pressurised fluid, usually oil, to generate motion and force. Because a liquid barely compresses, the push it delivers is firm and steady, and hydraulic actuators provide very high power and torque for their size. This is what allows large arms to lift heavy castings and hold them steady. The cost is bulk and upkeep: the arm needs a pump, a tank and pipes, and any leak means oil on the floor.

Pneumatic actuators use compressed air to produce linear or rotary motion. Air lines are light and cheap, the movement is fast, and there is no electrical spark at the joint. Air is compressible, however, so a pneumatic actuator is hard to stop accurately part of the way along its travel. It is used mostly for movements that run fully from one end to the other — a gripper that opens or closes, a pusher that extends or retracts.

Q3. Why do some robotic arms use compressed air or pressurised oil instead of an electric motor?

A. Because of the job and the surroundings. Pressurised oil delivers far more force and torque than an electric motor of the same size, so hydraulic actuators are used for heavy lifting. Compressed air is light, fast and produces no electrical spark at the joint, so pneumatic actuators suit fast repeated movements and places where a spark would be unsafe.

A hydraulic or pneumatic line stays pressurised even after the arm is switched off, and a joint can move suddenly when a line is opened. Never loosen or disconnect a pressurised line. Shut the supply off and let the pressure out through the proper release valve first.

The two fluid-driven types are compared in Table 7.2.

Table 7.2 – Hydraulic vs pneumatic actuators

Feature Hydraulic actuator Pneumatic actuator
What carries the energy Pressurised fluid, usually oil Compressed air
Force and torque Very high Moderate
Holding a position partway Steady, because liquid barely compresses Difficult, because air compresses
Speed of movement Slower and firmer Fast
Typical use in an arm Lifting heavy loads Opening and closing a gripper, quick push-and-return moves

7.3.3 Linear, Rotary and Piezoelectric Actuators

Actuators are also grouped by the kind of movement they produce.

A rotary actuator provides rotational motion. It is the natural fit at a joint, since a revolute joint turns, and most joints of a robotic arm are driven this way.

A linear actuator produces straight-line motion instead. Most of them start from a turning motor and convert that rotation into linear motion, typically using a screw mechanism: the motor turns a long threaded screw, and a nut riding on the screw cannot spin, so it travels along the screw and pushes a rod in or out. This is shown in Fig. 7.3-1.

Diagram

Fig. 7.3-1 – cut-away sketch of a linear actuator: a motor at one end turning a long threaded screw, a nut on the screw held so it cannot rotate, and an arrow showing the nut and the attached rod travelling out along the screw as the motor turns

Q. Why not simply build a motor that pushes in a straight line?

A. A rotating motor is cheaper, more compact and easier to control. Turning its rotation into straight-line motion with a screw is usually the simpler solution.

A piezoelectric actuator works on a completely different principle. Certain materials change shape very slightly when a voltage is applied across them, an effect called the piezoelectric effect. The actuator uses this effect to produce extremely precise and very small movements. It also keeps working in extreme conditions, such as the wide temperature swings met in space exploration. Its limitation follows from its strength: the movement it produces is tiny, so it is used for fine adjustment, never for carrying an arm across a workspace.

7.4 The Control Algorithm

By now you have two halves of an arm that cannot yet talk to each other. A sensor produces a number — an angle, a voltage, a pulse count. A motor accepts a command — turn this way, at this speed, or stop. Something in between has to take the number and work out the command. That something is a set of rules, and those rules are called a control algorithm.

You already use a machine that works this way. Set an air conditioner to 24 degrees and it does not simply run for a fixed length of time. It measures the room temperature, compares it with 24, runs the compressor while the room is warmer, and switches it off when the room is cool enough. The rules that connect the measurement to the action are the control algorithm.

NoteDefinition

A control algorithm is a set of mathematical or logical rules used to manage the behaviour of a system so that it achieves a desired outcome.

The algorithm processes inputs, such as data from sensors or commands from a user, and generates suitable outputs that drive the actuators and other parts of the system. In a robotic arm this happens over and over, many times a second, while the joint is still moving. Fig. 7.4-1 shows the path the information takes.

Diagram

Fig. 7.4-1 – block diagram of a control loop; boxes joined by arrows in this order: desired angle → comparison circle marked with a minus sign → control algorithm → actuator → joint of the arm → measured angle; a feedback arrow runs from the measured angle back to the comparison circle

7.4.1 What a Control Algorithm Does

The work of a control algorithm can be split into four key functions.

Input processing

The algorithm takes in the inputs. These come from the sensors on the arm, or from commands given by a user or by a program. The inputs could be measurements such as temperature, speed, position or force. Raw readings often need tidying first — a pulse count is converted into an angle, a wiper voltage is converted into degrees.

Decision making

Based on the input data, the algorithm works out what action is needed to get the desired behaviour. Most often this means calculating the difference between the current state and the desired state. This difference is called the error.

finding the error at a joint

Given: the controller has been told to place the elbow joint at 120°. The sensor at the joint reports the actual angle.

Find: the error in each of two cases, and what the algorithm should do.

Working:

Error = desired angle − actual angle

Case 1, the sensor reports 112.5°:

Error \(= 120^\circ - 112.5^\circ = +7.5^\circ\)

The error is positive, so the joint has not turned far enough. The algorithm keeps driving the motor in the same direction.

Case 2, the sensor reports 127.5°:

Error \(= 120^\circ - 127.5^\circ = -7.5^\circ\)

The error is negative, so the joint has gone past the target. The algorithm drives the motor the other way.

the error is +7.5° in the first case and −7.5° in the second. Its size tells the algorithm how far off the joint is, and its sign tells the algorithm which way to correct.

Output generation

Having decided, the algorithm sends control signals or commands to the actuators — motors, valves and the like — to adjust the behaviour of the system. This is the point where a calculation finally becomes movement.

Feedback handling

In a system that has feedback, the algorithm does not send one command and walk away. It keeps monitoring the output of the system and keeps adjusting its actions so that the error between the desired result and the actual result becomes as small as possible. A control system built this way, where the output is measured and fed back into the decision, is called closed-loop control.

holding a joint at a target angle Input: the target angle set by the program, and the angle measured by the sensor at the joint Output: a command to the motor at that joint Steps:

1. Read the sensor and convert the reading into the actual angle.
2. Error = target angle − actual angle.
3. If the size of the error is smaller than the allowed limit, stop the motor and finish.
4. If the error is positive, drive the motor in the forward direction.
5. If the error is negative, drive the motor in the reverse direction.
6. Go back to step 1.

Why it works: the loop never trusts its own command. It measures the result each time round, so any slipping, sticking or extra load simply shows up as an error that the next pass corrects.

Q4. What does a controller actually do with the reading it receives from a sensor?

A. It converts the reading into a usable value, subtracts it from the value that was asked for to get the error, and uses the size and sign of that error to decide what command to send to the actuator. It then reads the sensor again and repeats, so that the error keeps shrinking.

Step 3 in that method deserves a second look. The loop does not wait for the error to become exactly zero, because a real joint never lands on an exact value and a real sensor cannot measure one. It stops when the error is small enough for the task.

Q. What happens if the algorithm corrects too strongly?

A. The joint shoots past the target, the error changes sign, and the algorithm drives it back the other way. The joint can end up swinging to and fro instead of settling.

A control algorithm is also only as good as the measurement it is given. If the sensor at the joint is loose, or is reporting an angle that is 5 degrees out, the algorithm will faithfully drive the joint to the wrong place and report that the task is complete.

7.5 Finding the Position and Orientation of a Robotic Arm

Ask an arm to place a carton on a belt and two things have to be right. The gripper must arrive at the correct place, and it must arrive facing the correct way. A gripper hovering exactly above the belt with its jaws turned sideways will still put the carton down crooked.

The first of these is the position of the end effector — the point in space where it is, measured as distances along three directions from a fixed starting point. The second is its orientation — the way it is turned at that point.

Distances have to be measured from somewhere, so an arm is always set up with a reference coordinate system: a fixed point, usually at the base, with three directions marked out from it. Every position and orientation the arm works with is stated with respect to that frame. Fig. 7.5-1 shows this.

Diagram

Fig. 7.5-1 – robotic arm on its base with three axes drawn at the base and labelled x, y and z; a dot at the gripper marked “position of the end effector” with dashed lines dropping to the axes; a curved arrow through the gripper marked “orientation” showing which way the jaws face

Here is the difficulty. No sensor looks down at the gripper and reports where it is. What the arm has is a sensor at every joint. The controller reads the angle of each joint, and since the length of every link is fixed and known, it can work out from those angles where the end effector must be and which way it must be facing.

So finding position and orientation is not one action. It is a sequence of stages, worked through while the arm is being built and then repeated every time it runs. The four stages are shown in Fig. 7.5-2.

Diagram

Fig. 7.5-2 – flowchart of four boxes joined top to bottom by arrows, labelled: designing the system; sensor and actuator placement; development of control algorithm; implementation of feedback loop; with a return arrow from the last box back to the third box to show the loop repeating while the arm moves

Designing the system

Defining the task of the robotic arm comes first. What must the arm do, how far must it reach, how heavy is the load, and how accurately must it place the object? Only once the task is settled can the controller architecture be designed around it. This is also the stage at which the reference coordinate system is fixed, because every later measurement is stated with respect to it.

This order matters. An arm designed before the task is known will usually turn out to be wrong for the job in some way that no amount of programming can fix later.

Sensor and actuator placement

Based on the task assigned, the actuators and sensors are selected and mounted on the joints of the arm at strategic locations. Two conditions must be met. The actuators must sit where they can drive each joint directly, and the sensors must sit where they genuinely measure the rotation of that joint.

Alignment and calibration are checked at this stage. Calibration means comparing what the sensor reports against a known true value and correcting the difference, so that a reading of 0 degrees really does mean the joint is at its zero position.

When the robotic arm is powered on, the sensors provide their initial readings, and these establish the starting position of the joints. A joint fitted with an incremental encoder has to be driven to a known point at this moment and its count set to zero, since the encoder itself remembers nothing from before the power came on.

Q. Why does a sensor mounted slightly crooked cause trouble even if it works perfectly?

A. Every reading it sends is shifted by the same amount, so the controller confidently drives the joint to a position that is wrong by that amount every time.

Development of control algorithm

The measured angular positions are now brought together with the control algorithm, which adjusts the actuators until the joints reach the desired angles. The control system uses the feedback to correct any deviation from the target positions and so keep the movement accurate.

A command to the arm can take two forms. It may ask the arm to move to one specific position, or it may ask it to follow a trajectory — a planned path of positions passed through one after another, as when a welding tip must travel along a seam rather than jump to its far end.

Implementation of feedback loop

As the arm moves, the sensors continuously send data about the current joint angles back to the control system. In a closed-loop control system this feedback arrives in real time, fast enough for the controller to act on it while the movement is still going on.

The controller compares each fresh reading with the desired position and adjusts the input to the actuator to correct any deviation. If the actual angles do not match the desired ones, the motor commands are changed to close the gap. Once the arm reaches the desired position, the sensors provide a final reading that confirms the angles are correct, and the loop keeps running to hold the joint there for as long as the task needs.

Q5. Why must a robotic arm keep checking its own position while it is still moving?

A. Because the movement it actually makes is not always the movement it was commanded to make. A heavier load, a slipping gear or friction at a joint can all leave the arm short of the target, and a fast movement can carry it past. By reading the joint sensors continuously, the controller sees the gap while the arm is still moving and corrects it during the movement, instead of discovering the mistake only after the arm has stopped.

Hold your upper arm and elbow completely still and turn only your wrist. Your fingertips stay in almost the same place, but your palm ends up facing a different way. Note down what this shows about the difference between position and orientation.

7.6 One Joint, End to End: Sensor, Controller and Motor Together

Everything in this chapter so far has been one part at a time. This section puts three of them on a single revolute joint and shows the whole loop working.

The set-up is the simplest one that still does real closed-loop control. A potentiometer is fixed so that its shaft turns with the joint, and its wiper wire goes to an analog input of a microcontroller board such as an Arduino Uno. A DC motor drives the same joint. The board cannot supply enough current to run a motor from its own pins, so the motor is connected through a motor driver — a small board that takes low-power signals from the controller and switches the motor’s own supply accordingly. Fig. 7.6-1 shows how the parts are joined.

Diagram

Fig. 7.6-1 – block sketch of one revolute joint; a potentiometer mounted on the joint shaft with its wiper line going to pin A0 of an Arduino Uno; three lines from the Arduino to a motor driver marked IN1, IN2 and ENA; the driver connected to a DC motor and to a separate motor supply; the motor shaft driving the joint; a dashed feedback arrow running from the joint back to the potentiometer

From reading to angle

The board does not read degrees. Its analog input converts a voltage into a whole number from 0 to 1023, where 0 stands for 0 volts and 1023 for the full supply voltage. The potentiometer produces a voltage that changes with the joint angle, so the controller’s first job is to turn that number into an angle. Arduino’s map() function does this conversion using whole numbers only.

converting a sensor reading into a joint angle

Given: a potentiometer that turns through 270° across its full travel, connected to an analog input that reports values from 0 to 1023. The controller reads the value 512.

Find: the angle of the joint.

Working:

Angle \(= \dfrac{\text{reading}}{1023} \times 270^\circ\)

Angle \(= \dfrac{512}{1023} \times 270^\circ = \dfrac{138240}{1023} = 135.1^\circ\)

The map() function keeps whole numbers only, so it reports 135.

the joint is at about 135°.

That working also shows the limit of this sensor. The whole 270° range is spread over 1024 possible readings, so one step of the reading is a little over a quarter of a degree. The controller cannot see any movement finer than that.

The loop on this joint

Once the angle is known, the four functions of a control algorithm map straight onto this hardware. Input processing is the reading and its conversion into degrees. Decision making is the subtraction that gives the error. Output generation is the pair of direction signals and the speed value sent to the motor driver. Feedback handling is the fact that all of this happens again a few milliseconds later, with a fresh reading.

Disconnect both the board and the motor supply before changing any wiring at the joint. Once power is on, the joint can start turning the moment the program runs, so keep fingers, sleeves and loose wires out of its path.

driving one revolute joint to a target angle and holding it there Problem: a joint carries a potentiometer as its position sensor and a DC motor as its actuator. Drive the joint until it reaches 90°, then stop, and correct it again if it is pushed away from that angle.

// Closed-loop control of one revolute joint.
// Board: Arduino Uno.
// Sensor: potentiometer on the joint, wiper to A0.
// Actuator: DC motor through a motor driver; IN1 to pin 8, IN2 to pin 9, ENA to pin 10.
// The motor has its own supply, with its ground joined to the Arduino ground.

const int sensorPin = A0;
const int in1 = 8;
const int in2 = 9;
const int enablePin = 10;

const int targetAngle = 90;   // angle the joint must reach, in degrees
const int tolerance = 2;      // how close counts as reached, in degrees
const int motorSpeed = 150;   // driver speed value, 0 to 255

void setup() {
  pinMode(in1, OUTPUT);
  pinMode(in2, OUTPUT);
  pinMode(enablePin, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  int reading = analogRead(sensorPin);                 // 0 to 1023
  int actualAngle = map(reading, 0, 1023, 0, 270);     // potentiometer travel is 270 degrees
  int error = targetAngle - actualAngle;

  if (abs(error) <= tolerance) {
    stopMotor();
  } else if (error > 0) {
    driveForward();
  } else {
    driveReverse();
  }

  Serial.print("angle: ");
  Serial.print(actualAngle);
  Serial.print("  error: ");
  Serial.println(error);
  delay(50);
}

void driveForward() {
  digitalWrite(in1, HIGH);
  digitalWrite(in2, LOW);
  analogWrite(enablePin, motorSpeed);
}

void driveReverse() {
  digitalWrite(in1, LOW);
  digitalWrite(in2, HIGH);
  analogWrite(enablePin, motorSpeed);
}

void stopMotor() {
  analogWrite(enablePin, 0);
}

Output: the joint turns towards 90° and stops there. On the Serial Monitor a fresh line appears about twenty times a second, each showing the angle just measured and the error just calculated; the error shrinks as the joint approaches the target and then stays inside the two-degree tolerance. Turn the joint away by hand after the motor has stopped and the printed error grows again, so the motor starts and brings the joint back.

Why the tolerance is there

Remove the tolerance and set the loop to stop only at zero error, and the joint will not settle. A motor switched off while turning does not halt instantly, so the joint drifts past 90°, the error changes sign, the motor drives back, overshoots the other way, and the joint hunts about the target without ever resting. The tolerance gives the loop a small band it can stop inside.

running the motor from the board’s own 5V pin What goes wrong: the motor is wired to the 5V pin of the Arduino. The board resets or behaves oddly as soon as the motor starts, because a motor draws far more current than that pin can supply. The fix: give the motor its own supply through the motor driver, and join the ground of that supply to the ground of the board so that both share a common reference.

Change targetAngle to 60 and predict, before running the program, whether the joint will turn towards its zero position or away from it. Then run it and check your prediction.

This one joint is the whole chapter in miniature. The sensor reports what is, the control algorithm works out the difference from what should be, and the actuator closes that difference. A full robotic arm is the same loop repeated at every joint, with all the joint angles read together so that the position and orientation of the end effector can be worked out from them.

7.7 Summary

  1. A robotic arm is a programmable mechanical arm that lifts, moves and handles objects, or works with other machines and tools, in a precise and controlled way.
  2. The key components of a robotic arm are joints, links, end effector, actuators, sensors, controllers and power supply.
  3. A link is a rigid section of the arm; a joint is where two links move with respect to each other. A revolute joint turns and a prismatic joint slides.
  4. Sensors give the controller feedback — information about what the arm has actually done, so that the actual result can be compared with the desired result.
  5. An encoder measures the rotational position, speed and direction of a rotating component such as a motor shaft or a joint. There are two types: the incremental or rotary encoder, and the absolute encoder.
  6. An incremental encoder produces a pulse for each slot on its disk, so the pulse count gives the amount of rotation. Two offset signals, A and B, give the direction. Its count is lost if power is lost.
  7. An absolute encoder reads a coded disk and gives a unique position value for every angle within one revolution, typically as binary or Gray code. Its reading stays valid after a power cut.
  8. A potentiometer measures the angular position of a joint. Its wiper moves along a resistive element, producing a voltage proportional to the position, which the controller converts into an angle.
  9. Other sensors used in a robotic arm are force/torque sensors, proximity sensors, vision sensors and temperature sensors.
  10. Actuators convert energy into movement at a joint. The types used are electric, hydraulic, pneumatic, linear, rotary and piezoelectric actuators.
  11. Electric actuators include DC motors, stepper motors and servo motors. Hydraulic actuators use pressurised fluid for high power and torque; pneumatic actuators use compressed air for fast motion.
  12. A linear actuator converts rotational motion into linear motion, typically using a screw mechanism. A rotary actuator provides rotational motion at a joint. A piezoelectric actuator gives very small, very precise movements and works in extreme conditions.
  13. A control algorithm is a set of mathematical or logical rules used to manage the behaviour of a system so that it achieves a desired outcome.
  14. The key functions of a control algorithm are input processing, decision making, output generation and feedback handling in closed-loop control.
  15. Decision making rests on the error, which is the difference between the desired state and the current state. Its size shows how far off the joint is and its sign shows which way to correct.
  16. The position of the end effector is where it is; its orientation is which way it is facing. The controller works both out from the joint angles and the fixed link lengths.
  17. Finding the position and orientation of a robotic arm follows four steps: designing the system, sensor and actuator placement, development of the control algorithm, and implementation of the feedback loop.
  18. Calibration makes a sensor reading match the true value, so that the reference position the arm starts from is correct.
  19. At a single joint, the sensor measures the angle, the controller compares it with the target and works out the error, and the motor is driven until the error is small enough. The loop then repeats for as long as the arm is powered.

7.8 Key Terms

  1. Absolute encoder – An encoder that reads a coded disk and reports a unique position value for every angle within one revolution, keeping its reading valid even after power is lost.

  2. Actuator – The part of a robotic arm that produces movement at a joint by converting energy into motion.

  3. Closed-loop control – Control in which the output is measured and fed back to the controller, so that the command is adjusted while the movement is still going on.

  4. Control algorithm – A set of mathematical or logical rules used to manage the behaviour of a system so that it achieves a desired outcome.

  5. Controller – The small computer that reads sensor values, decides what should happen next, and sends commands to the actuators.

  6. DC motor – A direct current motor, which turns continuously while a voltage is applied and turns faster as the voltage is raised.

  7. Electric actuator – An actuator driven by electric current, such as a DC motor, a stepper motor or a servo motor.

  8. Encoder – A sensor that measures the rotational position, speed and direction of a rotating component such as a motor shaft or a joint.

  9. End effector – The tool fitted at the far end of a robotic arm, such as a gripper, a suction cup or a welding tip.

  10. Feedback – Information about what a system has actually done, sent back to the controller so that the actual result can be compared with the desired result.

  11. Force/torque sensor – A sensor that detects the amount of force or turning effort being applied at a particular point of the arm.

  12. Hydraulic actuator – An actuator that uses pressurised fluid, usually oil, to produce motion with high power and torque.

  13. Incremental encoder – An encoder that produces a pulse for each slot on its disk, so that the pulse count gives the amount of rotation; also called a rotary encoder.

  14. Joint – The place where two links of an arm meet and move with respect to each other.

  15. Linear actuator – An actuator that produces straight-line motion, typically by converting the rotation of a motor using a screw mechanism.

  16. Link – A rigid section of a robotic arm, whose length is fixed and known.

  17. Orientation – The direction in which the end effector is facing at a given place, as distinct from where it is.

  18. Piezoelectric actuator – An actuator that uses the piezoelectric effect to produce very small and very precise movements, and works well in extreme conditions.

  19. Pneumatic actuator – An actuator that uses compressed air to produce linear or rotary motion.

  20. Potentiometer – A sensor with a resistive element and a movable wiper, which produces a voltage proportional to the position of the wiper and so measures the angle of a joint.

  21. Power supply – The source that provides the energy needed by the motors and the electronics of a robotic arm.

  22. Prismatic joint – A joint that slides in and out in a straight line.

  23. Proximity sensor – A sensor that detects the presence of an object near the arm without touching it.

  24. Revolute joint – A joint that turns, in the way an elbow turns.

  25. Robotic arm – A programmable mechanical arm that lifts, moves and handles objects, or works with other machines and tools, in a precise and controlled way.

  26. Rotary actuator – An actuator that provides rotational motion, commonly used at the joints of a robotic arm.

  27. Rotary encoder – Another name for the incremental encoder.

  28. Sensor – A part that measures something and sends the measurement to the controller as a signal.

  29. Servo motor – A unit containing a motor, a gearbox, a position sensor and a control circuit, which drives its shaft to a commanded angle and holds it there.

  30. Stepper motor – A motor that turns in fixed steps, one step for each pulse it receives.

  31. Temperature sensor – A sensor that monitors the temperature of components such as motors, so that overheating can be prevented.

  32. Trajectory – A planned path of positions that the arm passes through one after another, rather than a single target position.

  33. Vision sensor – A sensor that captures images or video of the scene in front of the arm to guide its movements.

7.9 Objective Questions

  1. Which sensor is used to measure the rotational position of a joint in a robotic arm?

    1. Proximity sensor
    2. Temperature sensor
    3. Rotary encoder
    4. Vision sensor
  2. Fill in the blank: The difference between the desired angle of a joint and the angle actually measured at that joint is called the ____________.

  3. State whether true or false: An incremental encoder keeps its position reading even after the power supply is switched off.

  4. Which actuator uses compressed air to produce motion?

    1. Hydraulic actuator
    2. Piezoelectric actuator
    3. Pneumatic actuator
    4. Linear actuator
  5. Match each sensor in Column A with what it measures in Column B.

Column A Column B
a. Potentiometer i. How hot a motor has become
b. Force/torque sensor ii. The angular position of a joint
c. Temperature sensor iii. Whether an object is present nearby
d. Proximity sensor iv. How hard the gripper is squeezing
  1. An encoder disk has 180 slots, so it produces 180 pulses in one revolution. How many degrees does one pulse stand for?

  2. Which of the following is a key function of a control algorithm?

    1. Designing the mechanical links of the arm
    2. Output generation
    3. Supplying current to the motor windings
    4. Machining the joints of the arm

7.10 Concept Questions

  1. Define a control algorithm and name its four key functions.

  2. Explain how a potentiometer measures the angular position of a joint in a robotic arm.

  3. Give two differences between an incremental encoder and an absolute encoder.

  4. A robotic arm in a foundry has to lift heavy castings. Give one reason why a hydraulic actuator suits this work, and state one drawback of using it.

  5. An encoder fitted to a joint produces 250 pulses in one revolution. The controller has counted 75 pulses since the joint began to move. Calculate the angle through which the joint has turned, and state the smallest change in angle this encoder can detect.

  6. Explain the four steps followed to find the position and orientation of a robotic arm.

  7. What would happen if the sensors at the joints stopped sending readings while the arm was still moving towards its target? Explain your answer.

7.11 Case-Based Questions

  1. Students in a school lab build a small robotic arm with one revolute joint. A potentiometer is coupled to the joint shaft. It turns through 270° from one end of its travel to the other, and the controller board converts the wiper voltage into a whole number from 0 to 1023. The arm has been told to place the joint at 90°. At one instant the board reads the value 300.
    1. Calculate the angle of the joint at that instant, correct to the nearest degree.
    2. Find the error at that instant and state whether the motor should keep turning the joint further or turn it back.
    3. After the joint reaches the target, the students find it keeps shaking to and fro instead of settling. Suggest one change to the program that would stop this, and explain why it works.
  2. A packing shop uses a robotic arm to pick sealed food packets from a table and place them in a carton. A camera above the table guides the arm to each packet, and a sensor in the gripper measures how hard it is holding.
    1. Name the sensor that lets the arm hold a soft packet firmly without crushing it, and explain how the controller uses its reading.
    2. The camera also records the workers standing at the table. State one responsible practice the shop should follow while using this camera.
    3. After a power cut, the arm restarts and moves to the wrong place. Name the type of encoder most likely fitted at its joints, and state what must be done before work can continue.