Tuesday, July 27, 2010

Liquidware Sensors Review


Liquidware, the same folks who brought us the Open Source Hardware Bank have come out with a new line of sensor breakout boards that are worth taking a look at, especially if you are into Arduinos. Several factors distinguish the Liquidware boards from the others that are available.

They are targeted for Arduino. You can, of course, use them with any suitable micro controller out there, but they make it really quick and easy to get the sensors up and running on Arduino. Each sensor has a cheat sheet divided into three sections: "Learn," that describes the basic principles of the sensor; "Connect," that tells you how to connect the sensor to an Arduino, and "Code," that shows a minimal example of how to read data off the sensor. With these cheats, I was able to get the 3-axis accel and the ambiant light sensor up and running within 5 minutes (and to think that I had been putting this off for a month for lack of time).

I think these guys are on the right track here with these sensors. One improvement I might suggest, is to go beyond the basics on the cheat sheet. I think this could be accomplished by shrinking the font a bit and adding a column named "More" or something like that. This column would explain the full funtionality of the device. On the accel for instance, it'd definitely be a plus up to have a table for the G1 and G2 pins that affect the sensitivity of the unit. If done correctly, the new sheet will not frighten beginners, but will be more useful to the pros.

I've used a similar breakout board for the accelerometer (MMA7260QT) from Pololu, which cost about five bucks less. If you go this route, you might need a little more time getting up to speed.

Bottom Line:
If you are a seasoned pro, of course you will not NEED these hints, but even so, they will probably end up saving you some time getting things going.

If your new to electronics, these sensors can increase your chances of success using sophisticated sensors.

Sunday, June 13, 2010

The days of the week (or how to pretend like you are a savant)

Being able to tell what day of the week a date like October 28, 2012, will fall on seems like an impressive feet of computation. It is actually quite simple if you can memorize a few numbers.

My younger daughter Elizabeth and I have made a system whose only mental calculation is the addition of three numbers, all of which are less than seven. The sum of the three numbers indicates the day of the week. Sunday = 0, Monday = 1, and so on up to Saturday = 6. To complete the "savant" effect, say things like "Oh, that one is kinda bumpy so it is a Wednesday," or "Friday, it's blue and cold, definitely a Friday." If you decide to give it a go, be sure to try out my days of the week quiz program in the previous post to test yourself.



All of this math, takes place in the group of integers modulo 7, which simply means that we only care about the remainder of the number after dividing by 7. In this group, 8 and 1 are "equivalent" since 1 / 7 = 0 remainder 1, and 8 / 7 = 1 remainder 1. They both have the same remainder of one, after dividing by 7 so they are "equivalent" for our purposes. This boils down to the fact the we care ONLY about the day of the week, not how many weeks have passed or will pass between now and then. So we throw out the quotient and keep the remainder. To indicate that the computations are specific to integers modulo 7, "mod 7" is appended to each line. Here are some example calculations in this arithmetic:


0 + 0 = 0 mod 7
1 + 1 = 2 mod 7
4 + 3 = 0 mod 7
6 + 6 = 5 mod 7.


Try a few on your own:
3 + 3 = ? mod 7
5 + 2 = ? mod 7


Sometimes it is convenient to represent 6 as -1 mod 7. Since they share the same remainder after dividing by 7. With this in mind 6 + 6 = -1 + -1 mod 7 = -2 mod 7. Likewise -2 = 5 mod 7 and so on.

Each day, month, and year gets assigned an integer modulo 7. For instance in the carefully chosen example above:
October = > 0
28 = > 0
2012 = > 0,
so October 28, 2012 falls on a Sunday (0 + 0 + 0 = 0 mod 7).



So the arithmetic is simple. The tricky part is memorizing the number assignments for the months and years. Let's make it simple by only considering dates in the current year (2010) and focus on the months and day assignments. The year 2010 gets assigned a 4 (we will talk about why later).


The day assignments are the easiest: just take the day number modulo 7. The 15th of the month gets a 1 for instance since 15 = 1 mod 7.


The month assignments, in row order are:


Jan:0 Feb:3 Mar:3
Apr:6 May:1 Jun:4
Jul:6 Aug:2 Sep:5
Oct:0 Nov:3 Dec:5


or leaving off the month names for compactness:
0 3 3
6 1 4
6 2 4
0 3 5


In this system, this block of 12 numbers must be memorized backwards and forwards, by rows and by columns, inside, outside and upside-down. Some months are easier for me to remember than others:
January is a 0 (it starts everything off)
March is a 3 (third month of the year)
May is a 1 (May Day falls on May 1)
October is a 0 (The big O in October looks like a zero).


