Issue with Prop Maker, M4, and NeoPixel

Please tell us which board you are using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
vader7071
 
Posts: 124
Joined: Mon Sep 11, 2017 12:45 pm

Issue with Prop Maker, M4, and NeoPixel

Post by vader7071 »

So I have a Featherwing Propmaker (PID: 3988), a Feather M4 (PID: 3857), and a 144LED/m NeoPixel strip (PID: 2969).

I am trying to make the lightsaber (as seen here), and I have stumbled onto some problems.

I assembled the wing and the M4 as shown, added the speaker and a pushbutton, and wired the neopixel strip into the wing. When I 1st powered this on and tested, everything went fine. Strip lit up, if I changed the color code in the program, the blade color changed, all was well.

Fast forward about 3 weeks, I get the parts and begin to assemble everything into a hilt for test fitting, and I want to test out the strip in my blade, and the pixel strip will not come on. I check and reload the program, even go back to the default program to make sure I didn't corrupt something. No lights, none, not a one. I begin to check the voltage down the pixel strip. 5VDC at the beginning and 5VDC at the very end. I do not have a way to test the data on the data line.

In the process of testing, the lights just came on. They did not "extend" like they were supposed to, they just "boom" all on at once. Then they dropped out. I took a moment and reloaded my program ( specialized blade color), and again, initially, no lights. Then checking voltage down the blade, "boom", all lights on at once.

Where do I need to start looking deeper trying to nail this down? I am guessing since the lights just all pop on at once after the program called for them to "extend", I need to look at my initial data connection? Could this be on the featherwing? Could this be a weak solder joint on the JST or the neopixel strip?

Thank you in advance for your help.

User avatar
dastels
 
Posts: 15662
Joined: Tue Oct 20, 2015 3:22 pm

Re: Issue with Prop Maker, M4, and NeoPixel

Post by dastels »

A connection problem wouldn't explain this since suddenly connecting wouldn't cause them all to be on. You're using the standard software for the project?

Dave

User avatar
vader7071
 
Posts: 124
Joined: Mon Sep 11, 2017 12:45 pm

Re: Issue with Prop Maker, M4, and NeoPixel

Post by vader7071 »

Yes. Just took the example code, changed the line that says "COLOR" to set to the custom rgb code, and upload the program to the M4.

No other wiring or code changes.

I do have the speaker connected and I always get sound. That is how I know the leds should be on.

User avatar
dastels
 
Posts: 15662
Joined: Tue Oct 20, 2015 3:22 pm

Re: Issue with Prop Maker, M4, and NeoPixel

Post by dastels »

Can you post some clear photos out the wiring and connections?

Dave

User avatar
vader7071
 
Posts: 124
Joined: Mon Sep 11, 2017 12:45 pm

Re: Issue with Prop Maker, M4, and NeoPixel

Post by vader7071 »

sure. I will get them tonight.

User avatar
vader7071
 
Posts: 124
Joined: Mon Sep 11, 2017 12:45 pm

Re: Issue with Prop Maker, M4, and NeoPixel

Post by vader7071 »

20220110_195155.jpg
20220110_195155.jpg (109.73 KiB) Viewed 146 times
20220110_195142.jpg
20220110_195142.jpg (99.23 KiB) Viewed 146 times
20220110_195206.jpg
20220110_195206.jpg (65.41 KiB) Viewed 146 times
Here are the photos of the wiring to the featherwing and the neopixels. The M4 has female headers, the prop wing has male headers, and they just plug into each other. The speaker (not shown) uses the speaker connection on the propmaker, and the pushbutton uses the JST connector next to the neopixel JST connector.

I've also posted the code here so you can see it all.

Code: Select all

"""LASER SWORD (pew pew) example for Adafruit Hallowing & NeoPixel strip"""
# pylint: disable=bare-except

import time
import math
import gc
from digitalio import DigitalInOut, Direction, Pull
import audioio
import audiocore
import busio
import board
import neopixel
import adafruit_lis3dh

