August - November 2026
Embedded Ping Pong Game
TTK4155 Industrial and Embedded Computer Systems Design, NTNU
In the course TTK4155 at the Norwegian University of Science and Technology (NTNU), I built a distributed, computer-controlled electromechanical ping pong game in a group of three. Over the semester we assembled the hardware on a breadboard and wrote the software for two microcontroller nodes – an 8-bit AVR and a 32-bit ARM Cortex-M3 – that communicate over a CAN bus. The player steers the racket with a joystick, a solenoid hits the ball, and an infrared beam detects when a goal is scored.
System Architecture
Node 1 – User Interface
- ATmega162 microcontroller assembled on a breadboard
- External SRAM and MAX156 ADC on a memory-mapped parallel bus
- Address decoding with NAND gates and an address latch
- Joystick, touch slider and buttons on the User-I/O board
- 128×64 OLED display driven over SPI
- MCP2515 CAN controller and RS-232 link to the PC
Node 2 – Game Board Control
- Arduino Due with an ATSAM3X8E (ARM Cortex-M3)
- Motor shield with A3959 motor driver and CAN transceiver
- PWM-controlled servo for the racket angle
- DC motor with quadrature encoder for the racket position
- Relay-driven solenoid that hits the ball
- IR beam with op-amp signal conditioning for goal detection
Project Milestones
Building Node 1
- Microcontroller assembly and UART driver over RS-232
- Address decoding and external RAM
- A/D conversion and joystick input
- OLED display, SPI driver and menu system
- CAN controller driver, tested in loopback mode
Integrating Node 2
- CAN communication between Node 1 and Node 2
- Servo control and IR-based goal detection
- Motor control with encoder feedback
- Closed-loop position controller for the racket
- Solenoid triggering from the joystick button
Engineering Approach
Layered Drivers
The software is organized into small driver modules with clear interfaces. CAN communication, for example, is split into a hardware-independent messaging layer, a driver for the MCP2515 CAN controller and a low-level SPI driver underneath, so the same SPI driver also serves the OLED display and the I/O board.
Hardware Debugging
Building the circuits by hand meant dealing with electrical noise, decoupling, star-point grounding and level shifting between 5 V and 3.3 V logic. Oscilloscopes, multimeters and on-chip JTAG debugging were essential for verifying bus timing and signals at every step.
Key Concepts
- Memory-mapped I/O and partial address decoding
- Polling versus interrupt-driven designs
- SPI bus sharing between multiple slave devices
- CAN bit timing and message arbitration
- PWM generation for servo and motor control
- Discrete PI control with a fixed sampling period from a timer interrupt