The others just need to be memorized. It's not actually that bad, but if you think of a good mnemonic, let me know.


A brief note on how the month assignments are made. January gets assigned a 0 to start things off. This is somewhat an arbitrary choice, but if you change it, you will also have to change the year assignments. Since January has 31 days and 31 = 3 mod 7, the first of Feb is three days of the week offset from the first of January, thus February gets assigned a 3. February has 28 days (exactly 4 weeks) most years so March 1st will fall on the same day as February 1st most years. Thus, we assign a 3 to March. March has 31 days which makes April 3 days offset from March (which was already 3 days offset from January 1st) , so April gets assigned a 6 (3 + 3 = 6 mod 7). Carry this process forward to compute the assignments for the other months.


With this in hand, you can compute any day of the week for the year 2010:
Oct 14, 2010 = > 0 + 0 + 4 = 4 mod 7, a Thursday
Mar 10, 2010 = > 3 + 3 + 4 = 3 mod 7, a Wednesday
July 4, 2010 = > 6 + 4 + 4 = 0 mod 7, a Sunday
...


Now to tackle the year assignments. Be sure to get really fast for the current year before you go any further.


For reasons that might become clear later, the year assignment is the day of the week that March 4th falls on. March 4, 2010, happens to be a Thursday, so 2010 is a 4. Using a calendar we get the following assignments for some nearby years:


2007 = > 0
2008 = > 2
2009 = > 3
2010 = > 4
2011 = > 5
2012 = > 0
2013 = > 1
2014 = > 2


Observe that the years go up by one whenever the year is NOT a leap year. For a leap year the assignments are 2 larger than the previous year. This makes since since 365 = 1 mod 7 for a normal year, and 366 = 2 mod 7 for a leap year. Zero years are thus convenient milestones to anchor the assignments for neighboring years. Elizabeth and I have dubbed a zero assigned year, like 2007, as a zear.


Every 28 years a zear falls on a leap year like 2012. These special years get a special name in this system. When a zear is also a leap year, it is refferred to as a le-zear pronounced "le" as in French with great flourish and accent on the second syllable: le-Zear!


Leap years require additional caution (Elizabeth always gets me on this!). If the date of interest is is in January or February of a leap year, subtract 1 from the count. Example:
January 25, 2012 = > 0 + 4 + 0 = 4 mod 7 - 1 = 3 Mod 7, a Wednesday.


Additional hints:
Within 100 years of 2000, the year assignments repeat every 28 years so 1970 gets the same assignment as 1998. This pattern is broken by the following fact.
1900 is NOT a leap year. Every one hundred years we skip a leap year, unless the year is divisible by 400.



Friday, May 28, 2010

Days of the week.

I while back I wrote a day-of-the-week quiz program.  Now for the life of me I can't find it.  I re-wrote it.  Here it is.  Get good at it and amaze your friends.

Monday, May 24, 2010

ADXL345 Arduino Driver II

I found a much more complete driver for this accelerometer thanks to Kevin Stevenard.  I updated the code and renamed a few things.  The changes were, unfortunately, not backward compatible.  I've reposted the modified code here.

Thanks Kevin!

Sunday, May 23, 2010

Arduino: undefined reference to `loop'

Ok, since this is the second time this has baffled me, I am making a note to myself. It turns out you cannot have a library with the same name as the pde file.

This is the example that got me. The Arduino project .pde file is a test of an accelerometer library (Adxl345.cpp, .h). Here is what the directory listing looks like.
.../sketchbook/Adxl345/Adxl345.pde
.../sketchbook/Adxl345/Adxl345.cpp
.../sketchbook/Adxl345/Adxl345.h

This yeilds the cryptic error
undefined reference to `loop'