# Added
from adafruit_debouncer import Debouncer

# CUSTOMIZE YOUR COLOR HERE:
# (red, green, blue) -- each 0 (off) to 255 (brightest)
COLOR = (255, 0, 0)  # red
# COLOR = (0, 255, 0)  # green
# COLOR = (100, 0, 255)  # purple
# COLOR = (255, 20, 147) # deeppink
# COLOR = (0, 100, 255) # cyan

# Added: Custom Color Array Setup
# array setup:
# custColor[0] = (ccr[0],ccg[0],ccb[0]) = red
# custColor[1] = (ccr[1],ccg[1],ccb[1]) = green
# custColor[2] = (ccr[2],ccg[2],ccb[2]) = blue
# custColor[3] = (ccr[3],ccg[3],ccb[3]) = purple
# custColor[4] = (ccr[4],ccg[4],ccb[4]) = deeppink
ccr = [255, 0, 0, 100, 255]
ccg = [0, 255, 0, 0, 20]
ccb = [0, 0, 255, 255, 147]
cc = 0

# CUSTOMIZE SENSITIVITY HERE: smaller numbers = more sensitive to motion
HIT_THRESHOLD = 350  # 250
SWING_THRESHOLD = 125

# Defining number of Pixels
bldLen = 1  # blade length in meters
pixPerMtr = 144  # Neopixel per meter (from mfg)
NUM_PIXELS = pixPerMtr // bldLen

# NUM_PIXELS = 114
# NUM_PIXELS = 85
NEOPIXEL_PIN = board.D5
POWER_PIN = board.D10
SWITCH_PIN = board.D9
# Added
# COLOR_PIN = board.D8

enable = DigitalInOut(POWER_PIN)
enable.direction = Direction.OUTPUT
enable.value = False

red_led = DigitalInOut(board.D11)
red_led.direction = Direction.OUTPUT
green_led = DigitalInOut(board.D12)
green_led.direction = Direction.OUTPUT
blue_led = DigitalInOut(board.D13)
blue_led.direction = Direction.OUTPUT

audio = audioio.AudioOut(board.A0)  # Speaker
mode = 0  # Initial mode = OFF

strip = neopixel.NeoPixel(NEOPIXEL_PIN, NUM_PIXELS, brightness=1, auto_write=False)
strip.fill(0)  # NeoPixels off ASAP on startup
strip.show()

switch = DigitalInOut(SWITCH_PIN)
switch.direction = Direction.INPUT
switch.pull = Pull.UP

# Added
# bldClr = DigitalInOut(COLOR_PIN)
# bldClr.direction = Direction.INPUT
# bldClr.pull = Pull.UP
# bladeColorPb = Debouncer(bldClr)

time.sleep(0.1)

# Set up accelerometer on I2C bus, 4G range:
i2c = busio.I2C(board.SCL, board.SDA)
accel = adafruit_lis3dh.LIS3DH_I2C(i2c)
accel.range = adafruit_lis3dh.RANGE_4_G

# "Idle" color is 1/4 brightness, "swinging" color is full brightness...
COLOR_IDLE = (int(COLOR[0] / 1), int(COLOR[1] / 1), int(COLOR[2] / 1))
COLOR_SWING = COLOR
COLOR_HIT = (255, 255, 255)  # "hit" color is white


def play_wav(name, loop=False):
    """
    Play a WAV file in the 'sounds' directory.
    @param name: partial file name string, complete name will be built around
                 this, e.g. passing 'foo' will play file 'sounds/foo.wav'.
    @param loop: if True, sound will repeat indefinitely (until interrupted
                 by another sound).
    """
    print("playing", name)
    try:
        wave_file = open("sounds/" + name + ".wav", "rb")
        wave = audiocore.WaveFile(wave_file)
        audio.play(wave, loop=loop)
    except:
        return


