ElectroHub

Closed-loop position control of a lead-screw axis with encoder feedback

Every CNC machine, robot joint and pick-and-place head is the same control problem: get a mass to a commanded position and hold it there against a disturbance. This project builds one axis of it — a motor driving a lead screw, an incremental encoder measuring where the carriage actually is, and a cascaded controller with a current loop inside a velocity loop inside a position loop. The demonstration is the step response and the measured following error at speed, and the lesson is the difference between the resolution the encoder claims and the accuracy the mechanics allow.

Electrical & Electronics (EEE)MechatronicsElectronics & Communication (ECE)Machines & drivesIndustrial automation & controlMeasurement & instrumentationHardware build
Rs 9,306 to Rs 28,695
All-in cost
4.3 weeks
With 3 of you
B.E. mini, B.E. final year
Usually taken as
11
Parts on the list

What it will really cost

Not just the parts. Teams budget from a component list, then run out in week six on wire, connectors and the driver board they destroyed. These are the lines that catch them.

Split betweenstudents
LineCost
Components and materials
From the bill of materials
Rs 6,895 to Rs 21,335
Spares and replacements
15 % — you will destroy something
Rs 1,034 to Rs 3,200
Consumables and hardware
Wire, connectors, headers, screws, heatshrink
Rs 827 to Rs 2,560
Perfboard and assembly
Rs 150 to Rs 400
Report, printing and binding
Two or three bound copies, plots and the plagiarism check
Rs 400 to Rs 1,200
TotalRs 9,306 to Rs 28,695
Each, split 3 waysRs 3,102 to Rs 9,565

Indicative bands last checked in August 2026 — a guide, not a quotation. Prices move and vary by seller, and anything you can borrow from the lab comes straight off the total. The 4.3 week figure assumes 10 person-weeks of work shared between 3; students past 4 add coordination rather than output, so the estimate stops improving there.

Block diagram

positionend of travelcurrentCommanded positionCascaded position, velocity and current loopsH-bridge driver with current sensingMotorLead screw and nutCarriage on linear guidesQuadrature encoderLimit and home switches
  • Sensing
  • Control
  • Power stage
  • Load / output
  • Display & logging
  • Feedback path

The same chain in words

  1. 124 V DC supply
  2. 2Motor driver with current sensing
  3. 3DC or BLDC motor coupled to a lead screw
  4. 4Carriage on linear guides, driven by the screw nut
  5. 5Incremental quadrature encoder on the motor or screw
  6. 6Limit switches at both ends, plus a home switch
  7. 7Microcontroller running the cascaded position, velocity and current loops
  8. 8Serial logging of commanded and actual position

How it works

The encoder produces two square waves in quadrature. Counting every edge of both gives four counts per encoder line, which is where the factor of four in the resolution calculation comes from.

The innermost loop controls motor current, and therefore torque. It runs fastest because it has the fastest dynamics and because it is what protects the hardware.

The velocity loop sits outside it, comparing the differentiated position against a velocity command and producing a current demand.

The position loop sits outside that, comparing commanded position against measured position and producing a velocity demand. Each loop is tuned to be several times slower than the one inside it, or they fight each other.

Homing runs at power-up: the carriage moves slowly toward the home switch, then backs off and re-approaches at low speed to find the same edge repeatably, and that position becomes zero.

Design calculations

This is the chapter that separates an engineering project from an assembly job. Every value below carries the formula that produced it and the assumptions it rests on — check them against your own ratings before you use them, because your motor is not this motor.

Position resolution

0.5 micrometre with a 2 mm pitch and a 1000 line encoder

resolution = screw pitch / (encoder lines x 4)

2 mm / 4000 counts = 0.0005 mm. Quadrature decoding gives four counts per line, which is free resolution and should always be used.

Resolution is not accuracy

50 micrometres of backlash swamps a 0.5 micrometre resolution

accuracy is limited by backlash, screw error and stiffness

This single line is the most valuable thing in the project. A cheap lead screw and nut have tens of microns of lost motion on reversal, so the axis can resolve a position it cannot actually reach. Measure the backlash with a dial gauge and report both numbers.

Motor torque required

0.035 N.m for a 100 N load on a 2 mm screw at 90 percent

T = F x pitch / (2 x pi x screw efficiency)

