Monthly Archives: April 2015

CNC board and USB microscope

While in China I picked up a USB microscope for $25 USD. It’s an “2MP HD microscope with 600x magnification” according to the box and has 6 LEDs around the camera. I plugged it in and it was found right away by Linux as a video4linux device and works with VLC and Cheese. It’s been sitting next to my computer for about 2 weeks since I got back from China and I’ve been itching for some reason to use it. Tonight I made a small board on my CNC to test some new footprints and I thought it would be the perfect time to use the microscope to check out the cuts made by the bit. Using Cheese I was able to get some good shots of the PCB traces. The pictures are only 640×480, so I’m not too sure where the 2MP claim comes from.

I used my gcode_03 ULP script for Eagle (from my older site) to export the PCB to G-code. When I started working with the CNC for PCB routing I was using a 0.8mm end mill carbide bit, however I’ve noticed I get pretty clean cuts with a 30 degree “V” etching bit run at the max speed of my manually controlled spindle (Yes I know I need to find out the RPMs of that thing). The cuts made by the CNC are impressively clean and without burs. Each cut goes down 0.16 inches and the feed rate is 300mm/minute. The footprint is SOIC-8, the pads are 1.27mm x 0.635mm and the traces are 20mil. The cut is close to 0.5mm. The microscope did show what looks like copper particles in the track which was interesting to see. I’ve made a bunch of breakout boards and switch boards without shorting issues so I don’t know if these particles are big enough to cause a problem. Here are some pictures of the board using the microscope.

microscope image of board compared to a dime microscope image of the board microscope image zoomed in on traces

microscope image of cnc cut - two traces microscope image of cnc corner cut microscope image of cnc particles microscope view of SOIC-8 chip on pad

LED light strip LPD6803 code

Wow, it’s been a crazy few months. I am taking some courses for my masters, started a few contracting gigs and went to China with DangerousPrototypes Hacker Camp. There is so much to write about and I’ve been dropping the ball on Protological. Time to change that. Time for some cool LED stuff!

While in China I picked up a 5 meter “5050” 12V LED strip with 30 LEDs per meter for 90RMB which is $14.50 USD. I didn’t buy the controller because I wanted to control it with a microcontroller of course! The controller chip is a knockoff LPD6803 LED driver chip that listens for clocked data. The only datasheet I could find was from Adafruit here and the english is really, really bad. I didn’t know ‘grey’ == ‘color’?! After some playing around I figured out the protocol for how the data is sent. The commands are 16-bit and shifted out MSB first, the clock is idle low and the data is latched in on the high transition of the clock. The MSB is always 1 to indicate that the value is data and the 3 colors are 5 bits each; allowing for 31 steps in brightness.

1000 0000 0000 0000

One would think that the colors are Red, Green and Blue, however some testing showed they are Green, Red and Blue.

1000 0000 0000 0000
D|Grn ||Red ||Blue|

So if you want to turn on an LED with 1 step of RGB the byte value is 1 00001 00001 00001 = 1000 0100 0010 0001 = 0x8421;

These strips can be chained together, so to ‘reset’ the strip pixel ID and have it listen for a new set of colors you send 32 0’s which is 8 bytes of 0x00. Once I got the protocol figured out it was really easy to hook up a micro and control the strip.

I used an LPC1768 Mbed microcontroller (because it’s super easy) and made a demo program with some simple animations. The strip is 30 LEDs per meter, 5 meters long. Each LED ‘pixel’ is a group of 3 RGB LEDs and they all show the same color. So there are 50 groups of 3 in my 5 meter strip. The way I drive the LEDs is I make a uint16_t array in RAM for the 50 pixels, then create a timer to run through the array and send it out to the strip using the SPI hardware. With 8 bytes of reset, 100 bytes of data, at 500KHz I was able to address the whole strip in about 4ms. I set my timer to update the strip at 10ms, giving me a 100Hz refresh rate.

The rest of the application just writes the data array in memory and lets the timer clock it out to the strip. I included the code here with 4 demos. This will build in the Mbed compiler and uses the P5 & P6 SPI pins on the LPC1768 for data and clock. It should be pretty straight forward to port to an Arduino or other microcontroller, just setup a timer and update the SPI config and write functions.

Here is a video of the demos in action:

And the source file: ledstrip_mbed_demo.cpp

Enjoy, Drew