CAN Bus · Embedded C · ADC · GPIO

Developing a CAN-Based ECU for Automotive Virtual Cockpit Control Using Embedded C

Category: Automotive Software Engineering
Project Type: Academic Engineering Project
Technologies: Embedded C, CAN Bus, ADC, GPIO, PIT Timer
Institution: Technische Universität Chemnitz, Germany

1. Introduction

Modern vehicles use Electronic Control Units (ECUs) to monitor vehicle parameters and exchange information between different electronic systems.

The Controller Area Network (CAN) bus is an important communication protocol in automotive systems. It enables multiple ECUs to exchange information reliably.

As part of my M.Sc. Automotive Software Engineering studies at Technische Universität Chemnitz, I worked on a CAN-based ECU development project using Embedded C.

The project focuses on CAN message transmission and reception, vehicle speed processing, engine RPM data handling, indicator control, and Virtual Cockpit communication.

2. Project Objectives

The main objectives of this project were:

  • Develop a CAN-based embedded ECU using C programming.

  • Implement CAN message transmission and reception.

  • Understand CAN message buffers and filtering.

  • Read analog signals using ADC.

  • Convert potentiometer values into vehicle speed.

  • Process engine RPM information.

  • Control indicator lights using GPIO.

  • Implement timer-based operations using PIT.

  • Manage ECU operating states using a state machine.

  • Explore vehicle data communication with a Virtual Cockpit interface.

Automotive virtual cockpit digital instrument cluster

3. System Overview

The ECU processes driver inputs and vehicle-related signals before preparing CAN messages for the Virtual Cockpit interface.

The main functional modules include:

CAN Communication Module

Handles CAN message transmission, reception, message buffers, and receive callbacks.

ADC Module

Reads analog input from a potentiometer and converts the ADC values into vehicle speed.

GPIO Module

Handles digital input signals and indicator LED control.

PIT Timer Module

Manages periodic interrupts, CAN transmission timing, and indicator blinking operations.

ECU State Management

Controls ECU operating states, including IDLE and ENGINE_ON, based on received CAN messages.

System Architecture
CAN bus communication architecture in automotive ECU

4. CAN Bus Communication

CAN communication is one of the main components of this project.

The implementation supports:

  • CAN message transmission (Tx).

  • CAN message reception (Rx).

  • CAN message buffer handling.

  • Standard Identifier (SID) filtering.

  • Receive callback implementation.

  • Vehicle-related signal communication.

 CAN Message Handling

The current implementation uses the following CAN identifiers for ECU state management:

CAN IDFunction
0x11Switch ECU from IDLE to ENGINE_ON
0x10Switch ECU from ENGINE_ON to IDLE

The application also prepares CAN messages containing engine status, vehicle speed, RPM, and indicator light information.

5. Vehicle Speed Processing Using ADC

The project uses a potentiometer as an analog input source.

The ADC module reads the potentiometer value and converts the input into a vehicle speed value.

Input range: 0–4095

Vehicle speed range: 0–240 km/h

This demonstrates how analog input signals can be processed and represented as vehicle-related parameters in an embedded ECU.

6. Engine RPM Processing

The project includes RPM value generation and CAN data transmission.

The RPM information is prepared for CAN communication using separate low and high data bytes.

This demonstrates basic vehicle signal processing and data handling in automotive embedded applications.

ADC potentiometer input processing in embedded ECU

7. Indicator and GPIO Control

The GPIO module handles digital switch inputs and indicator LED outputs.

Key functions include:

  • Reading left and right indicator switch inputs.

  • Controlling indicator LEDs.

  • Processing indicator status.

  • Transmitting indicator information through CAN messages.

8. Timer-Based Operations

The Periodic Interrupt Timer (PIT) is used for time-dependent operations.

The implementation explores:

  • Periodic timer interrupts.

  • Timer callback functions.

  • Periodic CAN transmission.

  • Indicator blinking control.

These operations demonstrate the importance of timer-based execution in embedded ECU development.

9. Software Architecture

The application is organized into modular C source and header files.

ModuleResponsibility
main.cMain application and ECU state management
can.c / can.hCAN communication
adc.c / adc.hAnalog input processing
pit.c / pit.hTimer configuration and callbacks
siu.c / siu.hGPIO and system integration
init.c / init.hPeripheral initialization

This modular structure improves code organization and makes individual ECU functions easier to understand and maintain.

10. Development Technologies

TechnologyApplication
Embedded CECU software development
CAN BusAutomotive communication
ADCAnalog sensor input processing
GPIODigital input and output control
PITPeriodic timer operations
ECU State MachineOperating state management
Virtual CockpitVehicle data visualization concept

11. Skills and Learning Outcomes

Through this academic project, I explored:

  • Automotive CAN communication.

  • Embedded C programming.

  • ECU software architecture.

  • CAN transmission and reception.

  • CAN message filtering.

  • ADC-based sensor processing.

  • GPIO peripheral control.

  • Timer interrupts and callbacks.

  • ECU state machine implementation.

  • Vehicle speed and RPM data processing.

This project strengthened my understanding of automotive communication and embedded software development.

purposes. The implementation is not certified or validated for production vehicle use.

Automotive embedded ECU development hardware

12. Source Code and Documentation

The complete source code and supporting technical documents are available in my GitHub repository.

GitHub Repository:

https://github.com/obydur/CAN-Based-ECU-Virtual-Cockpit

The repository includes C source files, header files, CAN communication documentation, ADC, GPIO and PIT-related technical documents.

13. Conclusion

Developing a CAN-based ECU provided practical exposure to automotive communication and embedded software concepts.

By working with CAN message handling, ADC input processing, GPIO control, timer-based operations, and ECU state management, I gained a deeper understanding of how automotive embedded systems exchange and process vehicle-related information.

I am continuing to develop my expertise in Embedded C, CAN communication, AUTOSAR, ECU development, and automotive software engineering.

Author: Obydur Rahman
M.Sc. Automotive Software Engineering
Technische Universität Chemnitz, Germany


Disclaimer: This is an academic engineering project developed for educational

Have questions about the project?

Have questions about this project or want to discuss a similar idea? I’d be happy to connect and explore how we can work together.

Toggle Dark Mode