100 x 0.002 / (6.283 x 0.9) = 0.035 N.m. Add the torque to accelerate the carriage's own inertia, and add friction in the guides, which on a small axis is often larger than the load itself.

Loop bandwidth separation

Current 1 kHz, velocity 100 Hz, position 20 Hz

each outer loop at least five times slower than the one inside

If the position loop is as fast as the velocity loop, the two interact and the axis oscillates. The separation is what lets each loop be tuned as though the inner one were instantaneous.

Following error

1 mm at 20 mm/s with Kv = 20 per second

following error = velocity / position loop gain Kv

A proportional position loop always lags while moving — that lag is the following error and it is proportional to speed. Adding velocity feedforward is what removes it, and demonstrating the before and after is a strong result.

Homing repeatability

Second approach at a tenth of the search speed

approach the switch slowly, from the same direction, every time

A mechanical switch trips at a slightly different point depending on approach speed. Searching fast and then re-approaching slowly from a consistent direction is what makes zero mean the same thing after every power-up.

Bill of materials

ItemQtyUnit cost
Motor
24 V DC gear motor or small BLDC with encoder mount
1Rs 900 to Rs 3,000
Motor driver
H-bridge with current sensing, 10 A class
1Rs 450 to Rs 1,400
Incremental encoder
1000 PPR quadrature with index
1Rs 1,200 to Rs 3,500
Lead screw and nut
8 mm diameter, 2 mm pitch, with anti-backlash nut if affordable
1Rs 600 to Rs 2,200
Linear guides and carriage
Two rails with bearing blocks, 300 mm travel
1Rs 1,200 to Rs 4,000
Microcontroller board
STM32 with hardware quadrature decoding and timers
1Rs 450 to Rs 1,200
Limit and home switches
Micro lever switches
3Rs 15 to Rs 45
Coupling and mounts
Flexible shaft coupling, bearing blocks, base plate
1Rs 600 to Rs 1,800
Dial gauge
0.01 mm, for measuring backlash and accuracy
Borrow from the workshop or metrology lab if possible.
1Rs 500 to Rs 1,600
Power supply
24 V, 5 A SMPS
1Rs 600 to Rs 1,600
Wiring and enclosure
Shielded encoder cable, terminal blocks, ABS box
1Rs 350 to Rs 900

Specifications are written as ratings rather than brands, so any equivalent part works. Where a line says to borrow from the lab, do — it is usually the largest number on the page, and the total drops to Rs 8,806 at the low end without them.

What you need to be able to do

Skills

  • Embedded C / Arduino
  • Fabrication & mounting

None of these blocks you — they are learnable inside a semester. Each one you do not have costs a couple of weeks, so count them into your plan.

Equipment and access

  • Soldering stationrequired
  • CRO / DSO
  • Workshop (drilling, fabrication)required

Anything marked required is a blocker, not a difficulty. Arrange the access before you commit to the project, not after.

What goes wrong

  • Mechanical stiffness and backlash decide what this project can achieve, and no amount of control tuning fixes them. Build the axis first, measure its backlash with a dial gauge, and let that number set the accuracy you claim.
  • Encoder cables pick up noise from the motor drive and produce phantom counts, which show up as an axis that slowly drifts from its commanded position. Use shielded twisted-pair, ground the shield at one end only, and keep it away from the motor leads.
  • Tuning three nested loops at once is impossible. Tune the current loop first with the axis mechanically locked, then the velocity loop, then the position loop — in that order, one at a time.
  • An integrator in the position loop will wind up against a limit switch or a jammed axis and then drive hard when it releases. Clamp it, and test that behaviour deliberately rather than discovering it in the demonstration.

How to make it a stronger project

Use these when your guide says the scope is too small, or when you want something in the results chapter that nobody else in your batch will have.

  • Add velocity feedforward and show the measured following error at several speeds with and without it — a clean, quantitative result that most projects at this level do not have.
  • Add a second axis and interpolate a straight line and a circle between them, which is the step from a positioner to a machine tool.
  • Compare a trapezoidal velocity profile against an S-curve profile and measure the vibration at the end of the move with an accelerometer.

Writing the report

The structure below is what a project report is marked against, with the mistake that costs marks in each chapter. There is no template to download and there will not be one: the writing is your work, and a site that did it for you would be helping you cheat rather than helping you pass.

