1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

SOLVED APA102 LED Responsiveness

Discussion in 'Software Support' started by Alpha7, 13 January 2021.

  1. Alpha7

    Alpha7 New Member

    Messages:
    16
    Hardware:
    RPi1/Zero
    So I hate to do this, but I've been messing with software settings for the past day or so and I can't get my LEDs to respond in sync with my TV. No matter what I've tried my LED's will also update about .2 seconds after the TV input changes and especially when scenes change it is noticeable that the LED's are lagging behind.

    One other important thing to mention is my PI never goes above ~50% total CPU utilization even when running the LEDs with some of the lower (better resolution, higher refresh) settings i've tried.

    Running a Pi Zero with ~300 APA102 LEDs via a HDMI to USB Video grabber that is getting split off my PS5 to my TV and to the grabber.

    I made some comments below in the code section about some changes I've made, from what i've googled and read around here and the most important things I think i've found is that smoothing is disabled (currently) or at a very low delay, I've messed with the baudrate, refresh rate of the grabber, resolution and Decimation a ton but the only setting that has any increase was lowering smoothing, disabling it doesn't increase it to a perfect, or near perfect synchronization to the TV.

    If there is anything I missed please let me know or anything more I can try. I removed some of the section below like "LEDs" to make the config smaller on here.

    Code:
    {
        "backgroundEffect": {
            "color": [
                255,
                138,
                0
            ],
            "effect": "Warm mood blobs",
            "enable": false,
            "type": "color"
        },
        "blackborderdetector": {
            "blurRemoveCnt": 1,
            "borderFrameCnt": 50,
            "enable": true,
            "maxInconsistentCnt": 10,
            "mode": "default",
            "threshold": 5,
            "unknownFrameCnt": 600
        },
        "boblightServer": {
            "enable": false,
            "port": 19333,
            "priority": 128
        },
        "color": {
            "channelAdjustment": [
                {
    ...
    ...
    ...
            "imageToLedMappingType": "multicolor_mean"
        },
        "device": {
            "colorOrder": "bgr",
            "hardwareLedCount": 1,
            "invert": false,
            "latchTime": 0,                                ## no clue what this does, Not modified it.
            "output": "/dev/spidev0.0",
            "rate": 3000000,                            ## I've seen this set as low as 50,000 and as high as 40,000,000
            "rewriteTime": 10,                            ## default this is 200 I think? changing it doesn't seem to increase LED responsivness though
            "type": "apa102"
        },
        "effects": {
            "disable": [
                ""
            ],
            "paths": [
                "$ROOT/custom-effects"
            ]
        },
        "flatbufServer": {
            "enable": true,
            "port": 19400,
            "timeout": 5
        },
        "foregroundEffect": {
            "color": [
                0,
                0,
                255
            ],
            "duration_ms": 3000,
            "effect": "Rainbow swirl fast",
            "enable": false,
            "type": "color"
        },
        "forwarder": {
            "enable": false,
            "flat": [
                "127.0.0.1:19401"
            ],
            "json": [
                "127.0.0.1:19446"
            ]
        },
        "framegrabber": {
            "cropBottom": 0,
            "cropLeft": 0,
            "cropRight": 0,
            "cropTop": 0,
            "display": 0,
            "frequency_Hz": 10,
            "height": 45,
            "pixelDecimation": 8,
            "type": "auto",
            "width": 80
        },
        "general": {
            "name": "My Hyperion Configv2",
            "showOptHelp": true,
            "watchedVersionBranch": "Stable"
        },
        "grabberV4L2": {                            #messed with resolution, resolution and FPS a ton nothing seems to increase LED responsiveness
            "available_devices": "/dev/video0",
            "blueSignalThreshold": 5,
            "cecDetection": false,
            "cropBottom": 10,
            "cropLeft": 10,
            "cropRight": 10,
            "cropTop": 10,
            "device": "/dev/video0",
            "device_inputs": "auto",
            "fps": 30,
            "framerates": "30",
            "greenSignalThreshold": 5,
            "height": 648,
            "input": -1,
            "redSignalThreshold": 5,
            "resolutions": "custom",
            "sDHOffsetMax": 0.75,
            "sDHOffsetMin": 0.25,
            "sDVOffsetMax": 0.75,
            "sDVOffsetMin": 0.25,
            "signalDetection": false,
            "sizeDecimation": 18,
            "standard": "NTSC",
            "width": 1152
        },
        "instCapture": {
            "systemEnable": false,
            "systemPriority": 250,
            "v4lEnable": true,
            "v4lPriority": 240
        },
        "jsonServer": {
            "port": 19444
        },
        "ledConfig": {
            "classic": {
    ...
    ...
    ...
            },
            "matrix": {
                "cabling": "snake",
                "ledshoriz": 1,
                "ledsvert": 1,
                "start": "top-left"
            }
        },
        "leds": [
            ...
            ...
            ...
            ...
        "logger": {
            "level": "warn"
        },
        "network": {
            "apiAuth": true,
            "internetAccessAPI": false,
            "ipWhitelist": [],
            "localAdminAuth": true,
            "localApiAuth": false,
            "restirctedInternetAccessAPI": false
        },
        "protoServer": {                            ## Don't think i've seen this setting in the actual web config, not sure what it is or why its enabled
            "enable": true,
            "port": 19445,
            "timeout": 5
        },
        "smoothing": {                                ## Tried enabled or disabled, speeds up responsiveness of the LEDs if at a very low number but disabling doesn't make it perfect
            "continuousOutput": true,
            "decay": 1,
            "dithering": true,
            "enable": false,
            "interpolationRate": 60,
            "outputRate": 60,
            "time_ms": 25,
            "type": "linear",
            "updateDelay": 0,
            "updateFrequency": 60
        },
    }
    
    
     
  2. TPmodding

    TPmodding Administrator Staff Member Administrator

    Messages:
    2,132
    Hardware:
    RPi1/Zero, RPi2, RPi3, +Arduino, +WLED, RPi4
    do you know which resolutions your grabber can? can see it with "v42l-ctl --all"
     
  3. Alpha7

    Alpha7 New Member

    Messages:
    16
    Hardware:
    RPi1/Zero
    I wasn't able to get that command to work but my HDMI splitter outputs 4k or 1080, I currently have it downscaling my input to 1080 to the PI. I currently, manually have the resolution on the grabber set to 128x72 resolution and that has improved things a little more but still more of a delay than I would like. Also having the resolution so low it can't see smaller things around the edges.
     
  4. Alpha7

    Alpha7 New Member

    Messages:
    16
    Hardware:
    RPi1/Zero
    I took a video, with 127x72 at 3 Decimation Is about as near perfect as I can seem to get it.. but at this point I've got more LEDs behind my TV then pixles the PI is actually reading.

    There has to be some setting or something I am missing right? With a ton of action its not very noticeable but on the hard scene change you can definitely see the LEDs are lagging enough to be noticeable - I just recorded on my phone so the quality isn't perfect.

     
  5. TPmodding

    TPmodding Administrator Staff Member Administrator

    Messages:
    2,132
    Hardware:
    RPi1/Zero, RPi2, RPi3, +Arduino, +WLED, RPi4
    try it without decimation: 1
     
  6. Alpha7

    Alpha7 New Member

    Messages:
    16
    Hardware:
    RPi1/Zero
    Setting it back to 1 increases the lag quite a bit. It definitely doesn't decrease the lag or help in any way.
     
  7. jeroen warmerdam

    jeroen warmerdam Raspberry 3B / APA102 / Hyperion.NG relaisbox

    Messages:
    619
    Hardware:
    RPi3
    Have you tried to increase the arm in config.txt?

    You can manually change the boost and arm of cpu.
    Looks like your PI is a little short of some cpu power.
     
  8. Alpha7

    Alpha7 New Member

    Messages:
    16
    Hardware:
    RPi1/Zero
    I boosted it at one point but reconfigured since then and forgot to overclock it again. After overclocking again it seem a little better, more so now that I can't say I even notice unless I'm standing there trying to notice the difference.


    Here are the settings I ended up on, and its been stable for a couple days now like this:

    arm_freq=1095
    gpu_freq=550
    over_voltage=2
    core_freq=515
    sdram_freq=533
    over_voltage_sdram=1

    I am running heatsink not that I can imagine it really getting too hot without one just running hyperion.

    Device Resolution: 256x144 @60fps, 8 decimation for games, 2 for Movies

    I also realized something, I have my TV in game mode as the purpose of this project was to use with my ps5 and primarily Destiny 2. With these settings, the low capture resolution and 8 decimation allows things to look near perfect while gaming without smoothing. If I turn the TV into HDR or Movie mode (which causes a delay with the TV processing and adjusting the output it lags just enough to where the LEDs appear to respond perfectly with smoothing enabled)

    If I was only doing this for movies/TV I would have been done screwing with things weeks ago. Too bad games look fantastic with the LEDs as well.

    I'm sure the capture device is the largest culprit of lag here. I noticed lag when I hooked it up to my gaming PC as well, i'm not sure if the $200 Elgato devices can be essentially played on with 0 latency but the cheap $20 one I got definitely cannot be, and this is fine for this as its close enough at this point I think to not bother me.
     
  9. davieboy

    davieboy Active Member

    Messages:
    242
    Hardware:
    RPi1/Zero, RPi2, RPi3, RPi4
    totally get where your coming from on the USB grabber, they are either dirt cheap or expensive and the ones in the middle are questionable to whether they are just a diff case and overpriced :LOL:

    I noticed major lag yesterday on mine after setting it up to TV again, only way for me to resolve it was to reduce the video capture down to 1280x720p and its near perfect, 1080 would be better so it matches screen 100% but its only slightly larger but bearable for the cost of a good device.

    With you having to overclock the Zero to notice a difference - Surely The Zero is one of the biggest culprits, Single Core CPU, 512mb ram - Is that enough hardware to efficiently handle the video capture plus the operating system and that's the reason you are at 256x144px?

    Never had one or tried one but id of thought that it would run a headless or lightweight distro with not much resources left for other things or have i missed out for all these years? :roflmao:

    Youd think the card would handle something higher or at very least 640x480 - try as @TPmodding suggested and run
    Code:
    v4l2-ctl --list-formats-ext
    
     
  10. jeroen warmerdam

    jeroen warmerdam Raspberry 3B / APA102 / Hyperion.NG relaisbox

    Messages:
    619
    Hardware:
    RPi3
    tip:
    increase baudrate speed to 1500000 ( or higher) helps also in a faster SPI bus, thus faster respons less lag from the ledstrip
    led hardware> led controller settings
     
  11. jeroen warmerdam

    jeroen warmerdam Raspberry 3B / APA102 / Hyperion.NG relaisbox

    Messages:
    619
    Hardware:
    RPi3

    i agree completely with Davieboy,

    the hardware seems not be capable fully to the challenge of lighting 300 leds on SPI bus fluently and grabber the same time..
    maybe upgrade to a PI3 or 4 is the better choice here, instead of overclocking CPU which doesnt have really much calculating power to begin with.
    (its the same example than putting a Porsche engine in a volkswagen Beetle, its not a race car over night with that modification :LOL::roflmao:)

    i am running a overclocked and boosted PI3b, when i set size decimation to lower than 4 ( when every setting is highest as possible in Hyperion)
    then i can see a noticable difference in reacting of the leds, rendered image to Hyperion is getting behind.. .

    that means that CPU/GPU is at the top of rendering the image to Hyperion.
    So even with my well balanced setup on the PI3b there is a top setting that can't be topped.

    with other words, you are missing some power in CPU.
    i don't think you can solve this problem only with settings in config.txt and Hyperion or a different grabber for that matter.
     
    Last edited: 3 February 2021
  12. jeroen warmerdam

    jeroen warmerdam Raspberry 3B / APA102 / Hyperion.NG relaisbox

    Messages:
    619
    Hardware:
    RPi3

    this. i second this. :rolleyes:
     
  13. davieboy

    davieboy Active Member

    Messages:
    242
    Hardware:
    RPi1/Zero, RPi2, RPi3, RPi4
    I'd also like to agree to your first reply, paragraph 2 :roflmao::LOL:

    It probably could handle the LED's perfectly but struggling with both, It reminds me of the encoding/burning DVD days, the better the spec the faster it took, maybe slimming down your o/s may help you get a slightly higher resolution but its a big jump from what your currently getting to what you ideally want, esp if your running the PS5 at full 4k you'd want to get it a bit higher.

    As @jeroen warmerdam suggested a Pi3B or Pi4 would be a massive increase and are around the same price, Pi3A had the older quad core and 512mb ram so for the extra £10 the Pi4 would be the better option as you get more hardware for the cash.

    Good Luck
     
  14. Alpha7

    Alpha7 New Member

    Messages:
    16
    Hardware:
    RPi1/Zero
    I mainly just got the Zero because it was cheap and I had no idea how far the project would actually get. Now that I know I like it I might upgrade but in all honestly I've yet to have any issues with colors. I mean I have 100 LED's and have the resolution over 100, so technically that would be enough to still be accurate right?