This module demonstrates how to implement a steering control system using Pulse Width Modulation (PWM) on NXP S32K3 microcontrollers.
The application reads an analog input from a potentiometer (simulating a steering wheel) and converts it into a servo motor position. As the input changes, the servo motor reacts in real time, mimicking how steering systems work in modern vehicles.
This example is based on Application Code Hub demonstrations for:
In this workshop, a POT Click simulates the steering wheel position. When the student rotates it, an analog voltage proportional to the angle is read by the MCU through the ADC, scaled in software, and converted into a PWM duty cycle. The PWM is generated by the Servo Click (configured by the MCU over I²C) and drives a Micro Servo motor SG 180°, whose angle tracks the potentiometer in real time.
The three elements capture exactly the basic idea of the system in the demo:
This matches the classic flow of an embedded actuation system: sensor → processing → actuator.
The system operates continuously as follows:
This loop runs continuously to ensure real-time control.
Steering Monitoring Application Architecture
The POT Click outputs 0–3.3 V depending on the wiper position. The ADC samples this voltage at regular intervals and quantizes it into a digital code (a 12-bit ADC produces values between 0 and 4095). The further the potentiometer is turned, the higher (or lower) the digital sample. ADC acquisition is the foundation of automotive sensing — used for torque, throttle, battery voltage, and many others.
The ADC range (for example 0–4095) and the servo range (0°–180°, expressed as a PWM duty cycle) are different. The application performs a linear mapping so that one end of the potentiometer corresponds to one steering extreme and the other end to the opposite. This is the same scaling used in real EPS systems, where a hardware reading is converted into a normalized control command.
PWM switches a digital output on and off at a fixed frequency, varying the duty cycle (the fraction of time the signal is high). A hobby servo such as the SG 180° interprets this duty cycle as a position command. In this demo, the PWM is not generated by the MCU itself but by the Servo Click's dedicated PWM controller, which the MCU configures over I²C — a typical embedded pattern that offloads time-critical signal generation and keeps the CPU free for application logic.
I²C — Inter-Integrated Circuit is a two-wire serial bus made of SDA (data) and SCL (clock). The S32K3 uses LPI2C1 on PTC6 (SDA) and PTC7 (SCL) to configure the Servo Click — PWM frequency, channel, and duty cycle. The OE — Output Enable pin on PTB17 is an additional control line that enables or disables the PWM outputs without reconfiguring the chip, which is also useful for a quick "safe stop" behavior.
The POT Click is a simplified, safe stand-in for a real steering sensor. The student rotates it by hand, the voltage changes, the MCU reads it through the ADC, scales it, and the servo reacts.
Physical rotation → analog voltage → ADC sample → scaled command (angle / duty cycle) → I²C configuration of the Servo Click → PWM signal → servo angle. This direct chain from the student's hand to the servo shaft is the main educational value of the demo.
Required Hardware
| Component | Image | Purpose |
|---|---|---|
| FRDM-A-S32K312 |
Alternative MCU platform used to run the steering application and process steering inputs.
|
|
| FRDM-A-S32K344 |
Alternative MCU platform used to run the steering application and control connected peripherals.
|
|
| FRDM-K64 Click Shield |
mikroBUS expansion board used to connect Click modules to the FRDM platform.
|
|
| Servo Click |
PWM driver board used to control the servo motor position.
|
|
| POT Click |
Potentiometer module used to simulate steering wheel input.
|
|
| Micro Servo SG 180° | |
Actuator used to convert control signals into steering movement.
|
| USB-C / 12 V supply | — |
Provides power and enables programming and debugging of the system.
|
The example applications demonstrate how these peripherals are connected to the MCU pins and used to simulate steering wheel input and actuator control.
| Steering Control Monitoring on FRDM-A-S32K312 | Steering Control Monitoring on FRDM-A-S32K344 |
|---|---|
S32 Design Studio IDE
S32K3 Automotive Software Package
Application Code Hub project import
| Step | Action | Sub-steps | Expected Result |
|---|---|---|---|
| 1 | Import the Project |
|
Project successfully appears in workspace |
| 2 | Build the Application |
|
Build completes with no errors and generates .elf file |
| 3 | Connect Hardware |
|
Board is powered and detected by IDE |
| 4 | Flash and Run |
|
Application runs continuously |
| 5 | Functional Validation |
|
Servo follows potentiometer position in real time |
| Issue | Possible Actions |
|---|---|
| Board Not Detected |
|
| No Servo Movement |
|
| Incorrect Behavior |
|
| Unstable Movement |
|
The basic implementation can be extended in several ways:
Steering Range Control
Restrict or extend the actuator's range of motion
Define software-based limits to protect the mechanics
Input Direction Inversion
Reverse how the actuator responds to the input
Useful for left-hand vs. right-hand drive calibration
Noise Filtering
Apply software filtering to stabilize readings
Avoid jitter near the center position
Scaling Logic Exploration
Identify and analyze how the input is mapped to the output
Connect software math with hardware behavior
Fault-Handling Behavior
Add a mechanism that reacts to a detected fault
Transition the system into a safer state
State Machine Implementation A more advanced approach is to implement a state machine:
Idle
Active
Fault
This example reflects key automotive principles:
Continuous monitoring of driver input
Immediate response to control signals
Reliable actuator control
In real systems:
Redundancy is required
Fault detection mechanisms are implemented
Systems must comply with ISO 26262 (functional safety standard)
Steer-by-wire systems require high reliability since there is no direct mechanical link.
This module demonstrates how a simple embedded system can implement steering control using ADC input and PWM output.
It shows how:
Analog input is acquired
Data is processed in real time
Actuators are controlled using PWM
| Result on FRDM-A-S32K312 | Result on FRDM-A-S32K344 |
|---|---|
The course provides a strong foundation for more advanced systems, including filtering, state machines, and safety-oriented designs.