Hi Everyone! I've been working on getting SM16716 working using SPI and was wondering

Hi Everyone! I’ve been working on getting SM16716 working using SPI and was wondering if you could provide me some insight with this… When I run the example code all I get it some flickering throughout the strip.
I’m really new to SPI stuff, so if you can elaborate on your explanation that’d be great… I’d like to really understand this so any suggested reading would be much appreciated. From what I’ve ready it seems like the SM16716 uses 50 Zeros as a reset, and then 25 Bits for payload but I don’t really understand exactly how all of this works, gets linked together with clock timing, leads to smoother or less smooth PWM, etc…Sorry for the noob questions. Many thanks in advanced,
Joe

Btw, I’m working on connecting a 50 LED strip to an Arduino Uno.

Which version of the library are you using? I don’t know that the support in the first version was ever well tested/vetted - the second version should be a bit better.

FastSPI_LED2
… I’m connecting to pins 11 and 13 and have other example code via https://github.com/sowbug/sm16716 working more or less fine so I think the strip is good.

I’ll need to check the library again here with my strip to make sure that it is ok. It can be tricky getting the sm16716 working with hardware spi because that likes to look at the world in 8 bit chunks, and yes - the sm chip wants data in 25 bit chunks (a 1 followed by three sets of 8 bits for each of red, blue, and green data).

One thing to try is in my sample code, in one of the first two lines in the file is a commented out define called something like FORCE_SOFTWARE_SPH or something like that v

Uncomment that line and try rerunning and see if that works. If it does, then I have the basics of supporting the chip in place, and there’s something about the hardware spi support on avr that I messed up.

Also - just to be sure, you uncommented the definition for SM16716Controller? (Vs, say, my sample code still using ws2811).

Thanks so much for the quick and thorough responses…

I uncommented " #define FORCE_SOFTWARE_SPI 1"
and had already commented out LPD8806 and uncommented the SM16716 line.

Looks like the same response. Hmmm… Let me know how I can help. Many thanks again :slight_smile:

Ok - found the problem - (I really hate the SM16716 protocol) - go into FastSPI_LED2.h and somewhere around line 190 you’ll see a pair of functions named showRGB (verify that they’re in the class SM16716Controller) - and replace the two showRGB functions with this:

virtual void showRGB(register struct CRGB *rgbdata, register int nLeds) { 
	writeHeader();
	showRGB(rgbdata, nLeds, 255);
}

virtual void showRGB(struct CRGB *data, int nLeds, uint8_t scale) {
	// Make sure the FLAG_START_BIT flag is set to ensure that an extra 1 bit is sent at the start
	// of each triplet of bytes for rgb data
	writeHeader();
	mSPI.template writeBytes3<FLAG_START_BIT, RGB_ORDER>((byte*)data, nLeds * 3, scale);
}

That should take care of you in the short term (you may need to leave FORCE_SOFTWARE_SPI 1 on). There’s a few more things with the SM16716 that I need to go back in and fix - that extra start bit on each block of rgb data wrecks havoc with using hardware SPI setups (which, unfortunately, you want/need to get decent speed!)

Hmm… I may be editing the wrong file but I think I’m doing editing the correct file, https://code.google.com/p/fastspi/source/browse/branches/FastSPI_LED2/FastSPI_LED2.h?r=51

The 2 functions to replace are then on line 137, and 149, however they both take different perimeters than the functions you replaced them with. I’m getting to different compilation errors right now, one saying writeHeader() isn’t defined in the scope, and another saying "cannot declare ‘LED’ to be of abstract type ‘SM16716Controller<11u,13u,10u,0u>’ "

Any thoughts? Thanks so much in advanced. Also, for future reference, what LED strips do you like and do you have any favorite merchants?

ah - ok - yeah that’s running a much older version of the code - I didn’t realize how much I had been making changes lately - and it also appears to be doing the right thing (I’ve been re-working some of that code in a version of the library that is not yet checked in) - which leaves me a bit stumped as to why it isn’t working with the version of the code that you have.

I will probably be posting up a new release in the next week or so - there’s a bunch of new things that I want to get out - and a lot of changes have been made to the SPI internals, so I probably can’t just give you other quick edits to do/use.

As far as LED strips go - for cheap, right now, I’m liking the ws2811 based strips, however their data rate is only 800Khz, - not terribly fast. For higher speed updating, but a bit more expensive, i’ve been fairly fond of the LPD8806’s.

Personally, I don’t use the SM16716’s for anything, other than adding support to the library and testing them.