LabVIEW Interface For Arduino on Leonardo

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!).

LIFA_Leonardo_After2

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:

LIFA-Leonardo

Creative Commons License
This work, unless otherwise expressly stated, is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. Terms and conditions beyond the scope of this license may be available at rhb.me.

3 Comments

  1. Fabio

    I’m newbie with Arduino. I tried to follow this document and to upload on a Leonardo the firmware without AFmotor and Servo libraries.
    I still have this error messages:
    IRremote.cpp:172: error: ‘TCCR2A’ was not declared in this scope
    IRremote.cpp:172: error: ‘COM2B1′ was not declared in this scope

    Can you help me?

    Thanks in advance.

  2. rhb

    A quick hack would be to similarly remove the IRremote from the project. I’ll try to look at this next week, but I bet you’ll get faster help on the NI forum:

    https://decibel.ni.com/content/groups/labview-interface-for-arduino?view=discussions

  3. Dario

    Hello, im having the same issue, im installing Visa 5.1.2 at this moment, and i took the compiling error taking out all the libraries i wont use.
    My question is, do you configure the visa VI or the arduino INIT VI to use the leonardo?, becauze the default microcontroller is the UNO.
    Thank you

Leave a Reply