Haptic Feedback: Brushless Motors & Physics
Learning Goal: Build and program a 1-DOF haptic feedback interface using a brushless motor and encoder to simulate virtual physical sensations like stiffness, walls, and damping.
Prerequisites
- Programming: Basic familiarity with C++ and the Arduino IDE (defining variables, loops, and calling libraries).
- Mathematics: Introductory algebra and trigonometry (understanding vectors and basic coordinate systems).
- Physics: High-school-level classical mechanics (forces, springs, and basic kinematics).
Estimated Study Time
- Total Time: 28 Hours (including video lectures, written guides, physical assembly, and programming exercises).
Module 1: Basics of Haptic Feedback & Virtual Physics
Module Overview
This module introduces the mechanical and physical principles that govern haptic interfaces. You will transition from basic physical models (Hooke’s Law, Mass-Spring-Damper systems) to how these systems are modeled digitally in a haptic loop. You will study how a microcontroller reads position, calculates virtual forces, and commands an actuator in a tight, high-frequency sensing-actuation loop.
Recommended Videos
Why This Video is Essential
This video provides a concise overview of the core haptic rendering loop. It establishes the bidirectional nature of haptics: reading physical position from an encoder, passing it to a virtual environment simulation to compute physical interactions, and outputting torque commands to the actuator.
Why This Video is Essential
Prof. De Luca provides a vital mechanical interpretation of Proportional-Derivative (PD) control. In haptics, PD control is mathematically equivalent to attaching virtual springs (Proportional) and dampers (Derivative) to a system. Understanding this bridge between classical robotics control and physical sensation is key to writing haptic algorithms.
Why This Video is Essential
This video breaks down the physics of Mass-Spring-Damper systems. It provides an intuitive, visual representation of why soft-body and physics-based simulations rely on these equations, preparing you to translate continuous physical equations into discrete firmware instructions.
Why This Video is Essential
A rigorous explanation of Hooke’s Law (). To simulate a realistic virtual spring on a 1-DOF knob, you must master the relationship between displacement from equilibrium () and the resulting restoring force ().
Module 1 Gap Coverage & Self-Study
- Academic Rendering Gaps: Many introductory videos focus on commercial haptic suits rather than mathematical rendering.
- Self-Study Task: Study the concept of Virtual Coupling. Write out the state equations of a haptic device interacting with a virtual wall. Identify why update rates of 1 kHz or higher are mathematically required to prevent the discrete spring-damper system from adding energy (unstable oscillations) to the user's hand.
Knowledge Checkpoint
- Write down Hooke's Law and identify how the negative sign relates to the direction of a haptic restoring force.
- Sketch a block diagram of a haptic loop, detailing the input (encoder position), the computational step (virtual physics calculation), and the output (motor torque).
- Explain the physical sensation difference between a pure virtual spring (proportional to position) and a virtual damper (proportional to velocity).
Module 2: Microcontrollers and High-Resolution Encoders
Module Overview
Haptic loops require incredibly precise position measurements to calculate smooth virtual forces. This module covers how to wire and program magnetic rotary encoders (such as the AS5048A and AS5600) using SPI and I2C protocols, and explains why high-resolution sensors are required to compute clean velocity derivatives without introducing noise.
Recommended Videos
Why This Video is Essential
This video is a direct, practical guide showing how to wire the high-resolution AS5048A magnetic encoder to an Arduino using the SPI protocol. It clearly demonstrates hardware connections (MISO, MOSI, SCK, CS) crucial for fast, low-latency haptic loops.
Why This Video is Essential
An exhaustive deep-dive into the AS5600 magnetic position sensor. This video breaks down how 12-bit resolution translates to angular steps, explaining the physical mounting requirements of the diametrically magnetized magnet over the IC sensor.
Why This Video is Essential
A quick but critical hardware insight: it explains the direct relationship between encoder resolution and force-feedback quality. Higher resolutions eliminate "stepping" or "notching" sensations in the haptic loop, resulting in continuous, silky-smooth virtual physical rendering.
Module 2 Gap Coverage & Self-Study
- Encoder Quantization Noise: When calculating virtual damping (), we compute velocity by differentiating position: .
- Self-Study Task: Calculate the velocity error spikes caused by a 12-bit encoder (AS5600, 4096 steps/rev) vs. a 14-bit encoder (AS5048A, 16384 steps/rev) running at a 1 kHz loop rate. Notice how a lower resolution sensor yields massive discrete steps in velocity, which translates to loud, buzzing vibration noise in the motor.
Knowledge Checkpoint
- Connect an AS5048A or AS5600 encoder to your microcontroller and write a script to output the raw angle to the serial plotter.
- Explain the difference between an incremental quadrature encoder (signals A and B) and an absolute magnetic SPI encoder in the context of haptic initialization.
- Why must the magnet paired with a magnetic rotary sensor be "diametrically magnetized" rather than axially magnetized?
Module 3: BLDC Motors and Field Oriented Control (FOC)
Module Overview
Brushed motors have friction and cogging torque. To build high-fidelity haptic interfaces, we use brushless DC (BLDC) motors driven by Field Oriented Control (FOC). This module demystifies the vector math behind FOC (Clarke and Park Transforms) and shows how to configure a motor driver for smooth, cogging-free torque control.
Recommended Videos
Why This Video is Essential
This is the definitive academic guide on Field Oriented Control. It provides the deep mathematical framework necessary to understand how three-phase AC stator currents are transformed into a rotating, two-coordinate DC system (D-axis and Q-axis) to achieve direct torque control.
Why This Video is Essential
This video connects abstract FOC theory to actual hardware configuration. It explains how FOC transforms the physical three-phase coordinate frame (ABC) to the Direct-Quadrature (DQ) rotating reference frame to decouple magnetic flux control from torque control.
Why This Video is Essential
This video compares stepper motors to BLDC motors driven by FOC. It explains why FOC allows a motor to run in near-silence, with maximum efficiency, and with continuous holding torque—all absolute requirements for clean haptic feedback.
Why This Video is Essential
A practical hands-on guide using the popular SimpleFOC library. You will learn how to write basic calibration and test scripts to verify motor-to-sensor physical alignment before launching torque control.
Mathematical Summary of FOC (Self-Study Guide)
To address the math gaps, master these two key mathematical transforms used in FOC firmware:
-
Clarke Transform: Converts three-phase currents () in a 120-degree spatial frame into a static two-phase orthogonal coordinate system ():
-
Park Transform: Rotates the static orthogonal frame () by the rotor’s electrical angle () into the rotating rotor reference frame ():
In haptics, we keep the direct-axis current (zero magnetic flux drag) and modulate the quadrature-axis current because torque is directly proportional to :
Knowledge Checkpoint
- Explain why a standard DC motor driver (H-Bridge) is insufficient for FOC control of a 3-phase BLDC motor.
- Write down the relationship between the Q-axis current (), D-axis current (), and the output mechanical torque.
- Successfully run the SimpleFOC "align sensor" routine and verify that the motor shaft holds its position with zero cogging.
Module 4: Programming Virtual Sensations (Springs, Walls, and Detents)
Module Overview
This is the capstone module where physics, sensors, and motor control converge. You will write code to render physical barriers, custom spring constants, fluid damping, and tactile "detent" textures.
Recommended Videos
Why This Video is Essential
This video visualizes how to program textures and virtual detents on a BLDC rotary knob. It demonstrates how modulating the proportional gain dynamically based on position creates the sensation of physical "notches" or "clicks."
Why This Video is Essential
This video reviews open-source DIY haptic smart knob projects. It shows how combining a brushless motor, a magnetic encoder, and custom software creates an elegant, tactile user interface with programmable detents.
Step-by-Step Firmware Architecture (Gap Resolution)
Because the video pool lacks a raw code walkthrough for running virtual walls and spring-dampers inside the loop, use this reference code template designed for Arduino with the SimpleFOC library:
#include <SimpleFOC.h>
// Initialize BLDC Motor and Encoder BLDCMotor motor = BLDCMotor(11); // 11 pole pairs BLDCDriver3PWM driver = BLDCDriver3PWM(9, 10, 11, 8); MagneticSensorSPI sensor = MagneticSensorSPI(AS5148_SPI, 10);
// Haptic Parameter Settings float stiffness = 2.5; // Spring constant (k) float damping = 0.05; // Damping constant (c) float wall_position = 1.0; // Angle threshold for virtual wall (radians)
void setup() { sensor.init(); motor.linkSensor(&sensor); driver.voltage_power_supply = 12; driver.init(); motor.linkDriver(&driver);
motor.controller = MotionControlType::torque; // Torque control mode motor.init(); motor.initFOC(); }
void loop() { motor.loopFOC(); // Run FOC algorithm in background
float current_angle = sensor.getAngle(); float current_velocity = sensor.getVelocity(); float target_torque = 0;
// 1. Render Virtual Spring (F = -k * x) // Restores the knob to angle = 0 target_torque = -stiffness * current_angle;
// 2. Render Virtual Damper (F = -c * v) // Opposes motion to simulate moving through molasses target_torque -= damping * current_velocity;
// 3. Render Virtual Wall (Hard boundary at angle > wall_position) if (current_angle > wall_position) { float penetration = current_angle - wall_position; // Extremely high restoring force + extra damping to prevent bouncing target_torque = -15.0 * penetration - 0.2 * current_velocity; }
// Send torque command to SimpleFOC motor.move(target_torque); }
Knowledge Checkpoint
- Flash the code template above to your microcontroller. Verify that spinning the motor shaft away from zero produces a spring-like restoring force.
- Modify the code to simulate physical "detents" by rendering a sine wave force-profile: , where is strength and is the number of detents.
- Explain how to program a virtual "one-way wall" where the user can push past a barrier in one direction but is blocked from returning.
Course Map
Key People Index
- Prof. Alessandro De Luca (Sapienza University of Rome)
- Context: A world-renowned researcher in robotics control and physical interaction. His lecture on PD control provides the mathematical foundation of haptic rendering loops.
- Walter Lewin (Professor Emeritus, MIT)
- Context: Renowned physicist whose experimental demonstrations of Hooke's Law and Simple Harmonic Motion ground haptic equations in real-world measurements.
Final Self-Assessment
Complete this comprehensive self-assessment to verify your mastery of haptic engineering:
- I can describe the differences between physical force feedback and simple vibration-based haptic alerts.
- I can calculate the angular step size of a 14-bit magnetic encoder.
- I can successfully wire and configure an SPI-based magnetic encoder with an Arduino.
- I can mathematically explain the Clarke and Park transforms and write down how they decouple motor torque.
- I can explain why cogging torque ruins a haptic interface and how FOC resolves this issue.
- I can write an Arduino loop that executes at a rate of 1 kHz to maintain system stability.
- I can write firmware code that implements a virtual spring equation ().
- I can write firmware code that implements virtual damping () using calculated velocity.
- I can program a rigid boundary (virtual wall) and tune its parameters to prevent physical oscillations or bouncing.
- I can program a virtual tactile detent map and adjust its spacing and holding force dynamically.












