Welcome to my website!
This project explores the design and implementation of virtual haptic environments using an S32K144 microcontroller. By combining quadrature decoding for position sensing with Pulse Width Modulation (PWM) for motor control, I created a system that can simulate various physical properties like springs, walls, and dampers through touch.
The haptic interface provides force feedback based on the position of a rotary wheel, allowing users to physically “feel” virtual objects through the sense of touch. This project demonstrates fundamental concepts in embedded control systems, digital signal processing, and human-computer interaction.
The system architecture combines multiple embedded control techniques:
Hardware architecture showing the signal flow from microcontroller to haptic feedback
I implemented several virtual haptic environments, each with unique physical properties:
The spring model applies a restoring torque proportional to angular displacement:
float virtualSpring(float angle)
{
float k_spring = 5; // Spring constant (N·mm/degree)
float torque = -k_spring * angle;
return torque;
}
This creates a sensation of pushing against a spring, with increasing resistance as the wheel rotates further from the center position.
The wall model creates a rigid boundary at a specific angular position:
float virtualWall(float angle)
{
float torque = 0;
float k_wall = 500; // Wall stiffness (N·mm/degree)
if (angle < WALL_POSITION)
{
torque = -k_wall * (angle - WALL_POSITION);
}
return torque;
}
Users feel free movement on one side of the boundary, but encounter resistance when attempting to move through the virtual wall.
Visualization of virtual spring (left) and virtual wall (right) force profiles
The implementation demonstrated several interesting findings:
For a spring constant of 5 N·mm/degree with a wheel moment of inertia of 6.4×10^-4 kg·m²/radian, the theoretical oscillation frequency was 1.4 Hz. In practice, the measured oscillation frequency was 1.2 Hz, with the difference attributed to:
While increasing the wall spring constant (k_wall) made the wall feel more rigid, extremely high values (>1000 N·mm/degree) resulted in oscillatory behavior as the system repeatedly corrected position. The optimal value was found to be approximately 500 N·mm/degree, providing a good balance between:
The project successfully demonstrated that convincing haptic environments can be created with relatively simple control algorithms and careful tuning of system parameters.