# STM32 Performance Slowing down over time

**URL:** <https://forum.arduino.cc/t/stm32-performance-slowing-down-over-time/1005525>\
**Category:** 3rd Party Boards\
**Created:** [June 22, 2022, 2:37pm UTC](https://forum.arduino.cc/t/stm32-performance-slowing-down-over-time/1005525 "2022-06-22T14:37:18Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![jadhelou10](https://avatars.discourse-cdn.com/v4/letter/j/6a8cbe/32.png) [@jadhelou10](https://forum.arduino.cc/u/jadhelou10)\
**Post date:** [June 22, 2022, 2:37pm UTC](https://forum.arduino.cc/t/stm32-performance-slowing-down-over-time/1005525/1 "2022-06-22T14:37:18Z")

</div>

Hello all!

I am running a differential drive robot using an STM32 chip soldered on a customized PCB. The STM controls an array of Infra Red Sensors for line following and 2 DC Motors with encoders.

After around 2-3 hours of operation, the robot starts to have some delays in following the line and stopping. I am seeing a slower processing of the encoders and IR sensors over time which results in a huge delay in sending the commands.

I tried decreasing the speed by 50%, and the robot operated for a longer period of time.  
Any idea what might be the problem for this decrease in performance over time?

---

<div class="post-metadata">

**Author:** ![anon94801460](https://avatars.discourse-cdn.com/v4/letter/a/278dde/32.png) [@anon94801460](https://forum.arduino.cc/u/anon94801460)\
**Post date:** [June 22, 2022, 3:05pm UTC](https://forum.arduino.cc/t/stm32-performance-slowing-down-over-time/1005525/2 "2022-06-22T15:05:48Z")

</div>

Battery running down.

---

<div class="post-metadata">

**Author:** ![jadhelou10](https://avatars.discourse-cdn.com/v4/letter/j/6a8cbe/32.png) [@jadhelou10](https://forum.arduino.cc/u/jadhelou10)\
**Post date:** [June 22, 2022, 3:13pm UTC](https://forum.arduino.cc/t/stm32-performance-slowing-down-over-time/1005525/3 "2022-06-22T15:13:22Z")

</div>

I am tracking the battery and no problem with the voltage. Any other causes?

---

<div class="post-metadata">

**Author:** ![srnet](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/srnet/32/238868_2.png) [@srnet](https://forum.arduino.cc/u/srnet)\
**Post date:** [June 22, 2022, 3:17pm UTC](https://forum.arduino.cc/t/stm32-performance-slowing-down-over-time/1005525/4 "2022-06-22T15:17:48Z")

</div>

So once its slowed down, after 2-3 hours running, is it still slow running after you do a complete powerdown and restart ?

---

<div class="post-metadata">

**Author:** ![anon57585045](https://avatars.discourse-cdn.com/v4/letter/a/ed8c4c/32.png) [@anon57585045](https://forum.arduino.cc/u/anon57585045)\
**Post date:** [June 22, 2022, 3:20pm UTC](https://forum.arduino.cc/t/stm32-performance-slowing-down-over-time/1005525/5 "2022-06-22T15:20:22Z")

</div>

Please post technical information that might help us solve your problem.

---

<div class="post-metadata">

**Author:** ![jadhelou10](https://avatars.discourse-cdn.com/v4/letter/j/6a8cbe/32.png) [@jadhelou10](https://forum.arduino.cc/u/jadhelou10)\
**Post date:** [June 22, 2022, 3:25pm UTC](https://forum.arduino.cc/t/stm32-performance-slowing-down-over-time/1005525/6 "2022-06-22T15:25:52Z")

</div>

After restarting the robot it starts driving normally again.

---

<div class="post-metadata">

**Author:** ![jadhelou10](https://avatars.discourse-cdn.com/v4/letter/j/6a8cbe/32.png) [@jadhelou10](https://forum.arduino.cc/u/jadhelou10)\
**Post date:** [June 22, 2022, 3:27pm UTC](https://forum.arduino.cc/t/stm32-performance-slowing-down-over-time/1005525/7 "2022-06-22T15:27:36Z")

</div>

The only thing I tried is after decreasing the speed by 50%, I ran the robot for 40 hours until I stopped it. I had no problem during this 40 hours.

---

<div class="post-metadata">

**Author:** ![anon57585045](https://avatars.discourse-cdn.com/v4/letter/a/ed8c4c/32.png) [@anon57585045](https://forum.arduino.cc/u/anon57585045)\
**Post date:** [June 22, 2022, 3:29pm UTC](https://forum.arduino.cc/t/stm32-performance-slowing-down-over-time/1005525/8 "2022-06-22T15:29:13Z")

</div>

I asked for technical information about your project. I think I'll take the rest of the day off.

---

<div class="post-metadata">

**Author:** ![jadhelou10](https://avatars.discourse-cdn.com/v4/letter/j/6a8cbe/32.png) [@jadhelou10](https://forum.arduino.cc/u/jadhelou10)\
**Post date:** [June 22, 2022, 3:35pm UTC](https://forum.arduino.cc/t/stm32-performance-slowing-down-over-time/1005525/9 "2022-06-22T15:35:55Z")

</div>

Can you please specify what exactly do you need to know? (Hardware, software...)

---

<div class="post-metadata">

**Author:** ![anon94801460](https://avatars.discourse-cdn.com/v4/letter/a/278dde/32.png) [@anon94801460](https://forum.arduino.cc/u/anon94801460)\
**Post date:** [June 22, 2022, 3:59pm UTC](https://forum.arduino.cc/t/stm32-performance-slowing-down-over-time/1005525/10 "2022-06-22T15:59:01Z")

</div>

Please read and follow the instructions in the "How to get the best out of the forum" post, linked at the head of every forum category.

---

<div class="post-metadata">

**Author:** ![anon57585045](https://avatars.discourse-cdn.com/v4/letter/a/ed8c4c/32.png) [@anon57585045](https://forum.arduino.cc/u/anon57585045)\
**Post date:** [June 22, 2022, 5:00pm UTC](https://forum.arduino.cc/t/stm32-performance-slowing-down-over-time/1005525/11 "2022-06-22T17:00:14Z")

</div>

> [@jadhelou10](#):
>
> Can you please specify what exactly do you need to know? (Hardware, software...)

A great way to think about this - imagine that you are presented with this problem in a short forum post. What would **you** need to know, to solve it?

---

<div class="post-metadata">

**Author:** ![srnet](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/srnet/32/238868_2.png) [@srnet](https://forum.arduino.cc/u/srnet)\
**Post date:** [June 22, 2022, 5:20pm UTC](https://forum.arduino.cc/t/stm32-performance-slowing-down-over-time/1005525/12 "2022-06-22T17:20:39Z")

</div>

> [@jadhelou10](#):
>
> After restarting the robot it starts driving normally again.

You _ **might** _ have a code problem.

But you have revealed almost zero details of your project, and not when or how the problems developed, so thats only a guess.

(Hint)

---

<div class="post-metadata">

**Author:** ![anon57585045](https://avatars.discourse-cdn.com/v4/letter/a/ed8c4c/32.png) [@anon57585045](https://forum.arduino.cc/u/anon57585045)\
**Post date:** [June 22, 2022, 5:45pm UTC](https://forum.arduino.cc/t/stm32-performance-slowing-down-over-time/1005525/13 "2022-06-22T17:45:12Z")

</div>

STM makes about 100 STM32's too... which one?

---

<div class="post-metadata">

**Author:** ![jadhelou10](https://avatars.discourse-cdn.com/v4/letter/j/6a8cbe/32.png) [@jadhelou10](https://forum.arduino.cc/u/jadhelou10)\
**Post date:** [June 28, 2022, 9:59am UTC](https://forum.arduino.cc/t/stm32-performance-slowing-down-over-time/1005525/14 "2022-06-28T09:59:25Z")

</div>

@anon57585045 @srnet @anon94801460  
The robot uses an STM32F103ZCT6 that takes care of:

2 DC Motors being handled by a controller. The STM reads the encoders from the controller which are correct and reliable values as per the testing has shown.

2 IR sensors array (polulu 15 IR Sensor array) of 15 sensors each. The STM read the values of the IR and controls the speed of the motors accordingly to keep the robot following the line. It is using the built in function from the Polulu sensor.

The robot uses the IR Sensors to stop at the right position (i check how many sensors read the line since at the stopping the line is wider). Now in case the sensor messed up, the encoders will detect it since it moved more or less than it should and the bot will be able to move to the right position again.

The issue I am facing is that after a certain time (mostly in 2 hours but its decreasing after more tests) the robot messes up the stopping position (it keeps driving) and the encoders takes time to start recovering. Even after the recovering the sensor doesn't see the line anymore. As if nothing is working.

I tried decreasing the speed by 50% and the issue did not happen anymore for more than 2 days of running the bot. And from the looks of it, it seems like everything is delayed, this is why i suspect that it could be the STM slowing down after a certain time.

How can I debug this? Check memory usage over time for example?

---

<div class="post-metadata">

**Author:** ![anon57585045](https://avatars.discourse-cdn.com/v4/letter/a/ed8c4c/32.png) [@anon57585045](https://forum.arduino.cc/u/anon57585045)\
**Post date:** [June 28, 2022, 11:17am UTC](https://forum.arduino.cc/t/stm32-performance-slowing-down-over-time/1005525/15 "2022-06-28T11:17:29Z")

</div>

> [@jadhelou10](#):
>
> How can I debug this?

So many ways. One is just spotting it in the code. Another, serial debug statements. Is anything on the processor board getting hot? Did you read the guide as suggested in reply #10?

---

<div class="post-metadata">

**Author:** ![mrburnette](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/mrburnette/32/702556_2.png) [@mrburnette](https://forum.arduino.cc/u/mrburnette)\
**Post date:** [June 28, 2022, 1:20pm UTC](https://forum.arduino.cc/t/stm32-performance-slowing-down-over-time/1005525/16 "2022-06-28T13:20:38Z")

</div>

> [@jadhelou10](#):
>
> the robot messes up the stopping position (it keeps driving) and the encoders takes time to start recovering. Even after the recovering the sensor doesn't see the line anymore. As if nothing is working.

I really dislike guessing, but with no details on circuitry and no software listing; my suspicions are that you are drawing to much output current and "something" is heating up causing the uC to become erratic or simply shutdown.

In my shop, I would bring out the IR thermal camera; but, then again, I tend to do a rather detailed analysis of power parameters during the prototyping stage of designs. You can always use your finger to probe the temperature of the various components 😬

(SERIOUSLY please **do not** actually use your finger ... you could suffer a severe burn.)

You could try measuring the total current being drawn if you have a decent DVM with a high-current DC section.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [December 25, 2022, 1:21pm UTC](https://forum.arduino.cc/t/stm32-performance-slowing-down-over-time/1005525/17 "2022-12-25T13:21:39Z")

</div>

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
