Im currently making a costum 10x10 led matrix, and for it to be able to display senseable stuff, im trying to segment the display into 10 vertical lines which cycle at at least 100hz. Would a Python script on a raspberry pi be able to cycle its GPIO pins at this speed? Or Would an arduino or other Microcontroller be able to do it better?

  • RobotToaster@mander.xyz
    link
    fedilink
    arrow-up
    7
    arrow-down
    1
    ·
    3 days ago

    Short answer: It will probably work, since I assume you don’t need the timing to be reliable. It could start to glitch if the pi is under heavy load.

    Since you’re using python I’ll assume you’re using linux. Linux isn’t a real time operating system, so it is generally terrible at doing things like this. The issue is your program can be paused by the scheduler while the OS is doing something else, so any timing you request is not guaranteed. Now, a pi is ridiculously overpowered for this, so you’ll probably get away with it if that’s all the pi is doing, but under heavy load you could see the OS prioritise other processes and your display will freeze.

    You could install the preempt_rt patches to make it do real time better, this changes Linux into something that resembles a real time operating system, I don’t have any experience with it though.

    Generally something like this is better done by a microcontroller, because it isn’t constantly trying to juggle a hundred different tasks like an operating system is.

  • solrize@lemmy.ml
    link
    fedilink
    arrow-up
    5
    ·
    3 days ago

    This sounds kind of marginal to me, since you want the timing to be steady to stop the display from looking weird. You are better off with something like a Pi Pico and you will want to write the code in C (or similar) instead of Python. At that point 100 hz even on the main cpu is not a big deal. The Pico also has special i/o processors (PIOs) that can do this kind of thing more precisely even at MHz speeds, but they are limited and a pain to program.

    There is an Adafruit board to control LED Matrices from a Pi with hardware assistance if you want: https://www.adafruit.com/product/2345

    It says the current version works only on the pi 4, not the 5, for whatever reason. They are working on a pi 5 version.

  • golden_zealot@lemmy.ml
    link
    fedilink
    English
    arrow-up
    4
    ·
    edit-2
    3 days ago

    Like others said, the bottle neck will be the OS doing it’s thing with python rather than the hardware. Remember that you can perform pulse width modulation with the GPIO, so they can physically toggle states really very fast.

    I seem to recall that there is a GPIO header file for C available for the pi somewhere. If python proves too slow for what you want to do, you could look into writing something in C instead to try to speed things up potentially.

  • geneva_convenience@lemmy.ml
    link
    fedilink
    arrow-up
    2
    ·
    2 days ago

    RPI pico is probably a better choice. A rpi 5 can do stuff like WiFi servers and browsers but that’s not what you will do with it.

    • Luffy@lemmy.mlOP
      link
      fedilink
      arrow-up
      1
      ·
      2 days ago

      Thats what I was planning

      Tho, is it possible to connect a Pico w (with wifi) to my network and pull data from an API Server? Or do I have to somehow manually transfer that via some gpio Pins and an extra library?