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**.
This page explains:
✔ How the servo motor is used for steering.
✔ The implementation using **FTM (FlexTimer Module)** for PWM control.
✔ Code snippets for setting steering angles.
This page explains:\
:heavy_check_mark: How the servo motor is used for steering.\
:heavy_check_mark: The implementation using **FTM (FlexTimer Module)** for PWM control.\
:heavy_check_mark: Code snippets for setting steering angles.
---
## ⚙️ **How the Servo Motor Works**
## :gear: **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**
- 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**.
📌 _These signals are generated using **FTM3 Channel 6**._
### **PWM Signal Representation**

:pushpin: _These signals are generated using **FTM3 Channel 6**._
---
Duty Cycle = ( Pulse Width / Period Length ) x 100

## 🔩 **Implementation – Controlling the Servo Motor**
## :nut_and_bolt: **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**
## :tools: **Code Implementation**
### **:one: Setting the Servo Position**
### **1️⃣ Setting the Servo Position**
The function `setServoPosition()` updates the **PWM duty cycle** to control the steering.