OUTPUT DEVICES

Group Assignment

  • Measure the power consumption of an output device

Individual Assignment

  • Add an output device to a microcontroller board you have designed and program it to do something

Output Devices

Output devices receive processed data from a computer and translate it into visual, audio, or physical forms for the user. Common types include monitors for display, printers for hard copies, and speakers for sound. These peripheral components are crucial for interacting with digital information, offering both temporary and permanent results.

Output devices are what let a microcontroller act on the physical world — motors, displays, speakers, LEDs. This week focused on driving motors, which meant picking between two common types: stepper motors and servo motors.

I wanted to add a motor to my final project, to open and close the door. I was confused btween a stepper motor and a servo motor. So I went and checked up on both of them. Here's what I learned:

Stepper motors move in fixed steps and never report back, so if you say 200 steps, they do 200 steps. Servo motors have encoders, so the controller actually knows where the motor ended up and can correct if it drifted. Steppers are cheaper and good at holding a position. Servos are better when the motion needs to be fast or the load varies, because you get real feedback about what actually happened.

Property Stepper Motor Servo Motor
Control loopOpen-loop (no feedback)Closed-loop (encoder feedback)
Position accuracyFixed step incrementsCorrects errors in real time
SpeedBetter at low speedBetter at high speed
TorqueGood holding torque at restConsistent torque across speeds
CostLowerHigher
Typical use3D printers, CNC, plottersRobotic arms, dynamic loads
The main trade-off: steppers are simpler and cheaper but can lose steps under load with no way to detect it. Servos cost more but actually confirm they got there.

So I went ahead with the stepper motor.

Stepper Motor

A stepper motor, also referred to as a step motor or stepping motor, is a brushless DC electric motor that rotates in a series of small, discrete angular steps rather than spinning continuously like conventional DC motors.

Each step corresponds to a specific electrical pulse received by the motor, allowing precise control over angular position, speed, and direction without requiring complex feedback mechanisms. This characteristic makes stepper motors indispensable in applications demanding high positional accuracy and repeatability.

The stepper motor converts a train of input pulses into precisely defined increments in the shaft’s rotational position. When the digital pulses increase in frequency, the step movement transitions into continuous rotation, with the rotational speed being directly proportional to the pulse frequency. This predictable relationship between input signals and mechanical output is the key advantage that distinguishes stepper motors from other motor types.

Stepper motors find widespread use across diverse sectors, from consumer electronics such as printers and scanners to sophisticated industrial equipment including CNC machines, 3D printers, robotics, medical instruments, and precision optical systems. Their popularity arises from the combination of low cost, high reliability, excellent low-speed torque, and straightforward open-loop control.

Working Principle

The operation of a stepper motor is rooted in electromagnetic induction and the sequential energisation of stator windings. Like all electric motors, a stepper motor consists of a stationary part (the stator) and a moving part (the rotor). The stator contains multiple coils arranged in phases, while the rotor may be a permanent magnet, a toothed soft-iron structure, or a hybrid combination of both.

The fundamental operating sequence is as follows: when a current pulse is applied to a particular stator winding, it generates a magnetic field. The rotor aligns itself with this field due to magnetic attraction. When the next winding in the sequence is energised, the magnetic field shifts position, causing the rotor to advance by a fixed angular displacement—this displacement is known as the step angle. By continuously energising the windings in a specific order, the rotor rotates step by step. The step angle depends on the motor’s physical construction and determines how many steps are required for one complete revolution.

A typical stepper motor has a step angle of 1.8°, translating to 200 full steps per revolution. Mechanically, when the motor transitions from one step to the next, the rotor overshoots the target position and oscillates around it before settling—similar to a mass-spring system. The magnitude of this oscillation depends on the step size, load inertia, and damping characteristics.

Step Angle and Resolution

The step angle (θ) is the angular displacement of the rotor for each input pulse. It is determined by the motor’s construction and can be calculated using:
θ = 360° / (Nᵣ × Ø)
where Nᵣ is the total number of rotor teeth and Ø is the number of motor phases. Common step angles include 1.8° (200 steps/rev), 0.9° (400 steps/rev), and 7.5° (48 steps/rev).

Types of Stepper Motors

Stepper motors are classified into three primary types based on rotor construction: Permanent Magnet (PM), Variable Reluctance (VR), and Hybrid Synchronous. Each type offers distinct characteristics suited to different application requirements.

Permanent Magnet (PM) Stepper Motors

PM stepper motors employ a permanent magnet rotor surrounded by a stator with electromagnetic coils. When current flows through the stator windings, the resulting magnetic field interacts with the permanent magnets on the rotor, causing it to rotate in precise angular steps. PM motors are characterised by their simplicity, reliability, and ability to produce good torque at low speeds. They also exhibit detent torque—a holding force that keeps the rotor in position even when the motor is not energised. These motors are commonly used in applications requiring moderate precision, such as basic positioning tasks, consumer electronics, and medical devices.

Variable Reluctance (VR) Stepper Motors