def power(sound, duration, reverse):
    """
    Animate NeoPixels with accompanying sound effect for power on / off.
    @param sound:    sound name (similar format to play_wav() above)
    @param duration: estimated duration of sound, in seconds (>0.0)
    @param reverse:  if True, do power-off effect (reverses animation)
    """
    if reverse:
        prev = NUM_PIXELS
    else:
        prev = 0
    gc.collect()  # Clean RAM so animation smooth
    start_time = time.monotonic()  # Save audio start time
    play_wav(sound)
    while True:
        elapsed = time.monotonic() - start_time  # Time spent playing sound
        if elapsed > duration:  # Past sound duration?
            break  # Stop animating
        fraction = elapsed / duration  # Animation time, 0.0 to 1.0
        if reverse:
            fraction = 1.0 - fraction  # 1.0 to 0.0 if reverse
        fraction = math.pow(fraction, 0.5)  # Apply nonlinear curve
        threshold = int(NUM_PIXELS * fraction + 0.5)
        num = threshold - prev  # Qty pixels to light on pass
        if num != 0:
            if reverse:
                strip[threshold:prev] = [0] * -num
            else:
                strip[prev:threshold] = [COLOR_IDLE] * num
            strip.show()
            # NeoPixel writes throw off time.monotonic() ever so slightly
            # because interrupts are disabled during the transfer.
            # We can compensate somewhat by adjusting the start time
            # back by 30 microseconds per pixel.
            start_time -= NUM_PIXELS * 0.00003
            prev = threshold
    if reverse:
        strip.fill(0)  # At end, ensure strip is off
    else:
        strip.fill(COLOR_IDLE)  # or all pixels set on
    strip.show()
    while audio.playing:  # Wait until audio done
        pass


def mix(color_1, color_2, weight_2):
    """
    Blend between two colors with a given ratio.
    @param color_1:  first color, as an (r,g,b) tuple
    @param color_2:  second color, as an (r,g,b) tuple
    @param weight_2: Blend weight (ratio) of second color, 0.0 to 1.0
    @return: (r,g,b) tuple, blended color
    """
    if weight_2 < 0.0:
        weight_2 = 0.0
    elif weight_2 > 1.0:
        weight_2 = 1.0
    weight_1 = 1.0 - weight_2
    return (
        int(color_1[0] * weight_1 + color_2[0] * weight_2),
        int(color_1[1] * weight_1 + color_2[1] * weight_2),
        int(color_1[2] * weight_1 + color_2[2] * weight_2),
    )


# Main program loop, repeats indefinitely
while True:
    # Added
    # bldClr.update()
    red_led.value = True

    if not switch.value:  # button pressed?
        if mode == 0:  # If currently off...
            enable.value = True
            power("on", 1.7, False)  # Power up!
            play_wav("idle", loop=True)  # Play background hum sound
            mode = 1  # ON (idle) mode now
        else:  # else is currently on...
            power("off", 1.15, True)  # Power down
            mode = 0  # OFF mode now
            enable.value = False
        while not switch.value:  # Wait for button release
            time.sleep(0.2)  # to avoid repeated triggering
    elif mode >= 1:  # If not OFF mode...
        x, y, z = accel.acceleration  # Read accelerometer
        accel_total = x * x + z * z
        # (Y axis isn't needed for this, assuming Hallowing is mounted
        # sideways to stick.  Also, square root isn't needed, since we're
        # just comparing thresholds...use squared values instead, save math.)
        if accel_total > HIT_THRESHOLD:  # Large acceleration = HIT
            TRIGGER_TIME = time.monotonic()  # Save initial time of hit
            play_wav("hit")  # Start playing 'hit' sound
            COLOR_ACTIVE = COLOR_HIT  # Set color to fade from
            mode = 3  # HIT mode
        elif mode == 1 and accel_total > SWING_THRESHOLD:  # Mild = SWING
            TRIGGER_TIME = time.monotonic()  # Save initial time of swing
            play_wav("swing")  # Start playing 'swing' sound
            COLOR_ACTIVE = COLOR_SWING  # Set color to fade from
            mode = 2  # SWING mode
        elif mode > 1:  # If in SWING or HIT mode...
            if audio.playing:  # And sound currently playing..
                blend = time.monotonic() - TRIGGER_TIME  # Time since triggered
                if mode == 2:  # If SWING,
                    blend = abs(0.5 - blend) * 2.0  # ramp up, down
                strip.fill(mix(COLOR_ACTIVE, COLOR_IDLE, blend))
                strip.show()
            else:  # No sound now, MODE > 1
                play_wav("idle", loop=True)  # Resume background hum
                strip.fill(COLOR_IDLE)  # Set to idle color
                strip.show()
                mode = 1  # IDLE mode now
    # Added
    # if bladeColorPb.fell:  # When colorchange PB pressed
        # cc += 1
        # if cc >= len(ccr):
            # cc = 0  # reset index to 0
        # COLOR = (ccr[cc], ccg[cc], ccb[cc])
