Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

DotStar - Digital Pin vs SPI delay and utilising SPI pins fo
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

DotStar - Digital Pin vs SPI delay and utilising SPI pins fo

by jasontheblob on Sun Dec 29, 2019 9:24 am

Hi all,

I am currently trying to utilise two 0.5m strands of 144 Dotstar LED's for a cosplay outfit I'm creating (a tail).

I am powering the DotStars using a PowerBoost board, with the actual tail effects coming from a Adafruit Trinket M0 (which I'm programming using Circuit Python). My plan is to have each strip display a unique scrolling lighting pattern.

Currently I have one DotStar strip connected to pin 4+5 (SPI pins) and have the other strip connected to pin 0+1 (Digital Pins).

Both DotStar strips are working and I am able to program each of them. However I have noted that the SPI connected Dotstar strip updates significantly faster than the digital pin strip (0.02 seconds vs 0.3 seconds). This impacts the scrolling animations I wish to use, (as the digitial pin DotStar takes almost 30 seconds just to update each led on the strip). I have added the test code I am using to get these numbers at the end of this thread.

So my questions are:

1. I was aware that utilising digital pins/bit banging would have a performance hit, but is it expected/normal that it should take 0.3 seconds to run one led update command on a DotStar?

2. Is there any way to send unique commands to each strip utilising the same SPI pins? (ie if I try to run both strips off pin 4 and 5)

3. Are there any boards that might offer the ability for multiple SPI ports? I had a look online but didnt have much success. This would allow me to connect each DotStar strip to their own personal SPI connection.
[/list]Of course the other solution I have is to just run each DotStar off its own Trinket board but if possible I would prefer to run the code for both strips off the same board.

Any suggestions or tips?

Code I used to test is below:

Code: Select all | TOGGLE FULL SIZE
import time
import board
import adafruit_dotstar as dotstar
# Using a DotStar Digital LED Strip with 72 LEDs connected to SPI pins
#dots = dotstar.DotStar(board.D3, board.D4, 72, brightness=1)

# Using a DotStar Digital LED Strip with 72 LEDs connected to digital pins
dots = dotstar.DotStar(board.D1, board.D0, 72,brightness=1)

# MAIN LOOP
n_dots = len(dots)
while True:
    # Fill each dot with a random color
    for dot in range(n_dots):
        startTime = time.monotonic()
        dots[dot] = (0, 255,0)
        #display time it took to update LED
        print("Time to run: " + str(time.monotonic()-startTime))


Thanks!

jasontheblob
 
Posts: 3
Joined: Sun Dec 29, 2019 8:35 am

Re: DotStar - Digital Pin vs SPI delay and utilising SPI pin

by jasontheblob on Fri Jan 03, 2020 12:12 pm

Followup reading at "CircuitPython Microcontroller Wiring" (https://learn.adafruit.com/adafruit-dotstar-leds/python-circuitpython) notes that "If the LEDs are on hardware SPI pins, they will create a SPI device. If they're not on a hardware SPI pin combination, they will be bit banged. Wiring up to a hardware SPI pin combination means they'll respond screaming fast! However, it also means you can't share SPI with anything else. So if you have the need for another SPI device, you can bit bang but the LEDs will respond more slowly."

So I guess my revised question is How do you connect multiple DotStar Led strips to the same board without one been slowed down? I can't connect both to the same SPI pins as I want to individually program each strip (rather than have them replicate the same pattern).

Happy to provide any additional information needed!

jasontheblob
 
Posts: 3
Joined: Sun Dec 29, 2019 8:35 am

Re: DotStar - Digital Pin vs SPI delay and utilising SPI pin

by jasontheblob on Fri Jan 10, 2020 8:25 am

bump.... if this is in the wrong place please let me know.

jasontheblob
 
Posts: 3
Joined: Sun Dec 29, 2019 8:35 am

Re: DotStar - Digital Pin vs SPI delay and utilising SPI pin

by adafruit_support_carter on Thu Jan 16, 2020 2:06 pm

Suggestion - Even though you want two strips, trying just making it one strip. Tie that to a hardware SPI port so it's fast. And then take care of simulating two strips in software.

adafruit_support_carter
 
Posts: 16938
Joined: Tue Nov 29, 2016 2:45 pm

Please be positive and constructive with your questions and comments.