VR stepper motors feature a rotor made of soft iron with salient teeth, rather than permanent magnets. The rotor moves by seeking the position of minimum magnetic reluctance—that is, it aligns with the energised stator pole to provide the easiest path for magnetic flux. VR motors are lightweight and can achieve higher step rates, but they produce lower torque compared to PM motors and lack detent torque. They are used in applications where speed is prioritised over holding force, and their simpler construction makes them cost-effective for certain industrial uses.

Hybrid Stepper Motors

Hybrid stepper motors combine design elements from both PM and VR types, yielding the best characteristics of each. The rotor features two caps with alternating teeth, magnetised axially, creating a construction that delivers high resolution, high torque, and good speed performance simultaneously. A standard hybrid motor typically has 200 rotor teeth and operates at a 1.8° step angle. Due to their superior performance, hybrid stepper motors are the most widely used type in commercial and industrial applications, including CNC machines, 3D printers, computer disk drives, and CD players. The trade-off is greater constructional complexity and higher cost.

Stepper Motor Driver

At the heart of the module is a powerful microstepping driver chip made by Texas Instruments—the DRV8825. Though small in size, this chip is packed with powerful features. This driver can handle up to 45V and deliver 2.5A of electrical current, which is enough power to run popular stepper motors like the NEMA 17 and NEMA 23.

One of the best features of the DRV8825 is its built-in "translator." Normally, you would need to send complex electrical signals to four different wires in a specific order; the translator simplifies this to two pins: STEP (one pulse equals one step) and DIR (direction).

Technical Specifications

Property Value
Motor output voltage 8.2V – 45V
Logic voltage Built-In 3.3V output
Continuous current per phase 1A
Maximum current per phase 2.5A
Microstep resolution Full, 1/2, 1/4, 1/8, 1/16, and 1/32

Power Pins

VMOT and GND pins supply power to both the driver and the stepper motor. This voltage can range from 8.2V to 45V.

Warning: This module uses low-ESR ceramic capacitors, making it vulnerable to destructive LC voltage spikes. Always connect a large electrolytic capacitor (at least 47 µF) across VMOT and GND close to the driver to protect it.

Microstepping Pins

The DRV8825 offers six resolution options configured via the M0, M1, and M2 pins.

M0 M1 M2 Microstep Resolution
LowLowLowFull step
HighLowLowHalf step
LowHighLow1/4 step
HighHighLow1/8 step
LowLowHigh1/16 step
HighLowHigh1/32 step
LowHighHigh1/32 step
HighHighHigh1/32 step

Note: These pins have internal pull-down resistors, so leaving them unconnected defaults the motor to Full-step mode.

Control Input Pins

Power State Control Pins

Note: Both SLP and RST must be HIGH to enable the driver. You can bridge them to a logic HIGH voltage or control them via microcontroller GPIO.

Fault Detection Pin

The FAULT output goes LOW whenever the driver detects an error condition like over-current or thermal shutdown. The driver remains disabled until RESET is toggled or VMOT power is cycled.

Output Pins

Connect your bipolar stepper motor coils here: A1/A2 for the first coil and B1/B2 for the second coil.

OLED

An Organic Light Emitting Diode (OLED) works by passing an electric current through organic material layers sandwiched between an anode and a cathode. When voltage is applied, the anode injects holes (positive charge) and the cathode injects electrons (negative charge) into these layers, which recombine in the emissive layer to create light through electroluminescence.

Advantages of OLEDs

OLEDs are commonly used in smartphones, high-end TVs, and wearable devices.

I2C (4-Pin) Module

This is the most common version and requires only two data lines for communication. It is widely used due to its simplicity and low pin count.

SPI (7-Pin) Module

SPI is used for faster communication and offers more control pins. This interface is often preferred for applications requiring higher refresh rates or more complex graphics.

Individual Assignment

So for my assignment or this week, I wanted to use a stepper motor and an led. And I decided to use Xiao DRV8825 as the stepper motor driver.

For the driver, I made a custom slot for the pins in KiCAD.

The diver has 8 pins on both sides, so I went and chose connectors with 8 pins and sockets with 8 pins.

Then I went to the PCB editor and updated the footprints of the components.

The distance between the centers of adjacent pins in the motor driver is 2.54mm. So I entered the value in the window.

Then I checked the y value of the first connector pin and gave the same value to the second pin.

Then I went and looked at the distance between the two pin on both sides of the motor driver.

You can see that the second pin is in the sixth socket.

So I went and put the distance between the two connector pins the same as the board. You can see how I did it with through the images.

You can group the components br right clicking somewhere on the window and selecting the 'Grouping' option.

You can see the distance between the two pins is 12.7 mm. This is the distance that we must give the connector sockets.

So the next step is to work with the connector sockets.

So I made the y axis value the same for bothe sockets. Then I copied the x axis value of the first connector and added the 12.7 mm to that value and gave it to the second connector.

Now the distance between the two sockets is 12.7 mm. Now the pins will fit into the sockets.

So this is my schematic.