[LumiDrive+ LuMini Ring(40xA{A102-2060)] Need to Switch the LED On/Off at 1ms or slower

Hi,

I have a pretty simple project but for some reason feel struggle to get it to work right.

My goal: switching RGB LEDs on and off every 1ms or faster.

Hardware: LumiDrive + LuMini Ring (40 of APA102-2020)

Problem: the ring doesn’t switch fast enough using the pre-defined function color_fill. I wonder if the function or the LuMini can’t switch faster than 0.1s. Any thought on this?

I try not to PWM since I want to use this RGB ring.

=====================================================================================

See the code below:

import adafruit_dotstar

import digitalio

import board

import math

import time

import pulseio

import random

These two variables should be adjusted to reflect the number of LEDs you have

and how bright you want them.

num_pixels = 40

brightness = 0.005

This creates the instance of the DoTStar library.

pixels = adafruit_dotstar.DotStar(board.SCK, board.MOSI, num_pixels, brightness=brightness, auto_write=False)

Some standard colors.

BLACK = (0, 0, 0)

RED = (255, 0, 0)

YELLOW = (255, 150, 0)

ORANGE = (255, 40, 0)

GREEN = (0, 255, 0)

TEAL = (0, 255, 120)

CYAN = (0, 255, 255)

BLUE = (0, 0, 255)

PURPLE = (180, 0, 255)

MAGENTA = (255, 0, 20)

WHITE = (255, 255, 255)

A list of the ten colors. Use this if you want to cycle through the colors.

colorList = [RED, YELLOW, ORANGE, GREEN, TEAL, CYAN, BLUE, PURPLE, MAGENTA,

WHITE]

#####################################################################################################

This function takes a color and a dely and fills the entire strand with that color.

The delay is given in the case you use multiple color fills in a row.

def color_fill(color, wait):

pixels.fill(color)

pixels.show()

time.sleep(wait)

#####################################################################################################

while True:

color_fill(WHITE,0.001)

color_fill(BLACK,0.001)

Problem: the ring doesn’t switch fast enough using the pre-defined function color_fill. I wonder if the function or the LuMini can’t switch faster than 0.1s. Any thought on this?

It’s probably a little bit of both but the library is probably what’s really limiting your speed. Have you tried switching just one LED at a time rather than the whole 40? The [data sheet doesn’t really say what the max rate is but there’s probably enough information there to calculate a maximum on off rate.

If the LEDs can change as quickly as you need, you may need to end up skipping the library and bit bang the right data out as fast as you can to see if that does the trick. The more LEDs you are changing the more data you have to send and the slower things get so keep that in mind too.](https://cdn.sparkfun.com/assets/0/1/5/c/3/_20181120__APA_102-2020-256-8.pdf)

Hi TS_Chris,

I did try a single LED, and it showed a huge improvement. Though I would need to run 30-40 of them, so 1 wouldn’t work.

I would think this whole system can handle 1ms switching, don’t you think? It seems to be pretty standard to me that any MCU can do it nowadays.

Any suggestion to speed up this thing up?

Also did a test with a set up of 1ms on/off

For 10 LED, it would become 25ms

For 5 LED, it would be 13ms

For 1 LED, it would be 4ms.

Any suggestion of different hardware/different way to code to resolve this issue?

You could try speeding up the data transfer by writing a routine that directly manipulates the registers in your Arduino. That will significantly speed up how fast you can send out 1’s and zeros’s from your micro controller. You would need to figure out exactly what sequence of 1’s and 0’s to send ahead of time though.

I can’t help with the code needed but these videos and links will explain how port manipulation works.

  • - [Arduino Port Registers
  • - [[Tronixstuff Arduino Port Manipulation](https://tronixstuff.com/2011/10/22/tutorial-arduino-port-manipulation/)
  • - [[ARDUINO: Port Manipulation Tutorial](https://www.youtube.com/watch?v=yGJq2XxfdlY)
  • - [[Faster Digital Writes with Arduino Tutorial! - Direct Port & Register Manipulation](https://www.youtube.com/watch?v=B4bsPDFBJhA)
  • [/list] This might wind up being a lot of work to do, but it's the fastest way to toggle pins and might come in handy for future projects.

    The other alternative would be to use regular white LEDs in a ring rather than addressable ones. Those will turn on and off nearly instantly no matter how many LEDs you’re driving.](https://www.youtube.com/watch?v=B4bsPDFBJhA)](https://www.youtube.com/watch?v=yGJq2XxfdlY)](https://tronixstuff.com/2011/10/22/tutorial-arduino-port-manipulation/)](Arduino Reference - Arduino Reference)