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.
---
## ⚙️ **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**
📌 _These signals are generated using **FTM3 Channel 6**._

---
## 🔩 **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**
### **1️⃣ Setting the Servo Position**
The function `setServoPosition()` updates the **PWM duty cycle** to control the steering.
```cpp
// Function to set the servo position based on the desired duty cycle