Category: Uncategorized

Lasering Beautiful LED Panels

There’s always been one piece of product design that I adored, but never was able to quite pull off. Until now.

What am I talking about? LED panels of course! Those panels with translucent icons that are individually illuminated by LEDs. This:


Cool, huh?

So how does one go about making such a panel?

Step 1: Spray paint High Heat paint ( I used this - uniformly on a piece of clear plexiglas. Let it dry.



Side Note: do not use regular spray paint. It will come out terrible, like this:



Step 2: Laser the panel! Using a laser cutter, etch off whatever areas you want to be translucent. This means your icons, any borders, etc. You’ll want to use the rasterize setting on your laser cutter. Be sure to set the laser to lower power; you don’t want to cut through, you just want to etch off the top layer of paint. lasering_inprogress

Step 3: Admire your work!


AeroQuad Fixes

A few weeks ago I got my hands on an AeroQuad Typhoon quadcopter kit. I quickly built it, was all set to fly…. and it crashed. A lot of times. I also cut my fingers pretty bad one night trying to debug it. I had to tether the thing because it was so out of control.



But today I finally got it flying!


What was the issue?

Incorrect board orientation, motor wiring, and calibration.

Incorrect Flight Controller Orientation

By default the AeroQuad flight controller board comes loaded with AeroQuad X configuration. What does this mean? It means the following:

Notice which way is considered the quadcopters “front”. The blue arrow shows the direction, its the side with USB sticking out of. The front direction arrow also lines up with the X axis arrow on the AQ32 board.


Be sure to Calibrate your accelerometer using the correct “front” direction. If accelerometer calibration is done incorrectly – your copter will crash! After assembling your quadcopter, it might be convenient to make a big arrow so you can quickly see where the copter’s “front” is.

Propeller Placement

Also, pay attention to how the propellers are placed. Motors 1 and 3 use the “P” type propeller ( look at the text on the propeller, you’ll see 4.7P), while Motors 2 and 4 use the regular propeller(just 4.7 on the text) . Propellers should be placed with text facing the sky.

Reversing Motor Rotation

If your motors are spinning the wrong way ( clockwise instead of counter clockwise), switch any two wires of that motors ESC. That will cause it to spin the other way.


Good luck! See you in the skies.

Also, I like to put the battery underneath the quadcopter, that seems to make it a little bit more stable.

Christmas Hiking in Hudson Highlands Park

Two days ago, two friends and I went hiking in our usual area – the Breakneck Ridge area in Hudson Highlands park. Even though in the city the ground was dry, up in the mountains there was already a layer of snow on the ground.

While the low temperatures were terrible for our extremities, the snow revealed animal tracks that made hiking through the area even more fun. The tracks became extremely useful towards the end of our hike, when it got too dark to see trail markers but not too dark to track previous hikers’ footprints in the snow.

Anyways, enough talk, here are some pictures (and a panorama!).



Interfacing NRF24L01+ to Sparkfun’s Nordic Serial Interface


For a project I’m working on, I needed a low power , low cost, low range, wireless radio. I needed to transmit data wirelessly from my custom AVR board to my computer.


After some research I stumbled on to these lovely modules:

They’re great. Low cost and extremely low power consumption for both Rx and Tx  - less than 15mA.

I promptly bought a couple of modules as well as two Nordic Serial Interface boards.    NRF24L01+ Board  Nordic Serial Interface

Right out of the box, I began by plugging in the radio modules into the Serial Interface boards and plugging in my Serial Interface boards into two USB ports on my computer. I was able to wireless communicate between boards using a serial terminal, right away. (9600 Baud Serial on the Nordic Serial Interface Boards).

Electrical Wiring

Next up, I needed to connect one NRF24L01+ board to my 8 bit AVR microcontroller and have that communicate wirelessly with an NRF24L01+ board connected to my computer ( via the Nordic Serial Interface).

I wired up the board quickly, using every pin besides the IRQ pin ( an interrupt pin).


Afterwards, I found this fantastic AVR C library for interfacing the radio online:

Then I downloaded the Nordic Serial Interface board’s firmware from Sparkfun’s site:

Modifying Firmware

Its important  to make sure that all radios communicating to each other have the same radio settings. If one radio uses auto-acknowledge, the other radio better be using auto-ack too. After analyzing the code and referring to the datasheet, I was able to distinguish what radio settings the Serial Interface board used.

Then I went about modifying the AVR C library I found, so that it had matching settings to Sparkfun’s Nordic Serial Interface.

Sparkfun uses a 4 byte payload, no Auto-Ack, and CRC enabled. I kept everything as is, just changing the pin definitions for the SPI interface, for CE, and for CSN.

I just changed one line definition and rewrote one subroutine.

In mirf.h :

#define mirf_PAYLOAD 4 //payload length should be 4 to work with Sparkfun Interface Board

In mirf.c :

void mirf_config() {

mirf_CE_lo; // go into standby mode

mirf_write_register(CONFIG,0x7C); //16 bit CRC enabled, be a transmitter

mirf_write_register(EN_AA,0×00); // disable auto ack on all pipes

mirf_write_register(SETUP_RETR,0×00); // disable auto-retransmit

mirf_write_register(SETUP_AW,0×03);  //Set address width to 5bytes (default, not really needed)

mirf_write_register(RF_SETUP,0×07); // Air data rate 1Mbit, 0dbm, Setup LNA

mirf_write_register(RF_CH,0×02); // RF channel 2 ( default)

mirf_write_register(CONFIG,0x7A); // power up and be a transmitter

mirf_setTX; // tx mode


And voila, communication works!

In the future, I’m going to play around with Auto Acknowledge and some of the other protocols that this radio chipset can handle. Furthermore, I’m going to increase packet size to 32 bytes (the maximum) because my application uses a lot of bandwidth.


Using Winbond’s Serial Flash Memory

Today, for a project, I had to figure out how to use a Winbond Serial Flash Memory chip. It looked pretty simple at first: 16MB of memory , SPI interface, 3V3 level. But, it was my first time using an external Flash memory and of course I made a few mistakes along the way.All in all, it took me a few hours worth of playing around to figure out how to use it just right.

Here are the problems I ran into and their solutions:

1. Problem: Unreliable response to my command for requesting version( Send out 0×90, Receive two bytes with version info)

Solution: Immediately I realized this was a SPI system issue. Originally, I was on Mode 1 SPI( CPOL=0, CPHA=1) settings on my AVR microcontroller. Changing to Mode 0 SPI(CPOL=0, CPHA=0) or Mode 3 SPI (CPOL=1, CPHA=1) fixed this.

2. Problem: Overwriting data using the Program Page command didn’t work. For example, if I wrote 0×33, 0×34 , 0×35 originally and wanted to overwrite with 0×33, 0×45, 0×46 – I would read back 0×33, 0×00 , 0×00 . I would see zeros by any bytes that would be overwritten  Bytes that were identical kept their value.

Solution: You have to clear that sector memory before you overwrite it. Programming only works when you are overwriting 0xFF(which is the value after a Sector Erase, Block Erase, or Chip Erase). Sector Erase is the smallest erase I’ve founded at 4k bytes erase so that means its also the quickest. Chip erase clears the entire chip ( duh) and it can take 30 seconds or more.

Hiking and Running in Israel – Ein Gedi and Masada

Its been a while since my last post, and a very hectic time indeed.

This past October, my family offered me a plane ticket to join them on a trip to Israel. I snapped at it and went, despite technically having classes during the trip.

Its a beautiful country, with mountains and trails that will make an experienced hiker blush. The views are outstanding and the wildlife is like nothing I’ve ever seen on New York hikes. However, its hot. Really damn hot, like 90 to 100 degrees hot.

My first hike was a rather simple one but a beautiful one. It was at Ein Gedi, sort of a nature preserve near the Dead Sea. It has some Biblical background too, King David is believed to have hid form King Shaul at Ein Gedi. What’s unique about Ein Gedi is that it is an “ein” ( a spring) in a desert. Surrounding Ein Gedi is desert sand and sun boiled stones, but within are waterfalls and streams. Really beautiful.

Before the trip I got a tip from someone that there is a more advanced trail there. While on the return path from David’s Waterfall, keep an eye out for a path that goes right. Of course, not one to back down from a challenge, we took the trail up. Its moderate, nothing too crazy, but definitely fun. You get stunning views of the Dead Sea and even get to see the remains of an old Jewish temple.

Later that day, with my brother, I trail ran Masada’s Snake Path. Masada is a very high plateau in Israel where there used to be a town. The town was once under siege by the Romans, and instead of turning over their children, wives, and themselves to the Romans, the citizens committed mass suicide. Physically, the Snake Path extends about 5 miles if it were to be extended horizontally and is very very steep. Most people take the two minute long cable car ride up. You can notice the cablecar wires in my pictures below.

In all it took us a little under 30 minutes to complete the Snake Path. We paused once or twice along the way, out of sheer heat exhaustion, but we made it. We were absolutely soaked in sweat, with a stream of sweat searing our eyes. It was one of the most intense runs of my life.  The elevation climb and distance were challenging but the 100 degree heat just amplified the challenge. And this was AFTER another hike that same day.

All in all, I’m extraordinarily happy that I ran Masada. It was a great challenge and it really pushed my physical and mental limits.

Have you tested your limits lately?

Memcached Cross Platform – Perl and Python

So tonight I had to implement variable sharing between a Perl and Python script. Easy, right? Just use memcached.

Well, it was easy to setup… but not so easy to implement. I installed Python and Perl memcached modules the regular old ways ( you can google this yourself). Sharing worked perfectly between two Python programs and between two Perl programs, but not between Python and Perl.

So I telnetted in to the Memcached server and did some research.

telnet localhost 11211

get test

The results were interesting. When the variable was set with Python:

VALUE test 2 2

Whereas Perl it was set as:

VALUE test 0 2

Notice the difference in the third word – Python has a 2, Perl has a 0. This is a flag thats set, and in order to have communication you need to be able to read the flag.

How to fix this? Easy, hack the Python library to override the flags.  Find your memcache library location by doing  import memcache; print memcache;    That will print out the location. Mine was /usr/lib/python2.7/dist-packages

Now edit this line in ( you may need to sudo):

Change that line to _FLAG_INTEGER = 0<<1

That overrides the flag to 0. You can go ahead and override any of the other flags too, just replace the leftmost one by 0 ( or even the entire bit shift command , e.g. replace 2<<1 with just 0 ).

Enjoy your coding!



Interrupt Alerts on the LSM303DLHC

Some useful bit of info that the web should have.

I was having trouble setting up the LSM303DLHC accelerometer/compass chip for interrupt alerts. I sent over asking for some guidance from  ST and got a really useful, informative reply.

Their reply:

Thanks for your interest in STMicroelectronics MEMS products.

To generate an interrupt when one movement in one of the six directions is detected you have to set the following registers in the following way:
INT1_CFG_A -> 0xFF

Then you can set threshold and duration through INT1_THS_A and INT1_DURATION_A register.
The LSB value in the INT1_THS_A register is the following:
if FS = 2 about 16mg
if FS = 4 about 31mg
if FS = 8 about 63mg
The interrupt duration is calculate as N/ODR where N is the content of INT1_DURATION_A.

Thanks ST!

Remembering my First Animatronic Robot and MP3 Embedded Commands

I just got this video in an email - . Freddy is an animatronic robot I built for a client about 3 or 4 years ago, one of my first, and he still performs live at shows (in Hong Kong mostly). Here’s an older video I have that shows off  his personality better -

Whats really cool about Freddy is that he’s controlled entirely by an MP3 file that has the movements embedded in the song – this way his actions are always perfectly synced to the music.

So how do you actually go about syncing the movements? Specifically, how?

These are questions I was faced with when I first attempted this project as a 15 year old . The solution is clever, yet simple. MP3 files as we know them are two channels, one channel Left Ear and one channel Right Ear. What my solution does is use one of the channels for data and the other for the music.

Using any audio editor you can then sync data to music easily. Just put commands in at the same moment as some music is playing, and voila perfect syncing every time.

But what are the commands? How do you store a command?

DTMF tones. The same tones that you phones play when you push the number buttons. Thats the easy way ( MIDI being slightly more complicated but better way). Right channel has the music, and the left channel has DTMF tones at the identical moment.

There are a wide array of DTMF decoder chips out there. Essentially you just hook up a decoder to your microcontroller, connect your left ear channel (for data) to the decoder, and done. Your microcontroller will then read commands from the decoder  and then interpret that as needed to do whatever actions you prescribe. Perfect syncing all the time, and all commands are programmed in the MP3 file itself, so you just need an audio connector and an iPod. Want to change the actions for a song or add another? No need to reprogram a microcontroller, just change the tones in the audio file.



Fake It Till You Make It

On one hike this season,  I ended up leading my group very off trail. NY trails aren’t so very well marked, and its easy to veer off the main trail onto old, unmaintained trail. We accidentally ended up on such a trail, but only realized it about 15 minutes into the trail. The trail was extremely overgrown and it became apparent that this was not where we were supposed to be going.

Its always annoying to get lost, but it was worth it! On our little trek off the beaten path, we bumped into a lovely snake having lunch. It was a black racer eating some sort of small lizard. Black racers are very common in Upstate New York and are not poisonous. We watched the snake devour its prey and got a little bit closer to get a good look.

The snake then did the most surprising thing. It rattled its tail! I stood there completely shocked, this clearly wasn’t a rattlesnake and I began to reconsider whether this was indeed a nonvenomous black racer. My friend with me knew much better than me, she quickly pointed out that this is a common snake behavior. Snakes will imitate rattlesnakes ( which are venomous) to scare off predators. They don’t have little rattles on their tails, so they’ll just flick their tails back and forth on leaves to simulate the sound of a rattle. Brilliant!  The ingenuity of Nature at its best.