Instrument Control (GPIB, Serial, VISA, IVI)

Showing results for 
Search instead for 
Did you mean: 

LabVIEW interface using Firmata protocol to control Arduino microcontroller

I would like to use a LabVIEW interface to control an Arduino microcontroller using a Firmata protocol.

The desired goal would be uploading an Arduino sketch with the Firmata functionality so that the Arduino could be completely controlled by the host computer using the LabVIEW interface to enter Firmata-commands (to activate relays, run a bipolar stepper motor, read values from an encoder, etc…).

Does anyone have experience with the Firmata protocol and how to implement it using VISA?

The old Firmata home-page offered one example of a LabVIEW program using the Firmata protocol; however, it is only scanning the Firmata report for the analog pin voltage values. It does show how to convert the corresponding hexadecimal values to the LSB and MSB bits but I am unsure how to use this.

I have only progressed by using the “vvvv” software and seeing how pin values and pin modes are encoded to the Firmata protocol. Using the “Standard Firmata” uploaded on the Arduino, I can successfully activate LEDs using digital or analog (PWM) commands through the “vvvv” interface. When I try to use these same commands but using my LabVIEW interface, I cannot activate the LEDs relying on analog commands for power. If I change my pin modes and commands to be all digital, I can successfully activate all LEDs using my LabVIEW interface and “standard Firmata” sketch.

I am currently trying to communicate to the microcontroller through a USB serial connection using LabVIEW’s VISA to write commands. These commands are strings but changed to hex display. As mentioned previously, I can successfully command digital pin values but cannot command pin values by PWM.

As I understand it, the Firmata protocol loosely follows MIDI where command bytes are 8 bits and data bits are 7 bits. I do not know how the LSB and MSB bits are used. Supposedly, there are some commands that can accommodate more bits but I have not successfully applied them.

Individual examples (“0x” is the hexadecimal radix)

0xF4 0x08 0x01 = PinMode for pin 08 is set as a digital output

0xF4 0x03 0x03 = PinMode for pin03 is set as a PWM output

0x90 0x00 0x00 = port 0 of Arduino has LOW Outputs on all its pins

0x90 0x08 0x00 = port 0 of Arduino has one HIGH output on pin 03

0x90 0x08 0x00 0x91 0x11 0x00 = port 0 has one HIGH output on pin 03; port 1 has HIGH outputs on pin 08 and pin 12 (which does work)

0x90 0x00 0x00 0x91 0x11 0x00 0x92 0x00 0x00 0xE3 0x01 0x7C 0xEB 0x00 0x 00 =

Port 0,1, and 2 have LOW outputs on all digital pins, pin 03 has some PWM output (somehow corresponding to “255”); pin 11 has no output

The last example does not activate LED’s using the analog write command.

I have attached some supplementary material if anyone is interested including my programs that activate digital pins only and tries to activate digital and analog pins.



My labview program

My Firmata set-up commands

Standard Firmata sketch for Arduino



Firmata protocol

Firmata home page (old)

Firmata labview example

Firmata download

Vvvv download



Dell XPS 8300

Intel Core i5-2320CPU @ 3.00GHz


Arduino Uno R3 SMD edition

Arduino Motor Shield R3



LabVIEW Developmental System 8.6

NI-VISA version 5.0

Operating System: Windows 7 Home Premium, 64-bit

Arduino IDE version 1.6.5

Standard Firmata, copyright 2015 Jeff Hoels

vvvv version 45beta34.1, x64

vvvv addonpack version 34.1.0

Firmata version 2.6.1


0 Kudos
Message 1 of 6

Hi Zac58


I don’t have any experience with the Firmata protocol because it’s not supported by National Instruments, but if you have an specific VISA driver questions I would be happy to try and answer them.  I saw that you also posted this question in the Arduino forum.  I think that forum will be able to give you better support for your application.

0 Kudos
Message 2 of 6
Hey Defective Luddite,

I will narrow the focus of my question. How does VISA translate my string message to data to my instrument?

If I am trying to send a mixture of 8bit and 7bit messages, how do I correctly format that string message so VISA sends exactly what I want? When I use the Serial Initialize VI, does the data-bit control play a part in how VISA reads my string message?

Is there a way to have a USB sniffer to see this transaction between LabVIEW and my instrument? Could you recommend a sniffer if you knew of one? Older posts refer to a program called Portmon but I am unsure if that is compatible with newer operating systems.

Thank you for replying and any additional help or direction you give. I wasn't sure if this was the right topic to post, and I did want to fish in as many ponds as I could.

0 Kudos
Message 3 of 6



I believe the following document will help answer some of your questions on how VISA works and how LabVIEW specifically works with VISA:


I don't know of any good USB sniffers unfortunately.



Message 4 of 6

I have provided a NI trace of running two tests with a new program “Firmata Interface Troubleshoot” which is trying to set-up a serial communication with the Arduino microcontroller using the Firmata protocol; but I am still trying to decipher it. LED activation was successful for the “all digital” trace, however, the other trace was not successful in activating the LEDs connected to PWM outputs (pin 03 (0x03) and pin 11 (0x0B) of the Arduino).

This new program has the same architecture as my previous one. Both initialize serial parameters (baud rate, parity, etc…) with the Arduino serial driver to establish a serial communication. Then, it sends the initial command to set the pin modes and values of the Arduino pin outputs (as well as disabling analog reporting for the 6 analog pins) via VISA write. Next, additional commands are sent until the max iteration is met. Buffer is cleared and VISA connection closed. See Appendix for Firmata codes to initialize pins and set values. The only difference between the old and new program is the way I write my Firmata command. The new program uses a byte array (U8, unsigned bit integer) with a hexadecimal radix to represent the multi-byte commands I would like to send when I convert the byte array to string.

My unsuccessful attempts with LabVIEW have become even more maddening due to the fact I can make my commands work when I use a different software interface! Sartorius offers a simple, serial interface which is completely unsupported by Firmata but works for my commands using all digital commands or digital and PWM commands!

My guess is that there is some formatting issue with VISA that I am not addressing with my hexadecimal commands otherwise how could a simple serial interface do it?

The Firmata commands I am trying to use have three equal parts. The First part is the command byte (8bits) having some decimal value greater than 127. The second and third parts are the data bytes representing the LSB (least significant byte?) and the MSB (most significant byte?) respectively.

How do I determine if VISA is transmitting this correctly? Should I break-up my message into 3byte (24bit) increments? How?

I would appreciate any help in this matter; I’ve been butting my head against this issue and cannot figure it out.

Thank you for reading this,




Additional information

Arduino driver version

NI I/O Trace version 3.0.2



New firmata trouble shoot program

Two traces text and trace files



Sartorious COM helper



Serial Parameters

Baud rate……………….57600


Stop Bit……………………1

Flow control……………none

Data bit…………………..8

No termination character


“All digital” (all numeric values are hexadecimal)

Initial Firmata Command to set all digital pins to LOW, analog pin 03 to ZERO, analog pin 11 to ZERO, pins 00-13 as Digital outputs, pins 14-19 as Analog outputs, Disable Analog pins 0-5 from reporting

9000 0091 0000 9200 00E3 0000 EB00 00F4 0001 F401 01F4 0201 F403 01F4 0401 F405 01F4 0601 F407 01F4 0801 F409 01F4 0A01 F40B 01F4 0C01 F40D 01F4 0E02 F40F 02F4 1002 F411 02F4 1202 F413 02C0 00C1 00C2 00C3 00C4 00C5 00


Firmata commands to set pins with LEDs attached (03,08,09,11,12,13) to LOW/HIGH

9008 0091 1100 9200 00

9000 0091 0A00 9200 00

9008 0091 0100 9200 00

9008 0091 2A00 9200 00


“digital and PWM commands”

Initial Firmata Command to set all digital pins to LOW, analog pin 03 to ZERO, analog pin 11 to ZERO, pins 00-13 as Digital outputs except pin 03 and 11 are PWM outputs, pins 14-19 as Analog outputs, Disable Analog pins 0-5 from reporting

9000 0091 0000 9200 00E3 0000 EB00 00F4 0001 F401 01F4 0201 F403 03F4 0401 F405 01F4 0601 F407 01F4 0801 F409 01F4 0A01 F40B 03F4 0C01 F40D 01F4 0E02 F40F 02F4 1002 F411 02F4 1202 F413 02C0 00C1 00C2 00C3 00C4 00C5 00

Firmata commands to set pins with LEDs attached (03,08,09,11,12,13) to LOW/HIGH

9000 0091 1100 9200 00E3 017C EB00 00

9000 0091 0A00 9200 00E3 0000 EB01 7C

9008 0091 0100 9200 00E3 017C EB00 00

9008 0091 2A00 9200 00E3 0000 EB01 7C


0 Kudos
Message 5 of 6


I appreciate the literature; I am still reading through it though.


Just wanted to update you on something I noticed. Whenever I am using the Sartorius COM helper, I can send the three-byte hexadecimal command as individual bytes (regardless of time between entering the hexadeciimal bytes) and the Arduino will execute the command! Furthermore, I can append empty bytes (0x00) before and after the three-part command and not interfere with the command execution.


How can the Sartorius COM helper do this? Is this asynchronous?




0 Kudos
Message 6 of 6