🛞 Steering System – Servo Motor Control
📜 Overview
The steering system of our autonomous car is controlled using a servo motor. The servo adjusts the front wheels' angle by modifying its PWM (Pulse Width Modulation) duty cycle, allowing for precise directional control. Operational amplifier compares the actual value of the servo and the target value of the smoothed PWM signal and controls the electric motor with positive or negative voltage until the target and actual values are identical.
This page explains:
⚙️ How the Servo Motor Works
A servo motor operates by receiving a PWM signal, where:
- A 1ms pulse width (~5% duty cycle) steers left.
- A 1.5ms pulse width (~7.5% duty cycle) keeps the wheels centered.
- A 2ms pulse width (~10% duty cycle) steers right.
PWM Signal Representation
Duty Cycle = ( Pulse Width / Period Length ) x 100
🔩 Implementation – Controlling the Servo Motor
The FlexTimer Module (FTM) is used to generate the required PWM signals. Below is an overview of how the servo control is implemented.
Pin Configuration
Peripheral | Pin | Function |
---|---|---|
Servo Motor | PTB12 | FTM3_CH6 (PWM) |
🛠️ Code Implementation
Setting the Servo Position
The function setServoPosition()
updates the PWM duty cycle to control the steering.