View Single Post
  #2   Spotlight this post!  
Unread 09-09-2016, 15:52
RyanN's Avatar
RyanN RyanN is offline
RyanN
AKA: Ryan Nazaretian
FRC #4901 (Garnet Squadron)
Team Role: Mentor
 
Join Date: Jun 2006
Rookie Year: 2005
Location: Columbia, SC
Posts: 1,126
RyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond repute
Re: AdaFruit DotStars Help

Disclaimer first: I haven't had any SPI experience with the RoboRIO.

Here's a link to the APA102C LED / DotStar datasheet: https://cdn-shop.adafruit.com/produc...43/APA102C.pdf

Electrically, SPI has 4 active signals:
MOSI (Master out, Slave in) - Data from the controller to the device
MISO (Master in, Slave out) - Data from the device to the controller
SCLK (SPI clock) - The clock signal used to synchronize the data
CS (Chip select) - Active low signal used to 'select' a device to communicate with.

The DotStar is an output only device, so you won't have anything connected to the MISO pin. It's also not a true SPI device, so you wan't have anything connected to the CS pin.

In the end, you'll have SCLK connected to CI and MOSI connected to DI.

Begin.vi
In the Begin.vi, you'll need to select the SPI Bus. You're probably using the main SPI connector on the RoboRIO and not on the MXP port. You have 4 choices for the CS from 0 to 4. Since this is the chip select, you need to make sure the DotStar is connected to the appropriate CS pin. By default, the LabVIEW SPI operates at 500kHz. Adafruit says DotStars can operate up to 8MHz. 500kHz is likely plenty fast enough. Keep it as low as possible and only go faster if you need to.


Periodic Tasks.vi
This part is up to you to figure out. Technically, DotStars are not SPI chips. You could bit-bang the protocol out of two digital output ports.

A data stream consists of 3 parts:
Start Frame 0x000000 (32-bits of 0s)
Data Field - variable length in multiples of 32
End Frame 0xFFFFFFFF (32-bits of 1s)

The Data Field is where the LED Frames are stored. From the way the data sheet describes, the first LED on the chain is LED 1, and the last is LED N (where N is the number of LEDs you have in the chain).

Each LED frame is also 32-bits
[111][Global 5-bits][Blue 8-bits][Green 8-bits][Red 8-bits]

The global controls the global brightness setting. This value ranges from 2^0-1, or 0 to 2^5 - 1, or 31, so 0-31.

Each color channel is 8 bits, and has a range from 0 to 255. This is also called an unsigned 8-bit number. I'm not sure how you want to handle this with LabVIEW, but I would create a cluster type-def with 4 uint-8 elements.



Now, the easy part... convert that array of unsigned 32-bit integers into an array of consecutive 8-bit integers. That can be fed into the SPI write block.
__________________
Garnet Squadron
FRC 4901
Controls Mentor
@rnazaretian

Previous mentor and student from Team Fusion, FRC 364
Reply With Quote