![]() |
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!
|
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. |
| All times are GMT -5. The time now is 20:44. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi