fiduciary

Author Topic: Teensy Saber v3 / sk6812 flicker  (Read 238 times)

0 Members and 1 Guest are viewing this topic.

Offline M19eleven

  • No Force
  • *
  • Posts: 8
  • Um...Hello?
Teensy Saber v3 / sk6812 flicker
« on: September 10, 2018, 08:17:25 PM »
Greetings all!

I'm currently working on my very first saber build, a Teensy saber v3 / teensy 3.2 / 144 led (x2) sk6812 neopixel blade.

Everything is working great so far, however I'm having a slight issue with random flickering pixels (rgb colors) as the blade extends and retracts (in the part that should be dark). Another forum member (Obi-ken Wanobi) seems to have had the identical issue, with the same neopixel strips and tried several different solutions with limited success until he rebuilt the electronics with a Teensy 3.6 after learning his data pin on the original teensy was shorted to ground.

My data pin has no continuity to ground and otherwise seems to be operating fine so I'm not sure if that's my solution.

Touching the data wire doesn't seem to affect the flickering as it did in his case.

I've tried various resistors on the data line with no change. I'm using a 1000uf cap across the power. I've tried separating the power/data line to reduce induction noise with no change.

I haven't tried any adjustments in the programming since it seems more like an electrical issue to me but I'm far from an expert.

Any ideas are most welcome!!

Offline profezzorn

  • Mining Colony Members
  • Master Force User
  • *
  • Posts: 865
  • May the source be with you.
    • Hubbe's Corner
Re: Teensy Saber v3 / sk6812 flicker
« Reply #1 on: September 10, 2018, 08:47:24 PM »
Greetings all!

I'm currently working on my very first saber build, a Teensy saber v3 / teensy 3.2 / 144 led (x2) sk6812 neopixel blade.

Everything is working great so far, however I'm having a slight issue with random flickering pixels (rgb colors) as the blade extends and retracts (in the part that should be dark). Another forum member (Obi-ken Wanobi) seems to have had the identical issue, with the same neopixel strips and tried several different solutions with limited success until he rebuilt the electronics with a Teensy 3.6 after learning his data pin on the original teensy was shorted to ground.

My data pin has no continuity to ground and otherwise seems to be operating fine so I'm not sure if that's my solution.

Touching the data wire doesn't seem to affect the flickering as it did in his case.

I've tried various resistors on the data line with no change. I'm using a 1000uf cap across the power. I've tried separating the power/data line to reduce induction noise with no change.

I haven't tried any adjustments in the programming since it seems more like an electrical issue to me but I'm far from an expert.

Any ideas are most welcome!!


The programming is the easiest to change though, which is why you should always try that first. :) (Do you know how?)
The second thing to try is usually a different battery. Weak batteries can cause a lot of problems. A 1000uF cap ought to help with that though.

Do you usually have your saber connected to USB when you try it? If so, try disconnecting it.
The WS2811 data signal is generated by DMA in the cpu, the DMA channel reads from RAM, and the RAM can be really really busy when USB is active.  I suppose there could also be something else interferring with the DMA, but I'm not sure what that would be.

What version of the code do you have? I fixed a few WS2811-related bugs over the summer, so if your code is really old, you might need to update it.

Offline M19eleven

  • No Force
  • *
  • Posts: 8
  • Um...Hello?
Re: Teensy Saber v3 / sk6812 flicker
« Reply #2 on: September 10, 2018, 10:36:57 PM »
I have a fairly decent grasp of the programming so I will start to experiment with that.

I'm using software version 1.279 currently.

I've tried the saber with and without USB connected and the issue is present in both cases.

I have 2 freshly charged batteries I swap between.  I suspected maybe a current issue so I tried the setup with only 1 strip connected and it still behaved the same.

The DMA / RAM issue is something I'll definitely look into... perhaps that's the reason why Obi-Ken's issue was resolved with the teensy 3.6?

