• Update UDP broadcast for individual pixel control

    bveina01/12/2018 at 22:24 0 comments

    now that ive had the breakout boards populated and wired ten in a chain, i need to have some kind of test code. having more than one led means that now i want to have more than one color displayed.

    the first prototype code had 4 bytes per data-gram "RR BB GG VV" red, blue, green, intensity value. and that color would be displayed on all leds. now, ive just duplicated that project. every group of 4 is one led, therefore 10 leds should take a 40 byte data-gram. not an earth-shattering bandwidth.

    Interpreting the data was straightforward. i used a quick function to chunk the data into 4 byte arrays....thats it. everything else is the same as dealing with one led.

    from machine import Pin
    from apa102 import APA102
    import usocket
    port = 5500
    clock = Pin(14,Pin.OUT)
    data  = Pin(13,Pin.OUT)
    apa = APA102(clock,data,numPixels)
    # https://gist.github.com/SZanlongo/f9290809d1f76289d40a52af949acfbc
    def chunks(l, n):
        """Yield successive n-sized chunks from l."""
        for i in range(0, len(l), n):
            yield l[i:i + n]
    def setPixelRaw(index,r,g,b,val=31):
    def setPixelStr(index,s):
      if len(s)<3: return
      r= s[0]
      g= s[1]
      b= s[2]
      if len(s)>3: val = s[3]
    s = usocket.socket(usocket.AF_INET,usocket.SOCK_DGRAM)
    while True:
      l = t[0]
      for i,x in enumerate(chunks(l,4)):

    then i needed some cute animations. i need to clean up the code a bit but the colorsys library comes to the rescue again.

    i think with this successful test i need to lock in the dimensions of the acrylic and spin up the final base pcb.

  • Testing the breakout boards

    bveina01/11/2018 at 18:56 0 comments

    quick update!

    breakout boards are in, i got white soldermask because...reflective?...cool factor?... cool factor.

    huge shout-out to dirtypcbs who has always handled anything i threw at them no problem.

    i quickly found my first problem. the footprint is not really hand solder friendly. does anyone have any application notes or white papers on how much is enough when it comes to making hand solder-able footprints?? eagle has two different 0805 footprints one is easy to hand solder, the other is impossible. i ruined 3 breakout boards/leds then abandoned my hand iron for a solder paste dispenser and re-flow oven.

    i have a 983A solder paste dispenser and a T962A reflow oven in my lab, so i popped over and made up 40ish.

    that's where i discovered my second mistake, the footprint was upside down, the pin one marker is in the wrong spot, everything else was labeled correctly so, not a big deal.

    i was concerned about the leds surviving the reflow, they seemed very heat sensitive, any contact with a iron would destroy them, i used the default profile on my reflow oven and set out to test them.

    after paste before placement
    after reflow.

    I modified some example code to light 3 leds in a strip, two were already available from previous tests, and the first would be the device under test (DUT). i set up the bread board with some double length headers to hold the DUT.

    rom machine import Pin
    from apa102 import APA102
    import time
    clock = Pin(14, Pin.OUT)     # set GPIO14 to output to drive the clock
    data = Pin(13, Pin.OUT)      # set GPIO13 to output to drive the data
    apa = APA102(clock, data, 3) # create APA102 driver on the clock and the data pin for 8 pixels
    while True:
        apa[0] = (0, 0, 255, 31)
        apa[1]=  (0,255,0 ,31)
        apa[2]= (255,0,0,31)
        apa.write()                  # write data to all pixels
        apa[0] = (0, 0, 255, 0)
        apa[1]=  (0,255,0 ,0)
        apa[2]= (255,0,0,0)
        apa.write()                  # write data to all pixels

    Each led was friction fit onto the double length headers. if all three leds blinked i reasoned both input and output pins on the led worked well. i didn't have a single failure. 

    ill leave you with a shot of the apa102 die, not a super magnification, just interesting. next i have to wire ten of these up and set them up under the acrylic.

  • Panelizing tricks

    bveina01/05/2018 at 22:24 0 comments


    that is the size of my APA102 breakout board. (call it 13x8 mm) and with DirtyPCBs I can have 100mm x 100mm so panelization is a must. opening up GerberPanelizer by ThisIsNotRocket Science the first step is adding as many breakout boards as possible.

    i use the naive autopack feature to get a clean grid of 60 boards, now i need to add breakout tabs. thats alot of tabs lets see what the auto breaktab feature does?

    ok, that was a bit more than i anticipated. time to get creative

    i am going to place two breaktabs precisely where i want them in opposite corners and save the file.

    if focused on placing the tabs exactly in the middle between the two breakout boards and at the midpoint of the boards. this is important because any errors at this stage will propogate through the process. next open the file in notepad++. its simple xml we want to find the tabs section.

    and now this is all we need is some quick division and then copy and paste.  there are 5 spaces between columns in the x direction:

    thats all that need to be added each time. same formula for the y direction. 

    first i check the distribution across the x axis, add 5 lines

    save the file and reopen it in gerber panelzer

    i consider this a huge time savings, and it makes the tabs much more repeatable. repeat this for all the long edges and the narrow edges and we arive at the final panel and only four had to be placed manually.

    Thats it for panelizing and its been sent off to Dirty PCBs so in just a week or two  ill have 600 breakout boards. ready to prototype with.

  • prototyping with APA102 leds

    bveina01/05/2018 at 20:03 0 comments

    Up till now I've been prototyping with individual 5050 apa102 leds, and to wire them up I've co-opted some soic8 to dip8 breakout boards. that is not going to work in the long term. also as a contigency plan, if i run short on time id like a way to throw the leds into a quick laser cut 'form' and use that as part of the final piece, it will be messier, but i can hide any wires as needed, so i set about to create some easy to use apa102 breakout boards, cheaply.

    i always try to make my own footprints before trusting anything i find in eagle. 95% of the time, everything works if you use stock components, but Murphy's Law makes that 5% of the time happen every time... so off to the data sheet. Aliexpress had some mechanical drawings on it:

    ok the componenet has 1mm x 1mm contacts, then there is 4.2mm outside to outside dimensions so the center Y value would be: divide by 3 and.. no (4.3mm-3*1mm) /3 +.. <opens Skectchup> <30 seconds later>

    ok now i know where every pad is. i just need to know the recomended pcb footprint. and thats where i cant follow this datasheet, it indicates 1.5mm wide, but not where is should start nor how tall it should be. doing a quick internet search for "apa102 datasheet" yields plenty of datahsheet but not much more. "apa102 footprint" or "apa102 land pattern" dont help much more. so lacking anything more substantial ill settle for any 6 pin 5050 led.

    "5050 led land pattern" on image search hits paydirt

    will this work with my APA102s? lets just remake this in sketchup too.

    And it was at that point im reminded of a recent hackaday article "terrible dimensioned drawings" but that being said, im going to use it anyway. the error shown is 0.15mm and all the dimesions  listed for the led contacts are +/- 0.1mm. like homer said "close enough."

    onto eagle, very basic.

    nothing to write home about here
    extra tracks and soldermask stop for easy soldering

    the only hacky thing i dis here was add giant traces on the bottom so i could solder wires invisibly and chain multiple wires together the bStop layer will stop soldermask from being put down.  after checking the gerbers in gerbv, i set about to panelize the boards.

    and, since i did something beyond just running ThisIsNotRocketScience's Gerber Panelizer ill stop this post here.

    preview of next time:

  • Distributed Wireless attempt #1

    bveina01/05/2018 at 04:48 0 comments

    since there will be many centerpieces and i want them to be syncronized in whatever they are doing i was originally thinking of a RFM69 module running some kind of mesh network. i got some from my favorite chinese superstore, and played with them for roughly an hour and decided that would be kinda a pain in the a**. instead i turned to a slightly less energy efficient item the ESP8266. 

    In short it uses a bit more current, but take on the role of both processor and wireless tranceiver, plus python. its the path of least resistance for me. so i took the wireless "strip" i created several entries ago and hooked it up to some nodeMCU modules i had lying about.

    i use the built in python binding for the apa102 and connect the CLKIN line to GPIO14 and the DATAIN line to GPIO 13.

    technically i should use a level converter, but at the prototype stage it works okay. so ill leave it for future me to sort out.

    and thats the hardware completed for this post.

    The software

    ive decided to try using UDP broadcasts for this project, it will syncronize within the latency of the network, and that is negligible on the timescales im working with. ill have to build up a protocol layer on top on UDP but i dont need to worry about reliable communications since i can accept a certain amount of frame loss in the transmission.

    for a test program ive decided to transmit a 3 byte datagram in RGB order. when a node receives the datagram it will set all leds to the transmitted color.

    Receiver code:

    im currently running micropython, but i may switch to circuit python at some point if i run into any problems.

    from machine import Pin
    from apa102 import APA102
    import usocket
    port = 5500
    clock = Pin(14,Pin.OUT)
    data  = Pin(13,Pin.OUT)
    apa = APA102(clock,data,numPixels)
    def setPixelRaw(index,r,g,b,val=31):
    def setPixelStr(index,s):
      if len(s)<3: return
      r= s[0]
      g= s[1]
      b= s[2]
      if len(s)>3: val = s[3]
    s = usocket.socket(usocket.AF_INET,usocket.SOCK_DGRAM)
    while True:

     that is it for now, in the future id like to be able to send different rgb values for different pixels. but seeing as how i only have two leds wired up at the moment this will do to test the wireless aspects.

    Transmitter code

    The transmitter code currently runs on my laptop. on a full python2.7 interface. this is likely how the final version will run; a full python interface, not my laptop, maybe a Raspi or Beaglebone.

    Using the full python interface simplifys the HSV to RGB conversion significantly, "import colorsys" does it all. <insert XKCD comic here>

    the only special part of this code is the socket option SO_REUSEADDR for broadcasting to the local subnet.

    import socket
    import binascii
    import colorsys
    import time
    udpIP = ''
    udpPort = 5500
    color = "7f3f1f"
    message = binascii.unhexlify(color)
    sock = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
    sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    while True:
      for i in range(256):
        (r,g,b) = colorsys.hsv_to_rgb(i/256.0,1,1)
        message = chr(int(r))+chr(int(g))+chr(int(b))

    now to focus on having more LEDs to play with...

  • Using fusion360 cad for a chinese laser cutter

    bveina01/05/2018 at 03:20 0 comments

      Last post wrangled fusion 360 into creating some acrylic pieces, but getting these pieces fabbed is a different challenge.  

      the design is intentionally split into just 4 components duplicated multiple times.

      1. inner vertical
      2. outer vertical
      3. center holder
      4. middle holder
      red lines show interface to other pieces.

      now i needed to get these to my laser cutter. a Chinese import 300x500 with an Rudia controller. 

      RD6446g controller
      I put a lot of work into cleaning this import up. its a nice shot. not strictly needed.

      The software on these machines is notoriously ... not great ... but ive gotten used to it at this point. all i need is a dxf file to send to the software and ill be happy at this point.

      so, fusion360 can do this pretty quick!

      the cam tool can work with laser cutters and with an extra plugin, written by autodesk, it can make dxf files.

      so im going to create 4 different "setups" one for each of the pieces i need to cut.

      for the vertical pieces, i need to tell fusion to perform two separate cutting operations.

      notice the cam has accounted for the laser kerf

      notice the cam has accounted for the laser kerf

      only one piece threw me on this part. on the outer cut, notice the green lines coming from the start and stop points? that's called lead-in in fusion 360. if you have tiny holes, you need to turn this off otherwise the cam processor can't make it work. so, thats a thing...

      Also for the DXF export it is important to choose the correct kerf compensation selection. you want to choose Left compensation and "in computer" the dxf post processor cant handle the "in controller" option.

      as ive been designing this model ive forgotten my laser cutter kerf, but thats ok i can change one parameter and the cam processor will compensate. 

      since i was trying to test construction methods with this prototype i set the parameters to relatively small. after running the post processor and importing into RDworks I've sent it to the laser cutter.

      and assembled.

      this version went together SO much better. also, as an added bonus, the center has been filled with 4.5mm rhinestones, for that extra sparkle.

      i hope the next post will talk about the wireless transmission aspect.

  • Second acrylic prototype (learning fusion360)

    bveina01/04/2018 at 21:25 0 comments

      well this took alot longer than i thought.

      i had set out to make a second revision of the acrylic that would adorn the circuit board, but the cad cam process just took to long. 

      1. design everything in 3d in sketchup
      2. copy every 2d face, and reorient them to be planer.
      3. use a sketchup plugin to export the faces to svg format.
      4. import the svg into corel (importing straight into rd works causes problems...)
      5. export that to RDworks, the cam program for my laser cutter.
      6. colorize the layers and finally export them to a *.RD file on a flash drive
      7. carry flash drive to laser cutter, load and go.

      steps 2 through 6 took several hours. once was enough. i thought, there must be an easier way, so i embarked on a journey to learn fusion 360. four days later and a lot of head banging later, i emerged with a pretty good handle on fusion 360 and a workable parametric model of my centerpiece.

      This project was just complex enough for me to really have to get into the details of this cad program. 

      The Base

      the base of the model shows the PCB and the outlines of where the acrylic will eventually go. and everything on it starts with a sketch. 

      just about everything has been made a user parameter. ive placed two inscribed polygons centered on the origin, the side length of both has been set to user parameters (in the image above 55mm and 27 mm). ive also placed points where bolts and leds will eventually end up. that is for this sketch.

      next i designed a quick bolt and led to nominal dimensions.

      no i did not put threads on the nut....

      The rotate operation

      this one operation is the focus of the entire model.

      first i place a bolt and two leds for one panel. they are locked to the points on the parametric sketch i made for the base.

      then grab the bolts and leds and rotate!

      now its time to build up the acrylic

      The Acrylic

      back to the drawing board...well actually back to the sketch. fusion360 keeps everything you ever do and the order you do it in (this will become important in a minute). we make a new sketch with two rectangles. they are linked to the pentagons in the base sketch.

      we can use the same user parameters we have used before for the side lengths. i also cut off a bit from each corner so the acrylic doesn't overlap. then extrude!

      now i COULD just repeat the same rotate operation i used for the bolts, BUT a better option would be to TIME TRAVEL!!!!! 

      Time Travel (The Fusion 360 timeline)

      i did mention that fusion 360 stores everything you ever do and when you do it,  what i didnt mention is that you can go back in time and modify little parts of what you did in the past. you can even take some things that you did in the future and bring them past.

      so to simplify my life (and trust me, it does simplify things) i dragged the sketch and extrude operations before the rotate operations as shown above. Then, i edited the rotate feature to include the acrylic. then i warped forward in time, everything is redone in order.

      we will need something to bolt the acrylic together however. add another sketch.

      in none of these sketches do i worry about kerf whatsoever. this would result in very loose fitting parts but i will be dealing with the kerf in a later stage. based on the two holders i made i used joint offsets to palace them centered on the circuit board at fixed heights.

      now i add in the modifications to allow these pieces to fit together by adding a sketch to the extruded face of the acrylic.

      all of the dimensions come from user parameters. then i do another extrude THROUGH the existing acrylic and cut holes for the tabs,bolts,and leds. Also, since i moved the sketch back in time to before the rotate operation all of the cuts propagated through.

      this post has gone on pretty long at this point. ill cover laser cutting this design in another post.

  • first blinky lights.

    bveina01/04/2018 at 20:30 0 comments

    by this point i already had already sent out for a small reel of APA102 addressable leds. my eventual plan is to populate a custom board that will bolt to the acrylic panels. but for now i need to prototype with them. i tried hand soldering some wires, that failed...miserably... I didn't even take photos. i also didnt have any breakout boards for the 6 pin apa102s. but, the 8 pin soic breakouts i made for other things was close enough. 

    apa102 6 pin to SOIC 8 pin
    meh... close enough

    i wired up two together and got down to the business of making a simple hue fader. now, here is where i fell down the rabbit hole. APA102s use RGB to control color, and i wanted Hue, Saturation, Value (HSV). the math to do this isnt particularly complicated, but doing it on an 8 bit processor (like the atmega328p) can be a bit time consuming. 

    ill save you the rabbit hole: http://www.vagrearg.org/content/hsvrgb has a great write up of the fastest way to get from one to the other. including Open Source code for the atmega328p.

    for this first step though a simple modification to the strandTest arduino library from adafruit was enough.

    #include <Arduino.h>
    #include <Adafruit_DotStar.h>
    #define NUMPIXELS 2 // Number of LEDs in strip
    bool showing;
    void setup() {
       uint8_t rgb[3];
       uint8_t val;
       //volatile to force debugger to cache the value.
       volatile uint16_t top,x; 
      strip.begin(); // Initialize pins for output
      strip.show();  // Turn all LEDs off ASAP
      for (int i=0;i<NUMPIXELS;i++) strip.setPixelColor(i,0);
      rgb[0]=0x00; // red
      rgb[1]=0xff; // green
      rgb[2]=0x00; // blue
          if (rgb[x]==top)
              //if counting up, now count down.
              if (val==1) { val=-1; top=0; }
              else        { val=1;  top=255;}
              // and modify the next primary color
              if (x==0) x=2;
              else x=x-1;
          // change the RGB order to get an out of phase hue.
    void loop() {

    the code replicates the following RGB values.

    Hue vs RGB

    the acrylic from the last post was hand filed to sit on the leds and that led to:

    onto the next acrylic revision.

  • First laser cut prototype

    bveina01/04/2018 at 20:02 0 comments

    disclaimer: some of these posts are describing things that have already happened. im post documenting alot of things since i think this is a cool project that uses alot of different skills.

    Im a person who really likes to see/touch what im building so the prototype was quick and dirty, i made some basic tabbed panels in sketchup:

    at this point i wasnt worried about kerf, or fit, i just wanted a basic model i could show off to people and get feedback. i also needed to keep everything together, i decided on a captive nut approach and created one piece to hold the inner spire together, another to hold the outer spire together, and for now i just laser cut a base.to bolt everything together.

    there were some pretty flimsy joints in this setup, especially in the larger pentagon. i didn't have enough room to bolt in the center or bolt on both sides, but offsetting the bolt worked well enough. until, it didn't.

    it worked well enough for a proof of concept but barely. i used M3 nylon nuts and bolts that you can get from the usual sources (aliexpress, amazon, mcmaster). but i have a major redesign before i can get anything more done on the acrylic. it was a bear to get this together at all. next time, blinky lights!

  • Statement of purpose

    bveina01/04/2018 at 19:09 0 comments

    I am getting married. now among other things we need centerpieces for the reception. I have a basic idea of what i want, a clear acrylic spire between 6-10 inches tall, under lit with RGB leds. they should blink in time with the band, its an 80's band. yes this is going to be awesome. i did a quick render in sketchup to refine the concept. at a minimum im looking at 100mm circular circuit boards with addressable leds, some kind of wireless modules so they can all stay in sync, and batteries, im leaning towards 2 18650 cells, then lots of laser cut acrylic.

    in the rendering ive added a block for the batteries under the circuit board, and added a ring around the entire thing, succulents will be placed around the entire thing. next time i hope to have some acrylic cut.