STM32 Gets Up Close And Personal With Mandelbrot

The Mandelbrot set is a curious mathematical oddity that, while interesting in its own right, is also a useful tool for benchmarking various types of computers. Its constant computing requirement when zooming in and out on the function, combined with the fact that it can be zoomed indefinitely, means that it takes some quality hardware and software to display it properly. [Thanassis] has made this a pet project of his, running Mandelbrot set visualizations in different ways on many different hardware platforms.

This particular one is based on an STM32 board called the Blue Pill, which [Thanassis] chose because he hadn’t yet done a continuous Mandelbrot zoom on a microcontroller yet. The display is handled by a tiny 16K IPS color screen, and some clever memory tricks had to come into play in order to get smooth video output since the STM has only 20 kB available. The integer multiplication is also tricky on a platform this small while keeping the continuous zoom function, so it’s limited to fixed point multiplication.

Even with the limitations of the platform, he is still able to achieve nearly double-digit FPS rates with this one. If you want to play around with graphics like this on an STM platform, [Thanassis] has released all of the source code on his GitHub page, but if you’d like to see more Mandelbrot manipulation you can check out one of his older projects where he built a similar project on an FPGA.

12 thoughts on “STM32 Gets Up Close And Personal With Mandelbrot

  1. Brings back not so fond memories of playing with the Mandelbrot set on a 16MHz (?) 486 with 640k (or maybe it was 1MB?) of memory back in the day. I’m sure he has a faster frame rate on the refreshes with this modern microcontroller setup! 😀

    1. Oh la de da. Hark at him with his 486!

      In our day, us had to make do with the Mandelbrot set on an 8Mhz 68000 with 512kb RAM on an Atari ST, with all of 16 colours on screen at one time, that is until clever people figured out how to extend this with palette switching on an H-sync in assembler.

      That is literally the first time I ran fractal software on any computer.

  2. Very interesting. The ingenuity of the software is impressive. I just ran across some photographs of the set from the screen of my IBM XT from the early 80’s. ( Yes, a screenshot back then required a camera and film. ) 8 lines of RM Fortran, and 10 lines of assembler to put the pixels on the screen. It still took more than 18 hours to generate one set on the 4 mhz 8088. Back then we picked a location on the set, and then iterated some math with imaginary numbers a few hundred times until we arbitrarily decided that the product was heading towards infinity and colored the pixel black. Otherwise we colored the pixel based on the interactions it took to get there.

    1. The article claims fixed point is used, which would be integer manipulation / multiplication, and it’s quite feasible to do mandelbrot with fixed point.

      If you want floating point, then go to the STM32F4xx series, which have built in floating point instructions and are still quite affordable. I’m quite curious what the mandelbrot performance of that would be.

  3. “nearly double digit”. Yeah sure. the abhorring marketing bullshit of which I thought / hoped Hackaday and it’s users would not ….

    First frame that is enough in focus for the text to be readable (@ 0:14) shows 9.6fps so technically correct.

    It did trigger a memory of a demo of “Big Buck Bunny” on a STM32, and after a bit of digging I found another video that pushes just over 10 frames/s full screen to a much bigger TFT, and higher framerates at lower (also full screen) resolution on: https://www.youtube.com/watch?v=7-NHFz5MuoQ

    cbm80amiga has more video’s related to TFT screens and microcontrollers (also with ESP8266) on his youtube channel. I have not looked if (links to) code are available, but it does show that the blue pill is quite capable of some usable video on such display’s. It’s got enough processing speed to use such displays for a gui.

Leave a Reply to paulvdhCancel reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.