Debugging an Autonomous Underwater Vehicle with Tracealyzer

Oct 15, 2026 |

By Max Johansson, Vehicular Systems, Linköping University 

An AUV shown for illustration. Photo by Swedish Maritime Robotics Centre (SMaRC).

An AUV shown for illustration. Photo by Swedish Maritime Robotics Centre (SMaRC).

At KTH, the Swedish Maritime Robotics Centre (SMaRC) is continuously developing an autonomous underwater vehicle (AUV) as a research platform for studying underwater environments. The AUV has traditionally been powered by batteries, but adding a fuel cell can extend its operating range. We at the Vehicular Systems Division of Linköping University were invited to contribute to the project by developing the fuel-cell control system. 

The type of fuel cell used in this project produces energy by converting hydrogen and oxygen gas into electricity and water. Unlike a battery, which carries its reactants internally, a fuel cell must be supplied with hydrogen and oxygen from an external source. The reactants must be delivered at sufficient rates and pressures to ensure high performance, while the humidity and temperature of the device must also be maintained. 

This task is handled by what is typically called the balance-of-plant (BOP) system, which consists of the pipes, pumps, valves, and other actuators required to operate the fuel cell efficiently. Our task was to design the electronic control unit for this system. The figure below shows some of the necessary components in a BOP system. 

It was quickly decided that a real-time operating system (RTOS) would be a good choice for this kind of application because it allowed us to separate the different tasks the control unit needed to perform. These included reading sensor data, receiving communication from other systems on the vehicle, computing control updates, writing data to actuators, and more. A major feature of an RTOS is that each task (or thread) can be developed independently. A downside, however, is that concurrency can make timing and synchronization issues harder to debug.

This is where Tracealyzer became an indispensable tool. By recording and displaying the concurrency of the program, we were able to debug issues that would otherwise have been difficult to identify.

One of these issues involved the data-reading task. We programmed a dedicated task to handle communication between the microcontroller and our analog-to-digital converter (ADC), the component that reads data from our sensors.

We used an ADC equipped with 14 channels. It samples the channels sequentially, looping through them continuously. In simplified form, our intended program flow was:

  1. Wait until the ADC has data to convert, indicated by a hardware interrupt.
  2. Transmit a read-data command to the ADC.
  3. Store the data in an array at element n.
  4. Set n = n + 1 and return to step 1.

Because multiple tasks interact with the data, we protected the shared data with a semaphore. However, we made an error in where we acquired the semaphore. By requesting the semaphore before step 2, we blocked the main control task while the ADC conversion and communication were taking place. This meant the main control task could not proceed even though it did not need access to the shared data during that part of the operation.

Tracealyzer made the problem visible by showing the timing and concurrency of the tasks. In the figure below, the main control task (red) is blocked by the ADC task (green) for an extended period. Seeing the interaction in the trace made it clear that the semaphore was being held for longer than necessary.

Want to See What Your Software Is Doing at Runtime?

Explore Percepio Detect and Tracealyzer to see how continuous observability and visual trace diagnostics can help you detect problems earlier, understand what happened and get to the root cause faster.

Start an evaluation of Percepio Detect and Tracealyzer. 

Stay Ahead of What’s Changing in Embedded Software

Get monthly insights from Percepio on embedded software development, observability, debugging, industry trends and the issues shaping engineering teams.

Subscribe to the Percepio newsletter!


Percepio offers Tracealyzer licenses to qualifying academic institutions and students. Please visit the Licensing page to review the terms and apply for an academic license.