LabVIEW Interface For Arduino on Leonardo

7/17/2014 Update from Sam K:

Hey everyone.

LIFA has been replaced with LINX which includes support for the Leonardo (and lots of other new features too!). Check it LINX here:

Let us know if you have any questions about LINX by posting in the LabVIEW Hacker forums here: Thanks! Sam K LIFA & LINX Developer

Original 2013 Post

I've seen a lot of neat projects using the LabVIEW interface for Arduino (LIFA). It's a quick way to communicate with an Arduino, build a nice GUI for prototyping or testing sensors, and integrate it into a larger system (the Waterloo Labs Science Fair Mashup is a great example).  It's also pretty cheap to try ($50 for LV SE + Arduino Uno). Recently I ran into a bit of a hiccup in trying to use LIFA with a newer Arduino Leonardo to graph some sensor data.  Reading the forums, I found others who ran into the same two problems:

  1. The AFMotor library used by LIFA does not yet support Leonardo
  2. The Leonardo USB-Serial interface may not be recognized in VISA

For others who run into these issues, here are a few quick workarounds: For #1, simply contribute a patch to the AFMotor library to add Leonardo support.  Alternatively, you can remove the AFMotor and Servo libraries from the Arduino project (assuming you don't need motor control).  This is done by clicking the down arrow on the right of the tab bar in the Arduino IDE, and deleting these files from the project.  The last step here is to comment out "#DEFINE STEPPER_SUPPORT 1" in LabVIEWInterface.h.  This will prevent compilation errors due to missing servo libraries (thanks for including that Sam!).


As for the VISA issues, I had no success debugging the issue with VISA 4.6.  The USB-serial resource was detected, but listed as 'incomplete'.  Fortunately, updating to NI-VISA 5.1.2 solved this problem. With those two changes, I was able to compile and upload the LIFA firmware, and communicate with the Leonardo from a LabVIEW VI.  The only caveat (besides losing motor support) - some of the IO definitions listed in LIFA VI comments do not apply to Leonardo.  For example - Leonardo I2C (aka 'Wire') IO are on pins 2/3, not on A4/A5 as on the Uno.  Here's a photo of using the Leonardo I2C interface from LabVIEW via Sam's BlinkM Example:


Measuring AA Battery Life for LED Pixel Halloween Costume

As I mentioned in the LED Ring construction post, I wanted to make sure 4 AA batteries would power my 25 RGB LEDs through a good 3+ hours of trick-or-treating. The Adafruit doc provides a good battery life estimate, but I figured I might as well measure it. Fortunately, I had a myDAQ handy, and hooked it up to measure battery current and voltage as shown in the schematic.

Screen Shot 2012-11-11 at 11.31.11 PM

Note: the power consumed by the 1N4001 diode is not measured with this setup.

I then wrote a quick LabVIEW VI to measure & log the battery voltage and current every second.  This way I could see the voltage and current drop as the batteries discharged.

Rainbow Cycle LEDs

With some fresh AA's, I powered up the LEDs and ran the 'RainbowCycle' pattern from the Adafruit WS2801 library, shown below (all 25 LEDs are on driving different colors, this should be a good worst-case current draw mode).

The myDAQ logged data to a CSV file for about 8 hours, you can see the resulting current, voltage and power vs time (click for a larger version).


The graph shows about 5 hours of LED power before the current drops off, plenty for my application.  In total the LEDs consumed about 1900 mAh during the test, which is in line with the original estimate.

Roomba Costumes with Synchronized LED Rings

A quick post on our 2012 Halloween costumes - after many late nights, we had an awesome time walking around the neighborhood tonight.

Related posts:

Background - my son loves our Roomba vacuum cleaner.  He loves to watch it work, loves to take it apart and clean it, even loves to watch 10 min teardown videos on Youtube.  As such, we knew we had to make him a Roomba costume for Halloween.  But what about my wife and I?  The virtual walls!

A few weeks back, my wife and MIL got to work crafting an awesome costume.  Here they are in action:

Crafting the Roomba costumes
Crafting the Roomba costumes

And here is the end result (below).  You can see that Halloween started out a bit rough, the key player in theme was non cooperative.

A malfunctioning Roomba with two exasperated virtual walls.
A malfunctioning Roomba with two exasperated virtual walls.

However, all was not lost.  Our backup plan involved mounting his costume to his stroller (along with him).

After dark, we turned on the flair - my friend Matt and I built up 3 LED rings to mount on the top of the costumes.  The LEDs are the 25-pixel strings from Adafruit controlled by an Arduino Pro Micro from Sparkfun, powered by 4 AA batteries and a 9V.

Update: I detailed the LED Ring Design and Construction here.

The best part - we were able to synchronize the 3 LED rings via an IR transceiver board we built.  The rings used IR to share timer values and calibrate to a common understanding of time - allowing them to blink in sync!  Here is a mockup of the ring (with purple PCBs from OSHPark) and a photo of our PCBs (9 of 12).

The costumes lit up the night, we heard a ton of oohs & aahs, pictures taken, lots of questions, it was a blast!  I'll post more on how we did it when I catch up on my sleep.

And here we are trick or treating.

Roomba Costume
Roomba Costume

Fresh Popcorn in a Faraday Cage

RFI is a serious concern (especially for radio telescopes), but so is a tasty snack.  Here is one way they balance these needs at the GBT.  This microwave is in the main control room, which itself is in a faraday cage.  Side note: I need a microwave with a 'Danger' mark.