A mini project report runs to about 40 to 50 pages, and the literature survey is usually brief. Guides expect one clear objective, met and measured. A final year report is normally 60 to 90 pages with a substantial literature survey, and many departments expect a paper submission alongside it.

The full report guide — front matter, conventions and page counts

Abstract

One paragraph covering what the problem is, what you built, and what the result was. Written last, even though it appears first.

Loses marks: Describing the problem and the method but never stating a result. If there is no number in your abstract, it is not finished.

Introduction

Why the problem matters, the context it sits in, and a clear statement of the objectives your project set out to meet.

Loses marks: Objectives written so vaguely that nobody can tell at the end whether they were met. Write objectives you can tick off in the conclusion.

Literature survey

What has already been done, what each approach achieved, and the specific gap your work addresses.

Loses marks: A list of paper summaries with no comparison and no gap. The survey exists to justify your design choice, so end it by saying what you chose and why.

Methodology and block diagram

The system as a whole: the block diagram, what each block does, and the signal or power path between them.

Loses marks: A block diagram copied from a datasheet or another report. Draw yours to match what you actually built, including the parts that are inconvenient.

Design and calculations

Every component value and rating, with the formula, the assumptions and the arithmetic that produced it. This is the chapter that distinguishes an engineering project from an assembly job.

Loses marks: Component values with no justification. If a resistor is 10 kOhm, the report must say why it is not 1 kOhm.

Hardware and software implementation

The circuit as built, the PCB or wiring, the flowchart, and the parts of the code that carry the actual logic.

Loses marks: Twenty pages of pasted source listing. Include the flowchart and the few functions that matter, and put the full listing in an appendix.

Results and discussion

What you measured, in tables and graphs, compared against what you predicted in the design chapter — including where they disagreed.

Loses marks: Photographs of the working model presented as results. A photograph is evidence that it exists, not evidence that it works. Results are measurements.

Conclusion and future scope

Whether each objective was met, what the measured performance was, and what the honest next step would be.

Loses marks: Future scope written as a wish list of unrelated features. It should follow from a limitation you actually hit.

References and appendices

Every source in a consistent style, plus datasheets, full code listings and the complete bill of materials.

Loses marks: Citing a blog or a video where a datasheet or a standard exists. Cite the primary source for anything you relied on.

Viva questions with answers

The demonstration is half the assessment. These are the questions this project invites, and the answers are written the way you would give them out loud.

Why is the control structured as three nested loops?

Because the plant has three levels of dynamics — current, then speed, then position — and each is an integrator away from the next. Nesting lets each loop be designed as if the one inside were perfect, which makes tuning tractable, and it puts the protection where it belongs: the current loop limits torque regardless of what the outer loops demand.

What is the difference between resolution and accuracy here?

Resolution is the smallest change the encoder can report, which is set by the encoder lines and the screw pitch. Accuracy is how close the carriage actually gets to the commanded position, and it is limited by backlash, screw pitch error, guide straightness and stiffness. A system can easily resolve half a micron while being fifty microns from where it thinks it is.

Why does quadrature decoding give four counts per line?

The two channels are square waves ninety degrees apart, so within one line period there are four distinct transitions — A rising, B rising, A falling, B falling. Counting all four quadruples the resolution, and the order in which they occur is what gives the direction of travel.

What is following error and why does it exist?

It is the lag between commanded and actual position while the axis is moving. A proportional position loop produces output only in proportion to error, so it needs a standing error to command any velocity at all. The error is therefore proportional to speed, and it disappears when the axis stops. Velocity feedforward removes most of it by commanding the velocity directly rather than deriving it from an error.

Why is homing done in two passes?

Because a mechanical switch does not trip at exactly the same point at different approach speeds — there is hysteresis and mechanical compliance. Searching quickly finds the switch, and then backing off and re-approaching slowly from the same direction finds the same trip point every time, which is what makes the zero position repeatable across power cycles.

Tools for the calculations above

Normally taken as a B.E. mini project (5th/6th sem) or B.E. final year project (7th/8th sem) project. If yours is a different course, the extensions above scope it up and the simpler half of the design scopes it down — the arithmetic does not change. Back to all projects.