1
\$\begingroup\$

I'd like to build a small novelty circuit that calculates the Mandelbrot set and displays it on an array of LEDs. The minimum floating point math would not necessarily require complex numbers (just calculate \$x\$ and \$y\$ separately) and the total number of individual calculations of \$z_{n+1}=z_n^2+c\$ would be under one million, so even something as slow as ten million FLOPS per hour would be OK in this case. At this level, it looks like 16 bit math is almost enough with clever programming, 32-bits is enough to make it work. Floats rather than ints would make life a heck of a lot easier, but not required.

I believe that a Raspberry Pi would be overkill as would a high-end Arduino, so an Uno, or a Basic Stamp II with its FP coprocessor perhaps.

That exhausts my knowledge of the possibilities, but there must be other options out there. How would you go about designing a small circuit to do this? What type of circuit would you use?

Background question, and the first ever published image of the Mandelbrot set (1978):

enter image description here

\$\endgroup\$
22
  • 2
    \$\begingroup\$ .. or Atmel even have it as an example program asf.atmel.com/docs/latest/uc3c/html/… \$\endgroup\$
    – pjc50
    Commented Jul 15, 2017 at 8:18
  • 2
    \$\begingroup\$ Just pointing out that every AVR chip (as far as I know, it's all, thanks to a library) can do division and FP(floating point) arithmetic (FPU), yet there's no assembler command for division, and there's no FPU to deal with the FP arithmetic. It's all done in software, there's no hardware solution for FP arithmetic on Arduinos. And I'm very certain that you can include a similar library for picXX or any other microcontroller. Check out this link \$\endgroup\$ Commented Jul 15, 2017 at 8:37
  • 2
    \$\begingroup\$ Hmmm, I'm not 100% sure if it will work with every tinyAVR, some only got 512B flash, it might be difficult to fit everything onto that. And sorry for asking this question, but why can't you just store the mandelbrot image in a lookup table? Or are you going to make some super duper mega slow animation zooming in forever? \$\endgroup\$ Commented Jul 15, 2017 at 8:46
  • 3
    \$\begingroup\$ You don't need to change the grid spacing if you use a lookup table. You would only need 35x75 bits => 35x80 bits => 35x10 bytes => a list of 350 bytes. But it doesn't matter ;) I assume that you've gotten all the answers you need ;) Also, I'm very very sure that a tinyAVR that got 2kB flash could fit the FPU library on it without any problems + your own code. As long as you use atmelstudio as your coding environment... The Arduino IDE injects so much weird crap onto the controllers... \$\endgroup\$ Commented Jul 15, 2017 at 8:57
  • 2
    \$\begingroup\$ Well I have gone through it again. I haven't found anything calling for a small micro to do your plots. But I shall admit I overlooked one very good reason to your point: It's a challenge I want do it with as little as can be done. In this I do agree with you. \$\endgroup\$
    – carloc
    Commented Jul 15, 2017 at 11:20

2 Answers 2

1
\$\begingroup\$

I think the moset obvious solution for your requirements is using a FPGA and writing HDL code that calculates \$z_{i+1} = z_i^2 + c\$.

\$\endgroup\$
1
  • \$\begingroup\$ A search for "smallest FPGA" certainly comes up with several very small ones. I wouldn't have even considered it, but ya, this is downright elegant! \$\endgroup\$
    – uhoh
    Commented Jul 15, 2017 at 8:56
1
\$\begingroup\$

Any Cortex M4F can easily do single-precision floating point math (ie. float, not double). Here is a summary how long each instruction takes.

Example: Kinetis MK02FN128 running at 100MHz can theoretically do 100 million floating point multiplications a second.

You would write code in C with floats as you would do on a PC. Some tips. Just look for microcontrollers with Cortex M4F core or "with FPU".

\$\endgroup\$
3
  • \$\begingroup\$ Thanks for the links!! What's the smallest option here? The speed is amazing, but I'm looking for "small". \$\endgroup\$
    – uhoh
    Commented Jul 15, 2017 at 9:35
  • 1
    \$\begingroup\$ There is a myriad of ARM MCUs to choose from.... some better-known families to look at: Kinetis, STM32, EFM32, Renesas Synergy, TM4C. You can even get a Bluetooth system on chip with FPU - nrf52 (in a module eg. BL652). \$\endgroup\$
    – filo
    Commented Jul 15, 2017 at 9:59
  • \$\begingroup\$ Do you mean "small" as in chip package size, or some other metric? The Kinetis is a whole 5mm x 5mm, and the really small packages can't be hand-assembled. \$\endgroup\$
    – pjc50
    Commented Jul 16, 2017 at 21:05

Not the answer you're looking for? Browse other questions tagged or ask your own question.