Chapter 9
Motion Control, Robotics, CNC, and Machine Vision
Bachelor Program in Mechatronics Engineering
Industrial Automation
•
Bachelor
Motion Control, Robotics, CNC, and Machine Vision
Introduction
Industrial automation increasingly depends on coordinated motion rather than simple on–off sequencing. A modern production cell may move a workpiece with a servo axis, orient it with a robot, machine it using CNC interpolation, inspect it with machine vision, and exchange status information with a supervisory controller. These technologies are distinct, but their engineering value arises from integration.
Motion control converts digital commands into controlled position, velocity, and force. Robotics extends motion control to multi-axis mechanisms that manipulate objects in three-dimensional space. CNC systems apply coordinated motion to machining processes. Machine vision supplies measurement and decision-making based on images. Safe-cell design combines all four with risk reduction, guarding, interlocks, and human–machine collaboration.
This chapter develops the principles needed to select, program, integrate, and evaluate such systems at bachelor level.
Learning Objectives
By the end of this chapter, a student should be able to:
Distinguish position, velocity, acceleration, and torque control in servo systems.
Apply forward and inverse kinematics to simple robot mechanisms.
Design basic point-to-point and continuous-path trajectories.
Explain robot programming, end-effectors, and coordinate frames.
Describe CNC interpolation and robot–CNC integration.
Select appropriate machine-vision components and evaluate inspection results.
Compare conventional industrial robots with collaborative robots.
Design a robotic cell using risk assessment, safeguarding, and validation principles.
1. Motion-Control Foundations
1.1 Motion-control architecture
A motion-control system normally includes a command generator, controller, drive, actuator, transmission, mechanical load, and feedback sensor. The controller compares the commanded variable with the measured variable and generates an error-correcting signal.
A typical cascade contains:
Position loop: determines the required velocity from position error.
Velocity loop: determines motor torque or current from velocity error.
Current or torque loop: regulates electromagnetic torque rapidly.
An encoder measures shaft position; a resolver or encoder may also provide velocity information. Absolute encoders retain position information after power loss, whereas incremental encoders require a reference or homing operation.
Closed-loop servo motion-control system
Figure: Closed-loop servo motion-control system
Figure: Basic closed-loop servo architecture.
1.2 Kinematic and dynamic quantities
For a translational axis, position is x(t) in metres, velocity is v(t) = dx/dt in metres per second, and acceleration is a(t) = d2x/dt2 in metres per second squared. For a rotary axis, angular position is θ, angular velocity is ω = dθ/dt, and angular acceleration is α = dω/dt.
For an ideal rotary motor:
τ = Jα + τL + bω
Here τ is motor torque in N·m, J is reflected rotational inertia in kg·m², α is angular acceleration in rad/s², τL is load torque in N·m, and bω represents viscous friction, where b has units N·m·s/rad. The model assumes a rigid transmission and neglects nonlinear friction, backlash, and motor electrical dynamics. It is useful for preliminary sizing and control analysis.
For a linear load driven by a screw with lead p metres per revolution and efficiency η, the approximate motor torque required for force F is:
τ = Fp / (2πη)
The equation assumes steady motion and neglects acceleration, bearing friction, and transmission losses other than the stated efficiency.
1.3 Servo control
A proportional–integral–derivative controller is commonly written as:
u(t) = Kp e(t) + Ki ∫e(t)dt + Kd de(t)/dt
where e(t) is tracking error, u(t) is the control command, and Kp, Ki, and Kd are proportional, integral, and derivative gains. The proportional term responds to present error, the integral term removes persistent steady-state error, and the derivative term anticipates changing error. In digital drives, the derivative term is filtered because measurement noise is amplified by differentiation.
A practical servo must also address saturation, sampling, quantization, resonance, backlash, compliance, and integral windup. Gain tuning should begin with conservative values and be verified across the full load and speed range. A system that is stable without load may oscillate when a long belt, flexible coupling, or poorly supported mechanism changes its natural frequency.
1.4 Performance measures
Important measures include settling time, rise time, overshoot, steady-state error, repeatability, accuracy, bandwidth, and disturbance rejection. Accuracy describes closeness to the desired value; repeatability describes consistency of repeated results. A robot can be highly repeatable but inaccurate if its geometric calibration is incorrect.
2. Kinematics and Trajectory Planning
2.1 Coordinate frames and transformations
Robot motion is described relative to coordinate frames. A homogeneous transformation combines rotation and translation:
T = [ R p ; 0 1 ]
where R is a 3 × 3 rotation matrix, p is a 3 × 1 position vector, and the bottom row is [0 0 0 1]. A point represented in frame B can be expressed in frame A by pA = TAB pB. Transformations must be multiplied in the correct order because rotations generally do not commute.
For planar rotation:
R(θ) = [ cosθ −sinθ ; sinθ cosθ ]
Angles may be expressed in degrees for programming interfaces, but calculus and most control calculations use radians.
2.2 Forward and inverse kinematics
Forward kinematics calculates end-effector pose from joint variables. For a two-link planar arm with link lengths L1 and L2 and joint angles θ1 and θ2:
x = L1 cosθ1 + L2 cos(θ1 + θ2)
y = L1 sinθ1 + L2 sin(θ1 + θ2)
Inverse kinematics calculates joint angles from a desired point. Let r2 = x2 + y2. Then:
cosθ2 = (r² − L1² − L2²) / (2L1L2)
and
θ1 = atan2(y,x) − atan2(L2 sinθ2, L1 + L2 cosθ2)
The plus and minus choices for sinθ2 produce elbow-up and elbow-down configurations. A solution exists only when |L1 − L2| ≤ r ≤ L1 + L2, assuming unrestricted joints. Real robots impose joint limits, collision constraints, and singularity restrictions.
Worked example. A planar arm has L1 = 0.60 m and L2 = 0.40 m. Find one configuration reaching (x,y) = (0.80,0.20) m.
Thus θ2 ≈ 70.5° for the elbow-down choice. Using the second equation gives θ1 ≈ −14.3°. Substitution into the forward equations returns approximately x = 0.80 m and y = 0.20 m. The alternate elbow configuration is also mathematically valid, but it may violate a joint limit or cause a collision.
2.3 Jacobian and singularity
The Jacobian relates joint rates to Cartesian velocity:
v = J(q) q̇
where q is the joint-vector, q̇ its rate, v Cartesian velocity, and J(q) the Jacobian. At a singularity, the Jacobian loses rank. Some Cartesian directions then become unavailable or require extremely large joint speeds. Singularity avoidance is therefore a central planning and safety concern.
2.4 Trajectory profiles
A motion command must specify position as a function of time, not merely its endpoints. Common profiles include trapezoidal velocity and S-curve acceleration. A trapezoidal profile has acceleration, constant velocity, and deceleration phases. S-curve profiles limit jerk, where j = da/dt, reducing vibration and mechanical shock.
For a symmetric triangular velocity profile with total displacement D, peak velocity vmax, and acceleration magnitude a, the acceleration time is ta = vmax/a. If the peak velocity is not reached, the total displacement is:
D = a ta²
This special formula assumes zero initial and final velocity and equal acceleration and deceleration. General profiles must account for cruise time, nonzero boundary velocities, and jerk limits.
3. Robot Programming and End Effectors
3.1 Robot types and workspaces
Cartesian robots use three orthogonal linear axes and are simple to program for rectilinear motion. SCARA robots are fast in planar assembly. Articulated robots provide broad orientation capability. Delta robots provide high-speed pick-and-place. Mobile manipulators add a mobile base but introduce localization and stability problems.
Robot specifications should be interpreted together. Payload is not constant across the workspace; maximum payload usually assumes a specified reach, speed, center of gravity, and wrist orientation. Reach, repeatability, axis speed, cycle time, controller capacity, environmental rating, and serviceability must also be considered.
3.2 Programming methods
Robot programs commonly use:
Teach pendant programming, in which an operator records poses and instructions.
Offline programming, in which a simulated cell is used to generate and verify code.
Textual or vendor-specific languages, useful for loops, conditional logic, arithmetic, and communication.
PLC or supervisory commands, used for handshaking and production sequencing.
A robust program separates motion instructions from process logic. It checks permissives before motion, confirms part presence, monitors gripper feedback, and defines recovery behavior after faults. Coordinate systems should include world, robot base, tool, and work-object frames. Tool-center-point calibration is essential: an incorrect tool frame can produce systematic positioning errors and unexpected collisions.
3.3 End effectors
End effectors include pneumatic parallel grippers, vacuum cups, magnetic grippers, servo grippers, welding torches, screwdrivers, dispensing nozzles, and machining spindles. Selection depends on part geometry, mass, surface, temperature, fragility, contamination, required force, cycle rate, and failure mode.
For a vacuum gripper, the ideal holding force is approximately:
F = Δp A
where Δp is pressure difference in pascals and A is effective sealed area in square metres. The usable force is lower because of leakage, acceleration, orientation, and safety factors. A vertical lifting design should include a factor of safety and should detect vacuum loss rather than assuming that a valve command proves gripping.
4. CNC and Robotic Integration
4.1 CNC principles
Computer numerical control commands machine axes using programmed coordinates, feed rates, spindle speeds, tool offsets, and auxiliary functions. Linear and circular interpolation coordinate multiple axes so that the tool follows a commanded path. The controller performs interpolation at a much higher rate than the program block rate.
Machining performance depends on cutting speed, feed per tooth, number of teeth, and spindle speed. For a milling cutter of diameter D and cutting speed Vc:
n = 1000 Vc / (πD)
when Vc is in m/min, D is in mm, and n is in revolutions per minute. Feed rate is:
vf = fz z n
where fz is feed per tooth in mm/tooth and z is the number of teeth. These equations assume conventional definitions and do not replace tooling manufacturers’ limits.
4.2 Robot–CNC cell integration
A robot may load raw material, unload finished parts, change fixtures, present a tool, or perform post-process inspection. Integration requires a clear handshake. A typical sequence is:
CNC reports cycle complete and safe loading position.
Robot checks cell permissives and enters the load zone.
Robot confirms gripper status and removes the finished part.
Robot loads the new part and verifies seating or clamping.
Robot exits, signals “part present,” and CNC confirms clamp pressure.
CNC starts the machining cycle.
Signals should have defined meanings, ownership, timeout behavior, and fault recovery. Safety signals must not be treated as ordinary production signals. A communication network can coordinate sequence logic, but it cannot substitute for a properly designed safety circuit or safety-rated control function.
5. Machine Vision
5.1 Vision-system architecture
A machine-vision system generally contains illumination, optics, camera, image-acquisition hardware, processing software, and an interface to the automation controller. The image is a measurement of reflected or transmitted light, not a direct measurement of the object itself. Consequently, lighting often has more influence than the choice of algorithm.
Common lighting arrangements include backlighting for silhouette measurement, diffuse dome lighting for reflective parts, coaxial lighting for flat surfaces, and dark-field lighting for scratches or edges. Lens selection involves field of view, working distance, sensor size, resolution, distortion, and depth of field.
5.2 Inspection pipeline
A reliable pipeline normally performs image acquisition, preprocessing, segmentation, feature extraction, classification or measurement, and decision communication. Thresholding may separate foreground from background. Morphological operations can remove isolated pixels or close small gaps. Edge detection identifies intensity transitions. Measurement tools calculate dimensions, position, orientation, or defect area.
Calibration maps pixel coordinates to physical coordinates. If a calibrated image has scale s mm/pixel, a measured distance of d pixels corresponds to L = sd mm, provided distortion is negligible or corrected. Perspective distortion requires a planar transformation or calibrated camera model.
Performance must be evaluated using representative samples. For a binary inspection, a confusion matrix includes true positives, true negatives, false positives, and false negatives. Recall or sensitivity is:
Recall = TP / (TP + FN)
Precision is:
Precision = TP / (TP + FP)
where TP, FN, and FP denote true positives, false negatives, and false positives. A production engineer must choose the balance according to risk. Missing a dangerous defect may be more serious than rejecting an acceptable part.
5.3 Vision-guided robotics
A camera may be fixed above a conveyor (eye-to-hand) or mounted on the robot wrist (eye-in-hand). The system must establish the transformation between the camera frame and robot frame. Calibration errors, conveyor motion, lens distortion, latency, and part variability affect pick accuracy. A vision result should include confidence and validity checks rather than only a raw coordinate.
Artificial intelligence can classify complex defects that are difficult to describe with fixed rules, but it introduces dataset, explainability, drift, cybersecurity, and validation concerns. A learned classifier must be tested on new production conditions, not only on training images.
6. Collaborative Robotics and Safe Cells
6.1 Conventional and collaborative robots
Collaborative robots are designed to support specified forms of human–robot interaction. Collaboration does not mean that every operating mode is inherently safe. Risk depends on speed, force, payload, tooling, workpiece geometry, contact location, human behavior, and the complete application.
Collaborative strategies include safety-rated monitored stop, hand guiding, speed and separation monitoring, and power-and-force limiting. A sharp tool, heavy payload, or rapidly moving workpiece may make collaboration inappropriate even when the robot itself is marketed as collaborative.
6.2 Risk assessment
A cell risk assessment identifies hazards, estimates risk, applies protective measures, and verifies residual risk. Hazards include crushing at robot joints, impact, ejected parts, sharp tools, unexpected restart, electrical energy, pneumatic pressure, hot surfaces, noise, and ergonomic strain.
The hierarchy of risk reduction is:
Inherently safe design, such as reducing stored energy or eliminating sharp edges.
Engineering safeguards, such as fixed guards, interlocked gates, scanners, light curtains, and safety-rated monitored stops.
Information for use, including procedures, training, signs, and personal protective equipment.
Guarding must account for reach-through distances, access points, bypass possibilities, reset location, and escape. An emergency stop is important, but it is not a substitute for guarding or prevention of access to a hazard.
Applicable requirements vary by jurisdiction and application. Engineers should consult current machinery-safety standards, electrical codes, robot standards, lockout/tagout rules, and employer procedures. Standards provide structured methods, but compliance still requires application-specific validation.
6.3 Safety validation
Safety functions should be specified by required response, safe state, performance level or safety integrity target where applicable, diagnostic coverage, and fault behavior. Validation includes inspection, functional testing, fault insertion where appropriate, measurement of stopping time, and documentation. Changes to software, tooling, layout, payload, or operating mode can invalidate a previous assessment.
7. Applied Case: Vision-Guided CNC Loading Cell
The following is an illustrative case.
Background
A manufacturer machines aluminum housings on a CNC mill. Parts arrive randomly oriented on a conveyor. A six-axis robot loads the fixture, the CNC machines two faces, and a camera checks a drilled-hole pattern after machining.
Problem
Manual loading causes variable cycle time and occasional reversed parts. The existing inspection system rejects some good parts because reflections from the machined surface change with orientation. The cell also lacks clear recovery behavior when the robot fails to grip a part.
Analysis
The process requires orientation recognition, repeatable gripping, safe CNC handshaking, and inspection robust to surface variation. A vacuum gripper is unsuitable because the part has a porous casting surface and an open cavity. A mechanical gripper with part-presence sensing is selected. The camera is placed before loading, with diffuse lighting and a calibrated fixture reference.
The required interface is divided into production and safety functions. Production signals include “CNC ready,” “fixture clamped,” “robot part present,” and “inspection result.” Safety functions include gate monitoring, emergency stop, and safe robot stop. Timeouts are added to every handshake.
Approach and solution
The vision system identifies two asymmetric features and estimates orientation. The robot transforms the detected pose into its work-object frame, approaches at reduced speed, closes the gripper, and verifies both finger position and grip force. It then presents the part to a locating fixture. Fixture sensors confirm seating before clamping. Only after the robot exits the guarded machining zone does the CNC begin.
After machining, the robot transfers the part to the inspection station. The camera uses diffuse illumination and a calibrated pixel-to-millimetre transformation. The inspection algorithm measures hole centers and compares them with tolerance limits. Parts outside tolerance are placed in a quarantine bin, while uncertain images are diverted for human review rather than automatically accepted.
Outcome
The integrated design removes orientation errors and makes failure modes explicit. The most important improvement is not a sophisticated classifier; it is the combination of stable lighting, mechanical location, grip verification, timeout handling, and independent safety functions.
Learning points
Mechanical design and lighting often determine automation reliability more than software complexity.
Every commanded action needs feedback.
Production communication and safety communication must remain conceptually and technically distinct.
Inspection thresholds should be selected from measured process capability and defect consequences.
Recovery procedures are part of the design, not an afterthought.
8. Design and Commissioning Best Practices
Begin with the process requirements: cycle time, tolerance, payload, reach, environment, defect classes, changeover, and human access. Select equipment using worst-case conditions, not nominal catalog values. Model reachability and singularities before purchasing hardware. Include cable routing, maintenance access, calibration references, and spare capacity.
During commissioning, verify one subsystem at a time: I/O, axes, homing, limits, tool frames, gripper sensing, vision calibration, CNC handshaking, and safety functions. Test abnormal conditions deliberately: missing parts, failed sensors, communication loss, power restoration, obstructed gates, and rejected products. Record parameter versions and calibration data.
For employability, engineers should be able to read electrical and pneumatic diagrams, interpret robot and CNC documentation, write structured sequence logic, use coordinate transformations, conduct basic statistical inspection analysis, and communicate hazards clearly to technicians and operators.
Challenges and Limitations
Automation performance is limited by mechanical compliance, sensor uncertainty, calibration drift, thermal expansion, communication latency, and variation in raw materials. A robot’s repeatability does not guarantee process capability. Vision systems can fail under changing illumination, contamination, reflection, or unseen defect types. CNC accuracy depends on machine geometry, tool wear, thermal state, and fixturing.
High automation can also increase integration complexity and cybersecurity exposure. Networked robots, cameras, and CNC controllers should use controlled access, secure backups, change management, and segmented networks. Data collected for quality decisions may affect workers or suppliers and should be governed appropriately. AI-based inspection requires attention to bias in datasets, traceability of decisions, and human review of uncertain cases.
Chapter Summary
Motion control uses feedback, cascaded servo loops, and trajectory generation to achieve accurate and stable movement. Kinematics relates joint variables to end-effector position, while inverse kinematics must account for multiple solutions, limits, collisions, and singularities. Trajectory planning controls velocity, acceleration, and jerk rather than commanding only endpoints.
Robotic applications depend on calibrated coordinate frames, reliable end-effectors, tool-center-point accuracy, and explicit feedback. CNC systems coordinate axes for machining and must exchange well-defined signals with robots. Machine vision combines controlled illumination, optics, acquisition, processing, calibration, and statistically evaluated decisions. Collaborative robots require application-specific risk assessment; their collaborative label does not eliminate hazards. A safe robotic cell integrates inherently safe design, engineering safeguards, validated safety functions, documented procedures, and robust recovery behavior.
Key Terms
Motion control: Regulation of position, velocity, or torque in a mechanical system.
Servo loop: Feedback control loop used to regulate a motion variable.
Encoder: Sensor that measures angular or linear position.
Repeatability: Ability to return consistently to the same result.
Homogeneous transformation: Matrix representation combining rotation and translation.
Forward kinematics: Calculation of pose from joint variables.
Inverse kinematics: Calculation of joint variables for a desired pose.
Jacobian: Matrix relating joint rates to Cartesian velocity.
Singularity: Configuration in which the Jacobian loses rank or motion authority.
Trajectory: Time-dependent path of position, velocity, and acceleration.
End effector: Tool or gripper attached to a robot wrist.
Tool-center point: Reference point used to define an attached tool’s pose.
CNC: Computer numerical control of machine-tool motion.
Interpolation: Coordinated calculation of intermediate axis positions.
Machine vision: Image-based sensing and decision-making for automation.
Calibration: Establishment of a relationship between measurements and physical quantities.
Collaborative robot: Robot designed for specified human–robot interaction modes.
Risk assessment: Structured identification, evaluation, and reduction of hazards.
Safety-rated monitored stop: Safety function that stops motion while maintaining controlled restart conditions.
Review Questions
Short Answer Questions
What is the difference between accuracy and repeatability?
Why are coordinate frames essential in robot programming?
What function does a tool-center-point calibration perform?
Name two factors that influence machine-vision reliability besides the algorithm.
Why must production signals be distinguished from safety signals?
Long Answer Questions
Explain the architecture and purpose of cascaded position, velocity, and current servo loops.
Derive the planar two-link forward-kinematics equations and discuss inverse-kinematic alternatives.
Describe a complete robot–CNC handshake, including normal operation and timeout recovery.
Explain how lighting, optics, calibration, segmentation, and classification interact in a vision system.
Compare conventional guarded robotics with collaborative robotics, including limitations of collaborative operation.
Analytical / Application Questions
A two-link planar robot has link lengths 0.50 m and 0.35 m. Determine whether the point (0.20 m, 0.70 m) is reachable, and justify your answer using the reachability condition.
Design a vision-guided pick-and-place sequence for randomly oriented metal components. Specify the camera arrangement, lighting, calibration method, robot frames, feedback signals, and recovery actions.
Develop a preliminary safety concept for a robot loading a CNC machine. Identify at least five hazards, propose risk-reduction measures, and describe how the safety functions would be validated.
Multiple Choice Questions with Answers
Question 1
For a rotary load, which equation represents the basic inertial torque term?
A. τ = Jα
B. τ = J/α
C. τ = α/J
D. τ = J + α
Correct Answer: A. τ = Jα
Question 2
In a closed-loop servo system, the encoder primarily provides information about:
A. Ambient temperature
B. Measured position
C. Tool material
D. Network bandwidth
Correct Answer: B. Measured position
Question 3
For a two-link planar arm, a kinematic solution exists only if:
A. r > L₁ + L₂
B. r < |L₁ − L₂|
C. |L₁ − L₂| ≤ r ≤ L₁ + L₂
D. r = 0 for all link lengths
Correct Answer: C. |L₁ − L₂| ≤ r ≤ L₁ + L₂
Question 4
Which trajectory feature most directly reduces mechanical shock?
A. Higher payload
B. Limited jerk
C. Lower encoder resolution
D. Removing feedback
Correct Answer: B. Limited jerk
Question 5
The tool-center point defines:
A. The robot’s electrical ground
B. The reference point and orientation of an attached tool
C. The CNC spindle frequency only
D. The camera pixel size
Correct Answer: B. The reference point and orientation of an attached tool
Question 6
For a milling cutter, if cutting speed is 100 m/min and diameter is 50 mm, the approximate spindle speed is:
A. 64 rpm
B. 637 rpm
C. 6,370 rpm
D. 31,400 rpm
Correct Answer: B. 637 rpm
Question 7
Which lighting arrangement is generally suitable for silhouette measurement?
A. Backlighting
B. Random ambient lighting
C. Flashing warning light
D. No illumination
Correct Answer: A. Backlighting
Question 8
Recall in binary inspection is calculated as:
A. TP/(TP + FN)
B. TP/(TP + FP)
C. FP/(TP + FN)
D. TN/(TN + FP)
Correct Answer: A. TP/(TP + FN)
Question 9
A collaborative robot is best understood as:
A. A robot that is safe in every application without assessment
B. A robot intended for specified interaction modes requiring application-specific risk assessment
C. A robot that never needs guarding
D. A robot that cannot use tools
Correct Answer: B. A robot intended for specified interaction modes requiring application-specific risk assessment
Question 10
Which is an engineering safeguard rather than information for use?