Today 12:26
Forum: Website / Forum Issues
Starter: rcurl
Views: 0
Replies: 11
Yesterday 14:15
Forum: Absolute Beginners Section
Starter: amod
Views: 0
Replies: 29
Yesterday 14:11
Forum: The Lounge
Starter: pic-ignorant
Views: 0
Replies: 2
+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 17

Thread: Driving SK9822 or APA102 RGB LED's137 days old

  1. #1
    Prolific Poster rcurl's Avatar
    Join Date
    Mar 2002
    Posts
    1,783
    Thumbs Up
    Received: 31
    Given: 51
    Total Downloaded
    1.54 GB

    0 Not allowed!

    Default Driving SK9822 or APA102 RGB LED's

    I've been trying to figure out how to drive SK9822 or APA102 RGB LED's using the MSSP module in a PIC16F1503 but I'm getting nowhere. Part of the problem is that I haven't used MSSP SPI mode with a PIC16 series chip, and I hate to admit that I can't even find the SFR flag that tells me that the transmission is complete.

    The data protocol for these LEDS is like this:
    Start frame consisting of 32 0's
    Multiple LED frames, each one consisting of: 3 1's, followed by a 5-bit global brightness value, followed by 8-bit Blue, 8-bit Green, and 8-bit Red values
    End frame consisting of 32 1's

    I would post my code, but it's such a mess that I'm embarrassed to show what a noob I am.

    Can anyone help me get started on this?

    Thanks!

    -Rick

  2. #2
    Member Oldhack's Avatar
    Join Date
    Aug 2010
    Posts
    152
    Thumbs Up
    Received: 9
    Given: 0
    Total Downloaded
    1.02 GB

    0 Not allowed!

    Default Re: Driving SK9822 or APA102 RGB LED's

    Hello Rick
    The Neopixel using the WS2812 has to be ran at high speed to match the internal clock, (See Adafruit Web site for great information) I had to use Assembly on a eight bit chip with 40 NS. timings,
    The Dot star APA102 is a strange SPI with the 32 zeros and one's, I had to look far and wide on the net and found some information that cleared up some of the issues, I do not think the Dot star APA102 makes things any more easier than the Neopixel.
    The thing you should have is a Saleae logic analyzer
    I hope that at some time they will make a true SIPO it will have to have one color four wire or RGB with six wires.
    Good luck it will drive you a little nuts.

    Best to you
    Gary

  3. #3
    Member tumbleweed's Avatar
    Join Date
    May 2011
    Posts
    379
    Thumbs Up
    Received: 68
    Given: 0
    Total Downloaded
    141.92 MB

    0 Not allowed!

    Default Re: Driving SK9822 or APA102 RGB LED's

    The SK9822 and APA102 are infinitely easier to deal with than the WS2812.

    All you need to do is send out a few bytes of SPI data at just about any reasonable frequency... none of the timing woes of those others.

    The PIC16 SPI is pretty much the same as the PIC18 MSSP. You can tell when a transmission is complete by using the SSP1IF bit in PIR1, or the BF bit in SSP1STAT register.

  4. #4
    Fanatical Contributor Les's Avatar
    Join Date
    Feb 2002
    Posts
    3,017
    Thumbs Up
    Received: 309
    Given: 114
    Total Downloaded
    1.51 GB

    0 Not allowed!

    Default Re: Driving SK9822 or APA102 RGB LED's

    As Tumbleweed has said, the SK9822 and APA102 devices are quite easy to interface with, as it is, essentially, an SPI interface.

    They are also, a lot, faster than the WS2812 devices, which are dreadfully slow. Lovely devices, but slow. :-) I'm a bit busy at the moment, but as soon as I get some time, I'll create an interface library for the SK9822 and APA102 devices. Well....... It will be for the APA102 devices, because I don't have any SK9822 devices, but, apparently, they are the same interface, but the APA devices are a lot faster. From what I've read, the SK9822 have a 4KHz speed, while the APA102 devices have a 19KHz speed. And with RGB LEDs in a strip or a panel, speed is a must for interesting projects. LOL
    For more example programs for Proton and Proton24 or updates, please visit: Proton WIKI or Proton Files

  5. #5
    Prolific Poster rcurl's Avatar
    Join Date
    Mar 2002
    Posts
    1,783
    Thumbs Up
    Received: 31
    Given: 51
    Total Downloaded
    1.54 GB

    0 Not allowed!

    Default Re: Driving SK9822 or APA102 RGB LED's

    Thanks for the info!
    I can't seem to get anything out of the SPI Master.

    I've got the MSSP set up like this:
    Code:
    All_Digital = true
    Declare Xtal = 16
    
    '* Set I/O pin direction *
    APFCON = %00010000
    TRISA = 0       'all pins digital output
    TRISC = 0
    ANSELA = 0
    ANSELC = 0
    
    
    '* Set up MSSP module for SPI *
    SSP1STAT = %00000000
    SSP1CON1 = %00100000
    SSP1CON2 = %00000000
    SSP1CON3 = %00000000
    SSP1MSK = %00000000
    SSP1ADD = %00000000
    ...and then to test it I'm doing this:
    Code:
    SPItest:
      SSP1BUF = %10101010 
      DelayMS 1
    GoTo SPItest
    At the moment I'm not trying to drive any LED's. I'm just looking at the clock and SDO lines with the 'scope, but there's nothing there. What have I missed?

  6. #6
    Junior Member Dave Purola's Avatar
    Join Date
    Jul 2004
    Posts
    26
    Thumbs Up
    Received: 9
    Given: 0
    Total Downloaded
    68.55 MB

    0 Not allowed!

    Default Re: Driving SK9822 or APA102 RGB LED's

    Rick, Here is a small test program I wrote to do some testing of APA102C's around XMAS last year. It's in PBP.
    Attached Files Attached Files

  7. #7
    Prolific Poster rcurl's Avatar
    Join Date
    Mar 2002
    Posts
    1,783
    Thumbs Up
    Received: 31
    Given: 51
    Total Downloaded
    1.54 GB

    0 Not allowed!

    Default Re: Driving SK9822 or APA102 RGB LED's

    Quote Originally Posted by Dave Purola View Post
    Rick, Here is a small test program I wrote to do some testing of APA102C's around XMAS last year. It's in PBP.
    Thanks, Dave! Much appreciated. Looks like it uses a software SPI driver instead of the MSSP, but at this point I just want to see some LED's light up!

    I'll convert it to PDS when I get home tonight.

    -Rick

  8. #8
    Prolific Poster rcurl's Avatar
    Join Date
    Mar 2002
    Posts
    1,783
    Thumbs Up
    Received: 31
    Given: 51
    Total Downloaded
    1.54 GB

    0 Not allowed!

    Default Re: Driving SK9822 or APA102 RGB LED's

    Well- it seems to be working ....at least occasionally. I'm using this code:
    Code:
     SPIloop:                       
    SHOut PORTC.2, PORTC.0, MsbFirst, [$00,$00,$00,$00] 'start frame
                                   ' global-BL-GR- RED
    SHOut PORTC.2, PORTC.0, MsbFirst, [$FF,$FF,$00,$00]  'LED1 Blue
    SHOut PORTC.2, PORTC.0, MsbFirst, [$FF,$00,$FF,$00]  'LED2 Green
    SHOut PORTC.2, PORTC.0, MsbFirst, [$FF,$FF,$FF,$FF]  'end frame
    DelayMS 1
    GoTo SPIloop
    I have it in a loop to make it easier to see on the scope.

    The data and clock look fine on the scope and on the data analyzer, but the SK9822 LED's sometimes come on immediately, and sometimes take a minute or two to come on. I've got an LED blinking on another port, so I know the PIC is awake and the clock rate is properly declared.

    At least it's a start. Could be a hardware issue. I'll post any new findings here.

    -Rick

  9. #9
    Junior Member Dave Purola's Avatar
    Join Date
    Jul 2004
    Posts
    26
    Thumbs Up
    Received: 9
    Given: 0
    Total Downloaded
    68.55 MB

    0 Not allowed!

    Default Re: Driving SK9822 or APA102 RGB LED's

    Rick, The code as presented shifts the data out MSB first with the clock idling low. I am unfamiliar with the "SHOut " command. I also am unfamiliar with using the SK9822 led's. I will look for a data sheet and see what the differences are.

  10. #10
    Junior Member Dave Purola's Avatar
    Join Date
    Jul 2004
    Posts
    26
    Thumbs Up
    Received: 9
    Given: 0
    Total Downloaded
    68.55 MB

    0 Not allowed!

    Default Re: Driving SK9822 or APA102 RGB LED's

    Rick, I just looked at the data sheet for the SK9822's and it appears they are the same. I would possibly see if there is a way to delay the clocking of the SHOut command as there is for the PBP version of the command "Shiftout".

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. DMX512 RGB led controller
    By Roshan in forum Proton Plus Compiler v3
    Replies: 5
    Last Post: 17th November 2015, 10:49
  2. Apa102 led
    By StipoGill in forum Projects discussion
    Replies: 0
    Last Post: 10th June 2014, 04:07
  3. Octobrite RGB Led Display and TLC5947
    By ohararp in forum Projects discussion
    Replies: 0
    Last Post: 20th December 2010, 15:27
  4. RGB led's parallel
    By pe1pme in forum The Lounge
    Replies: 1
    Last Post: 2nd December 2010, 04:31
  5. 2 Pin RGB LED
    By Darlington in forum The Lounge
    Replies: 7
    Last Post: 22nd December 2008, 22:01

Members who have read this thread : 38

Actions :  (Set Date)

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts