Motor Diagnostics is a MISRA-inspired embedded C project that simulates an automotive or industrial motor diagnostics ECU on a normal laptop. It monitors deterministic sensor samples, debounces noisy readings, detects persistent faults, advances a safety-oriented state machine, and records fault events in a fixed-size circular log.
This project is useful for practicing embedded C techniques without hardware: clear module boundaries, fixed-width integer types, no dynamic memory allocation, defensive checks, bounded buffers, explicit states, and simple testable logic.
Motor_Diagnostics/
├── README.md
├── Makefile
├── include/
│ ├── motor_sensor.h
│ ├── fault_supervisor.h
│ ├── system_state.h
│ └── fault_log.h
├── src/
│ ├── main.c
│ ├── motor_sensor.c
│ ├── fault_supervisor.c
│ ├── system_state.c
│ └── fault_log.c
├── tests/
│ ├── test_fault_supervisor.c
│ ├── test_system_state.c
│ └── test_fault_log.c
└── docs/
├── design.md
└── misra_notes.md
Install a C99 compiler and make. On Windows, MSYS2/MinGW, WSL, or another
GNU-compatible toolchain works well.
makemake runThe tests are simple host-side C programs that use assert().
make testSample Volt(mV) Temp(C) Current(mA) RPM Heartbeat Fault State Log
1 12000 45 4000 1500 1 FAULT_NONE SYSTEM_NORMAL 0
8 9000 45 4000 1500 8 FAULT_UNDER_VOLTAGE SYSTEM_WARNING 1
15 12000 110 4000 1500 15 FAULT_OVER_TEMPERATURE SYSTEM_SAFE_MODE 3
23 12000 45 36000 1500 23 FAULT_OVER_CURRENT SYSTEM_SAFE_MODE 5
Use normal Git commands only:
git init
git branch -M main
git add .
git commit -m "Initial MISRA-style motor diagnostics project"
git remote -v
git remote remove origin
git remote add origin https://github.com/agmankaruse/Motor_Diagnostics.git
git push -u origin mainIf origin does not exist, skip git remote remove origin and add the remote.