(Here is the thread in which you graciously helped him troubleshoot the issue: https://www.fx-sabers.com/forum/index.php?action=profile;u=89639;area=showposts;start=30)

I'll tinker around with it and will be sure to update on the results.

Thank you so much for the assistance and all the work you've put into this.  I'm having a blast with it.

Offline M19eleven

  • No Force
  • *
  • Posts: 8
  • Um...Hello?
Re: Teensy Saber v3 / sk6812 flicker
« Reply #3 on: September 11, 2018, 02:50:37 AM »
I just did a quick experiment and using the serial monitor command, turned the amp off, then extended and retracted the blade several times and the flickering issue is completely gone.

Enabling the amp brings the flickers right back.

I think we're getting closer... Experimenting continues.

Offline profezzorn

  • Mining Colony Members
  • Master Force User
  • *
  • Posts: 865
  • May the source be with you.
    • Hubbe's Corner
Re: Teensy Saber v3 / sk6812 flicker
« Reply #4 on: September 11, 2018, 01:35:10 PM »
I just did a quick experiment and using the serial monitor command, turned the amp off, then extended and retracted the blade several times and the flickering issue is completely gone.

Enabling the amp brings the flickers right back.

I think we're getting closer... Experimenting continues.

That is an excellent observation, and it pretty much guarantees that the problem is electrical somehow.
(because turning off the amp doesn't turn off any of the code that sends the sound out, you just can't hear it.)

One possibility is that it's some sort overhearing, a signal getting transmitted from one wire to another.
The speaker wires, the speaker and the coil for the booster would be the most likely candidates for such interference.

The other option is that the noise travels back through the board itself. However, I'm not sure how that would flip zeroes to ones. (Seems like it would be more likely to flip ones to zeroes.) Although, maybe the noise is added to the ground wire.

First thing to try would be to just shuffle your wires around a bit and see if that makes a difference. I suspect it won't or you would have already noticed.

Offline M19eleven

  • No Force
  • *
  • Posts: 8
  • Um...Hello?
Re: Teensy Saber v3 / sk6812 flicker
« Reply #5 on: September 11, 2018, 03:07:35 PM »
I've done a lot of wire shuffling and haven't observed any difference.

I took the speaker off, thinking maybe the voicecoil was defective and sending some noise back into the ground plane but that had no effect.

I examined the boards under a scope to see if I could spot any suspect joints or stray solder and everything looks pretty good.

I'm going to take a look at the booster now.

It really feels like an overhearing situation to me but can't for the life of me figure out where. The issue doesn't happen consistently... If I extend and retract the blade several times in a row sometimes it will not have any of the flickering at all, sometimes very minor, sometimes a lot. This is with everything stable and controlling by either power button or serial console.

Offline M19eleven

  • No Force
  • *
  • Posts: 8
  • Um...Hello?
Re: Teensy Saber v3 / sk6812 flicker
« Reply #6 on: September 11, 2018, 03:43:46 PM »
Well I may have misspoken in my earlier post. When turned the amp off I was using the blade off/on command which I forgot doesn't trigger the sound at all anyway.

I reinstalled the speaker so I can hear what's going on again :).

From the serial console I played the mars.wav track and used blade on/off. Result=flicker

While still playing Mars.wav I turned the amp off. Result=flicker

Stopping the audio, amp on. No flicker.

Looks like we're back to the DMA/RAM issue.

Offline profezzorn

  • Mining Colony Members
  • Master Force User
  • *
  • Posts: 865
  • May the source be with you.
    • Hubbe's Corner
Re: Teensy Saber v3 / sk6812 flicker
« Reply #7 on: September 11, 2018, 03:48:32 PM »
Well I may have misspoken in my earlier post. When turned the amp off I was using the blade off/on command which I forgot doesn't trigger the sound at all anyway.

I reinstalled the speaker so I can hear what's going on again :).

From the serial console I played the mars.wav track and used blade on/off. Result=flicker

While still playing Mars.wav I turned the amp off. Result=flicker

Stopping the audio, amp on. No flicker.

Looks like we're back to the DMA/RAM issue.

That's some excellent bug-hunting skills there.
I'm going to take a look to see if there is a way to adjust the priority of the DMA requests, although I thought it was already pretty high. I suspect the problem has something to do with the SD reading code, maybe it's using DMA as well.


Offline profezzorn

  • Mining Colony Members
  • Master Force User
  • *
  • Posts: 865
  • May the source be with you.
    • Hubbe's Corner
Re: Teensy Saber v3 / sk6812 flicker
« Reply #8 on: September 11, 2018, 11:03:00 PM »
Well I may have misspoken in my earlier post. When turned the amp off I was using the blade off/on command which I forgot doesn't trigger the sound at all anyway.

I reinstalled the speaker so I can hear what's going on again :).

From the serial console I played the mars.wav track and used blade on/off. Result=flicker

While still playing Mars.wav I turned the amp off. Result=flicker

Stopping the audio, amp on. No flicker.

Looks like we're back to the DMA/RAM issue.

That's some excellent bug-hunting skills there.
I'm going to take a look to see if there is a way to adjust the priority of the DMA requests, although I thought it was already pretty high. I suspect the problem has something to do with the SD reading code, maybe it's using DMA as well.

I found something that might help, it's a piece of code that can go almost anywhere:
Code: [Select]
#ifdef __MK20DX256__
    MCM_CR = MCM_CR_SRAMLAP(1) | MCM_CR_SRAMUAP(0);
    AXBS_PRS0 = 0x1032;
#endif

I haven't tested this myself yet, but I thought maybe you would be able to get to it before me.

Offline M19eleven

  • No Force
  • *
  • Posts: 8
  • Um...Hello?
Re: Teensy Saber v3 / sk6812 flicker
« Reply #9 on: September 12, 2018, 02:09:27 AM »
Great suggestion. I had high hopes but unfortunately it didn't seem to have an effect on the issue. 

I'm going to try a new SD card tomorrow to make sure that's not the issue. This one benchmarks fine but there might be more to it.

Offline SA22C

  • No Force
  • *
  • Posts: 27
  • Don't Panic
Re: Teensy Saber v3 / sk6812 flicker
« Reply #10 on: September 12, 2018, 06:06:12 AM »
Iíve also observed weirdness with sk6812 skinny strips, (effects not rendering correctly and lots of transitory pixel artifacting) but it was much improved after I desired everything with a fresh teensy after the USB port broke loose from my first build.

Still, I have similar symptoms, especially on the battery meter style. Iíve got some regular ws2811b strips that Iím gonna build into a second blade and do some a-b testing next week.

Offline profezzorn

  • Mining Colony Members
  • Master Force User
  • *
  • Posts: 865
  • May the source be with you.
    • Hubbe's Corner
Re: Teensy Saber v3 / sk6812 flicker
« Reply #11 on: September 12, 2018, 10:53:35 AM »
Great suggestion. I had high hopes but unfortunately it didn't seem to have an effect on the issue. 

I'm going to try a new SD card tomorrow to make sure that's not the issue. This one benchmarks fine but there might be more to it.

What if you try:

Code: [Select]
#ifdef __MK20DX256__
    MCM_CR = MCM_CR_SRAMLAP(3) | MCM_CR_SRAMUAP(3);
    AXBS_PRS0 = 0x1032;
#endif

?

Offline profezzorn

  • Mining Colony Members
  • Master Force User
  • *
  • Posts: 865
  • May the source be with you.
    • Hubbe's Corner
Re: Teensy Saber v3 / sk6812 flicker
« Reply #12 on: September 12, 2018, 10:54:52 AM »
Iíve also observed weirdness with sk6812 skinny strips, (effects not rendering correctly and lots of transitory pixel artifacting) but it was much improved after I desired everything with a fresh teensy after the USB port broke loose from my first build.

Still, I have similar symptoms, especially on the battery meter style. Iíve got some regular ws2811b strips that Iím gonna build into a second blade and do some a-b testing next week.

It seems that something has changed with the skinny strips, because this didn't use to be a problem (afaik)

Offline M19eleven

  • No Force
  • *
  • Posts: 8
  • Um...Hello?
Re: Teensy Saber v3 / sk6812 flicker
« Reply #13 on: September 12, 2018, 02:57:48 PM »

What if you try:

Code: [Select]
#ifdef __MK20DX256__
    MCM_CR = MCM_CR_SRAMLAP(3) | MCM_CR_SRAMUAP(3);
    AXBS_PRS0 = 0x1032;
#endif

?

No luck with this one either. The new SD card also didn't change anything.

Now the good news is I managed to get rid of the issue completely with a very simple change! The bad news is that it's not very elegant :(.

In an effort to definitively rule out a bad chip, crosstalk interference, or anything along those lines I decided to try the teensy at a lower clock speed to see what (if any) effect it would have on the issue and boy did it have an effect. Instead of a few rainbow flickering pixels here and there, the whole blade was a jumble of flickers while extending and retracting the blade.

So... if a slower CPU makes the problem much worse, perhaps a faster CPU will make it better?  It sure does.  Changing the clock speed to a 120mhz overclock fixes everything. Kind of a brute force bandaid, but successful nonetheless.

I ran it for a little while to see if there would be a concern of overheating but the chip doesn't even get warm to the touch so it doesn't seem like 120 is pushing it to the limits at all.  Plus, since this isn't a continuous duty device I think the overall impact of the increased clock speed will be negligible. 

This solution would also explain why swapping out the Teensy to a 3.6 has fixed the issue for some.

I can't thank you enough for all your help with this. Hopefully someone else will find this info useful as well.