Any code I have added is commented out. This was so I could see how/where it might need to build so I can plan for it, but that is once the hardware is set and the original base code works.

User avatar
dastels
 
Posts: 15662
Joined: Tue Oct 20, 2015 3:22 pm

Re: Issue with Prop Maker, M4, and NeoPixel

Post by dastels »

So, it worked and now it doesn't.
The connections look fine.

Can you try the sample code at the top of https://learn.adafruit.com/adafruit-pro ... -3015943-2, changing NUM_PIXELS appropriately.

That will test out the neopixels and the related circuitry. Assuming that works, gently wiggle the NeoPixel connections (on the strip & board connector) and see if anything odd happens.

Dave

User avatar
vader7071
 
Posts: 124
Joined: Mon Sep 11, 2017 12:45 pm

Re: Issue with Prop Maker, M4, and NeoPixel

Post by vader7071 »

Ok, so I loaded the program. Changed the 30 to 144 (the number of pixels). I started the feather, and initially nothing happened. I bumped it (not really sure where), and all the pixels came on green, and held. No change. Just solid green. Waited about 10-15 seconds, still no color change.

Then I cycled power, and tried to restart the unit again. Same thing, no change. Bumped it again, and now all of the pixels came on pink.

So to test, I went a modified the program from 144 to 72 (get an idea of how much the feather is talking to the pixels), and absolutely no response. I could not "bump" it to come on. None of the pixels came on at all.

I am powering off of the usb port. I am using either my computer usb or a 10,000mAh usb battery pack.

User avatar
dastels
 
Posts: 15662
Joined: Tue Oct 20, 2015 3:22 pm

Re: Issue with Prop Maker, M4, and NeoPixel

Post by dastels »

Hmm. That really weird. My next step would be to carefully inspect and redo all the soldered connections to fix or rule out a connection issue.

Dave

User avatar
vader7071
 
Posts: 124
Joined: Mon Sep 11, 2017 12:45 pm

Re: Issue with Prop Maker, M4, and NeoPixel

Post by vader7071 »

That will be my next step when I get back to my full soldering station.

User avatar
vader7071
 
Posts: 124
Joined: Mon Sep 11, 2017 12:45 pm

Re: Issue with Prop Maker, M4, and NeoPixel

Post by vader7071 »

So now that I am home at my full workbench, I found the issue. A trace is broken on the 1st neopixel. When I unsoldered my wires and moved them up one, the strip worked just fine.

User avatar
dastels
 
Posts: 15662
Joined: Tue Oct 20, 2015 3:22 pm

Re: Issue with Prop Maker, M4, and NeoPixel

Post by dastels »

Great! you might be able to short the broken trace with solder or a bit of wire.

Dave

Locked
Please be positive and constructive with your questions and comments.

Return to “Feather - Adafruit's lightweight platform”