or sometimes
undefined reference to `setup'

or both. The fix is to rename the Arduino project as anything other than "Adxl345". Using "Save As" in arduino should do the trick. This is what the listing looks like that works:

.../sketchbook/Adxl345_test/Adxl345_test.pde
.../sketchbook/Adxl345_test/Adxl345.cpp
.../sketchbook/Adxl345_test/Adxl345.h.

Friday, May 14, 2010

ADXL345 Arduino Driver

I wrote a simple driver for the ADXL345 accelerometer on the Razor board.  The code provides read/write access to the registers on the device and allows you to change the bandwidth of the internal low pass filter.  This little chip has an in-depth interface with stream buffering, fall detection, bump detection, double click detection besides autonomous low pass filtering.  I have only scratched the surface here.

A simple test script is located in the examples directory.

Wednesday, May 12, 2010

WORDUINO Instructions

Anool has prepared a beautiful set of instructions for our WordClock. Unfortunately, there are only 6 copies of the boards so consider yourself lucky if you got a set. If anyone expresses an interest, we may make more of the next edition of WORDUINO. Please let us know if you are interested.


The flexible faceplate lettering has been laser etched.


This picture shows the laser cut baffles to isolate the light to individual words.

Saturday, May 08, 2010

SharkFin Sensor Swap -- SFSS

I take it back. On the original SharkFin, the analog circuitry was causing a small error in both the gyro and accel measurements. We've since corrected the design, but we didn't want to lay money down on a new set of boards until the concept was proven.

Along comes the 9 degree of freedom Razor IMU from SparkFun. This $125 bad boy has 3 axes of accel, 3 of gyro and 3 magnetometer, overkill for sure. I got this for experimentation and found out that it fit beautifully on Fin. The holes even lined up. This amazing foresight by Anool, enabled the sensor swap.

The 9 dof razor has a ATMEGA328 on board already. I reprogrammed the MEGA on the SharkFin base to be a digital slave dummy. It just listens on the serial port for 3 byte messages which it assigns to the digital ports: PORTB, PORTC, and PORTD. This simple interface could be expanded to also read digital inputs from the slave.


The accel datasheet indicates a selectable bandwidth. It is unclear on exactly how this is being accomplished, but if it is effective, this will relieve the huge burden on the processor of low-pass filtering the accel data.

The magnetometer offers the possibility of complete head orientation tracking. It is still unclear exactly how to take advantage of this given that there is no true velocity measurement. Ideas are welcome!

Anool receives Alden's minature WordClock.

After over a month, Anool finally received the package containing Alden's miniature WordClock.  Here are some photos of his careful vivisection.

Saturday, May 01, 2010

WordClock Delivered


I dropped off a word clock to Alden (creator of the miniature word clock). I had mistakenly come to the conclusion that Alden had a laser cutter. I will forward the super cool golden face plates when they arrive from Anool. You can see the word clock on the left of the work bench.

While I was there he showed me around his beautiful shop. This is a dream shop, well lit and spacious, with enough components on hand to invent the future (which is what he is doing!).

Below, Alden is checking the performance of a stepper driver he has been working on. The steppers must have gotten out of hand in the second photo as the whole room seems to be spinning.

Sunday, April 18, 2010

Yet Another WordClock

First pass I tried to save room by soldering the power cord directly into the board. It turned out there was plenty of space on the back side of the board as seen below.


The boards are held in place with surplus proto-board. A slit has been cut in the corner of the the enclosure from the outside of the box to accept the holder. This keeps the board stable in both forward and backward directions.



Still missing the baffels, but the result is easily readable.


Friday, April 16, 2010

Laser Cut Face and Baffels

Unhappy with how the clock face turned out, Anool, redesigned them to be laser cut and the results speak for themselves!


He is testing a diffuser over "O'CLOCK", that is how the final product will look.

Monday, April 12, 2010

WordClock boards have arrived


The WordClock board from Anool arrived!
The clock consists of three boards: Main board which houses the ICs, the LED board and the face (pictures to come)

Everything seems to be working except the reset from the FTDI interface. hmmm.

Yet another blinking light, and it is a miracle every time!

Sunday, March 28, 2010

SharkFin-- The first wireless helmet mounted brake light!

I've been consumed for the past month with the SharkFin. The gyro drift and analog glitches nearly did me in. I am reporting in the wee hours of the morning today, that the first version is functional! May still need to play with the thresholds after road testing but, (famous last words) I feel confident that there are no more major hurdles! More pics and vids to come.


Hurray!

Wednesday, February 24, 2010

HACDC Lightning Talk

I made it through a few of the charts of my Lightning Talk before my 5 minutes was up at HAC DC last night. It was a great evening of amazing presentations and after all the presentations were done, Alden Hart gave me a beautiful and tiny word clock. I'll put the link to the video here when it's available.

Saturday, February 20, 2010

IT WORKS!!!!

The boards arrived FedEx this morning from Mumbai. I got right to work on the first prototype when I got home. It friggin worked the first try! The boards exceeded all of my expectations! Lights work. Sensors work. Serial port works. Unbelievable.
Three cheers for Anool! Three cheers for SharkFin!

Friday, February 12, 2010

Strap-On Shark Fin Boards!

 
Anool has completed the machining of the Strap-On Shark Fin boards and they came out beautifully.  Half of them will be arriving from India soon!


Thursday, February 11, 2010

1^2 + 2^2 + 3^2 + 4^2 + 5^2 + ... + n^2

It is well know that the sum of the squares of integers S is n(n+1)(2n+1)/6. And proofs abound. Although this relationship is not difficult to prove by mathematical induction, it is not intuitively satisfying. This visual proof is very clear and easy to understand.

Elizabeth, my 10-year-old daughter, wanted to figure out the volume of a sphere. Making approximations using 16 equal thickness coin shaped cylinders as seen below.

We ended up with an expression that contained in part, the sum 1 + 4 + 9 + 16 + 25 + 36 + 49 + 64.  It was clear that if we had used instead n coins each of width 1/n, to approximate the volumn, part of that expression would intail the sum Sn = 1 + 4 + 9 + 25 + ... + n^2.  To no avail, I looked around for a simple way to demonstrate the well known relationship:
Sn = n(n+1)(2n+1)/6.


Imagine the sum Sn as the volume of the pyramid of 1 x 1 x 1 cubes with one cube on the top layer, 4 on the next, 9 on the next and so on up to n x n cubes on the bottom layer as seen in the figure above.
From the expression Sn =n(n+1)(2n+1)/6, we see that Sis one sixth the volume of a box with dimensions n x (n + 1) x (2n + 1). So it is at least conceivable that six of these pyramids could be packed into that rectangular volume. Elizabeth and I glued 30 wooden cubes into 6 two-layer pyramids (1 x 1 + 2 x 2) as shown

and without too much effort arranged them into a 2 x 3 x 5 rectangular volume.


The configuration is general, in that it can be scaled up to any positive integer n. Here are some screen shots of a Python simulation using n=4 demonstrating the configureation.


Now fast forward a few days. Snowmaggeddon has snowed me OUT of Reston, VA, and I'm stuck in LA on a rainy Saturday. Amy (lovely wife) scouts out a meeting of the LA Microcontrollers Club from the Make Blog. The once-a-month meeting was scheduled to start in only three hours. A quick peak at the map revealed Topanga, CA, to be just up the mountain North of Santa Montica, about a forty-five minute drive from my hotel. Sweet.

Luckily, I got an early start because the direct route was closed because of the Niagra of mudslides. Rerouting was tricky with my gps-phone rebooting every two minutes. I finally arrived at this beautiful location at the end of a mile-long jeep trail.  The Ford Focus I was driving had trouble negotiating the rutted climb, but the view was worth it.


It was fun getting to know Jack, the founder of the LA Mircrocontroller Club and freelance maker (see see buffingtonfx.com) and Nick, a freelance Hollywood tech.

Nick brought his Arduino-based movie prop clock that stays on whatever time you set it and won't flicker when filmed. Jacked showed off his awesome shop, with a DIY CNC router, and shared his recent experience with the Propeller development board.

Getting to the point, Jack kindly offered to route out the pyramid shapes with his CNC router. Literally, an hour later, Jack had produced three perfect five-layer pyramids. He would have made all six, but I was already late for another appointment. Had I known that Jack was planning to give the pyramids to me, I definitely would have waited for the top half of the retangular volume!


Thanks Jack!

Wednesday, February 10, 2010

SharkBoot (Arbitrary clock speed)

To save batteries, Anool are considering running the SharkFin at 3.3V with a 12 MHz resonator.  That means that the bootloader needs to be recompiled with the new CPU speed.

Steps:
1. Download Makefile from ladyada.net here.
2. Add new target by modifying adaboot328 to Makefile (I called it sharkfin328)

sharkfin328: TARGET = sharkfin328
sharkfin328: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>2' '-DNUM_LED_FLASHES=3'  '-DWATCHDOG_MODS'
sharkfin328: $(PROGRAM)_sharkfin328.hex
sharkfin328: AVR_FREQ = 12000000L 
sharkfin328: MCU_TARGET = atmega328p
sharkfin328: LDSECTION  = --section-start=.text=0x7800

3. >make sharkfin328
4. Upload  see here for details.

The new board will look like a "Arduino Duemilanove or Nano w/ ATmega328" inside of Arduino.

Saturday, January 30, 2010

BEBL Board Has Arrived!




The boards Anool sent before Christmas have finally arrived. Looks like the envelope got hung up in the sorter as you can see the torn corner. No worries, the boards arrived unharmed and they are even smaller than I had imaged, 2x5cm.

Now to find a case...
UPDATE

Emily found this tiny Altoids tin that is just right!