electricimp / reference

Electric Imp Reference Code
MIT License
94 stars 65 forks source link

Fixing glitching pixels #11

Closed kgleeson closed 9 years ago

kgleeson commented 10 years ago

This fixes issues with glitching pixels I had on a Neopixel 60 ring with 5v/10a psu.

kgleeson commented 10 years ago

Thats updated now and should be good to go.

It has my Neopixel 60 ring running perfectly glitch free now https://www.youtube.com/watch?v=AR_XrYeBeIU :)

ersatzavian commented 10 years ago

That is fantastic. Thank you so much.

mezelve commented 10 years ago

the new code throws an error: [Status] Device booting; 5.88% program storage used [Device] ERROR: the index 'BYTESPERPIXEL' does not exist [Device] ERROR: at main:16

so I moved BYTESPERPIXEL outside the neopixel class and defined it as a const const BYTESPERPIXEL = 24;

code doesn't throw an error now but I still get glitches after the 26th pixel on my 60 pixel WS2812B ring.

@kgleeson would you mind sharing the code from the video?

kgleeson commented 10 years ago

Ah ha, turns out when I changed the clearblob I hadn’t actually ran it, but I had when I changed the other lines.

Sure I’ve the code up at https://gist.github.com/kgleeson/9387458

On Monday 31 March 2014 at 20:03, Pieter wrote:

the new code throws an error: [Status] Device booting; 5.88% program storage used [Device] ERROR: the index 'BYTESPERPIXEL' does not exist [Device] ERROR: at main:16
so I moved BYTESPERPIXEL outside the neopixel class and defined it as a const const BYTESPERPIXEL = 24;
code doesn't throw an error now but I still get glitches after the 26th pixel on my 60 pixel WS2812B ring.
@kgleeson (https://github.com/kgleeson) would you mind sharing the code from the video?

— Reply to this email directly or view it on GitHub (https://github.com/electricimp/reference/pull/11#issuecomment-39127811).

blindman2k commented 10 years ago

Realistically, it won't make a difference in this case but its risky practice to initialise instance blobs in the class definition as if you instantiate two objects of the same class they will share the memory (somewhat like a static property). You are better off leaving the const definition inside the constructor (optional) and allocating the blob inside the constructor too. Leaving out the rest of the stuff, this is what it would/could look like.

class NeoPixels { clearblob = null;

constructor(_spi, _frameSize)
{

    const BYTESPERPIXEL   = 24;
    clearblob = blob(BYTESPERPIXEL);

} }

On Mon, Mar 31, 2014 at 12:23 PM, Kieran Gleeson notifications@github.comwrote:

Ah ha, turns out when I changed the clearblob I hadn't actually ran it, but I had when I changed the other lines.

Sure I've the code up at https://gist.github.com/kgleeson/9387458

Thanks, Kieran Gleeson

On Monday 31 March 2014 at 20:03, Pieter wrote:

the new code throws an error: [Status] Device booting; 5.88% program storage used [Device] ERROR: the index 'BYTESPERPIXEL' does not exist [Device] ERROR: at main:16 so I moved BYTESPERPIXEL outside the neopixel class and defined it as a const const BYTESPERPIXEL = 24; code doesn't throw an error now but I still get glitches after the 26th pixel on my 60 pixel WS2812B ring. @kgleeson (https://github.com/kgleeson) would you mind sharing the code from the video?

Reply to this email directly or view it on GitHub ( https://github.com/electricimp/reference/pull/11#issuecomment-39127811).

Reply to this email directly or view it on GitHubhttps://github.com/electricimp/reference/pull/11#issuecomment-39129942 .

blindman2k commented 10 years ago

Hi all,

I just finally got my NeoPixel ring to stop glitching by dropping the SPI clock rate to 3750 kHz.

const SPICLK = 3750; // kHz

A.

On Mon, Mar 31, 2014 at 1:40 PM, Aron Steg aron.steg@bcde.com.au wrote:

Realistically, it won't make a difference in this case but its risky practice to initialise instance blobs in the class definition as if you instantiate two objects of the same class they will share the memory (somewhat like a static property). You are better off leaving the const definition inside the constructor (optional) and allocating the blob inside the constructor too. Leaving out the rest of the stuff, this is what it would/could look like.

class NeoPixels { clearblob = null;

constructor(_spi, _frameSize)

{

    const BYTESPERPIXEL   = 24;

    clearblob = blob(BYTESPERPIXEL);

} }

On Mon, Mar 31, 2014 at 12:23 PM, Kieran Gleeson <notifications@github.com

wrote:

Ah ha, turns out when I changed the clearblob I hadn't actually ran it, but I had when I changed the other lines.

Sure I've the code up at https://gist.github.com/kgleeson/9387458

Thanks, Kieran Gleeson

On Monday 31 March 2014 at 20:03, Pieter wrote:

the new code throws an error: [Status] Device booting; 5.88% program storage used [Device] ERROR: the index 'BYTESPERPIXEL' does not exist [Device] ERROR: at main:16 so I moved BYTESPERPIXEL outside the neopixel class and defined it as a const const BYTESPERPIXEL = 24; code doesn't throw an error now but I still get glitches after the 26th pixel on my 60 pixel WS2812B ring. @kgleeson (https://github.com/kgleeson) would you mind sharing the code from the video?

Reply to this email directly or view it on GitHub ( https://github.com/electricimp/reference/pull/11#issuecomment-39127811).

Reply to this email directly or view it on GitHubhttps://github.com/electricimp/reference/pull/11#issuecomment-39129942 .

mezelve commented 10 years ago

That's it! Thank you @blindman2k ! I've added your 2 modifications. https://gist.github.com/mezelve/9903312

mezelve commented 10 years ago

Ok. I still have some issues with clearFrame(). For now I'm looping through all the pixels and I set them to [0,0,0].

kgleeson commented 10 years ago

This causes my 60 ring to just go white, reverting back to 7500 works perfectly.

I hadn't tried it recently, but even with the spi clock at 7500, the code makes my 60 led/m strip just display random colours for pixels 0 - 34 and nothing after that.

blindman2k commented 10 years ago

I tested on my other NeoPixels at home and it won't stay stable, even at 3750khz. Any movement of the USB cable (particularly at the connector in the power source) and the colours go haywire. It is better at 3750khz but its still not usable. Back to the hardware drawing board for me.

blindman2k commented 10 years ago

Yay! I am back up and running. I added a diode, as per @tombrew's instructions, to drop the voltage a bit and at 3750khz everything is perfectly stable and I am busy creating animations.

cat-haines commented 9 years ago

Close PR - significantly out of date