Go to Post If all else fails - bring cookies in the shape of FIRST shapes. Cookies are always good. - Eugenia Gabrielov [more]
Home
Go Back   Chief Delphi > Technical > Programming > NI LabVIEW
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 03-09-2016, 17:57
s5511's Avatar
s5511 s5511 is offline
Registered User
FRC #5511
 
Join Date: Jan 2016
Location: Cary, NC
Posts: 57
s5511 is an unknown quantity at this point
Question AdaFruit DotStars Help

Our team is trying to use AdaFruit DotStars, but we have been running into many issues. We are using Labview, and are connecting through SPI. Could someone show sample code that would allow us to send values to the lights? We need to open it in Begin.vi, and send data through Periodic Tasks.vi right? Also, how exactly does the wiring work? Is there a particular arrangement you need to plug the SPI in? We have been getting refnum errors among others (44007 & 91). All help is greatly appreciated!
__________________


NC Rookie All Star, Rookie Highest Seed 2015
NC THOR Winner 2015
NC Guilford County Winner and Creativity Award 2016
Reply With Quote
  #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
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 20:44.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi