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 (I think)
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.

References
Firmata protocol

Firmata home page (old)
http://firmata.org/wiki/Main_Page

Firmata labview example
https://code.google.com/p/labviewduino/

Firmata download

Vvvv download

Hardware
Dell XPS 8300
Intel Core i5-2320CPU @ 3.00GHz
8.0GB RAM
Arduino Uno R3 SMD edition
Arduino Motor Shield R3

Software
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

Firmata initialize command for digital pins.txt (225 Bytes)

firmata decoder.txt (441 Bytes)

I apologize for how broad my original post was. I will narrow my question.

Would anyone please share their experiences using the Firmata-commands from a software interface that was different from the Arduino IDE?

I am trying to upload a sketch to the Arduino microcontroller so that it used the full functionality of the Firmata library (activating analog and digital pins) but relied on the Firmata commands to be transmitted to the Arduino through the USB serial connection.

I would appreciate any additional help or direction. Thank you for reading this,

-Zach

I am trying to upload a sketch to the Arduino microcontroller so that it used the full functionality of the Firmata library (activating analog and digital pins) but relied on the Firmata commands to be transmitted to the Arduino through the USB serial connection.

Well that would be Firmata then. That is what you have to run in the Arduino.

All the rest is down to LabView, it communicated to the Arduino through the serial port which is the USB as far as the Arduino is concerned.

Any data manipulation has to be done in LabView, like turning a MSB and LSB into a number. This is simply done by multiplying the MSB by 256 and adding the LSB to it.

Hey Grumpy_Mike,

If you are interested in my "progress", I have a link to the LabVIEW forum I posted the same scenario.

The present state of affairs is that I am trying to decipher what VISA commands to initiate so I can correctly write and read the buffer from this serial connection. This has become quite infuriating because while I am reading VISA user manuals, I can easily communicate these hexadecimal commands to the Arduino using a different, unsupported software interface called Sartorius COM Helper. This leads me to believe that it is mainly a format issue that requires just a slight tweak of the standard parameters that LabVIEW's VISA uses to establish a serial connection. But....... I have NO idea how Sartorius COM helper has established a serial connection with the Arduino!?

What USB driver does Arduino use? And how can I view it or understand how it works? Maybe, if I understood how it works; I could determine what I need to do in LabVIEW.

Could you explain further or direct me to some literature about the conversion of two 7bit bytes (MSB and LSB) into a number? Why MSB multiplied by 256?

Thank you for the reply and thank you for reading this,
-Zach

Could you explain further or direct me to some literature about the conversion of two 7bit bytes (MSB and LSB) into a number? Why MSB multiplied by 256?

You never said they were 7 bit numbers. If they are then simply combine them with:-
number = (MSB * 128) + LSB
It is all to do with powers of two and binary numbers, you are simply shuffling the bits from the two smaller numbers into successive bits of a larger number. As a byte can only hold numbers between 0 and 255 then one in the most significant byte is worth 256 of the numbers in the least bit.
A bit like this:-

What USB driver does Arduino use?

It is a simple serial port, nothing fancy. You just have to get the baud rate to match in LabView and you send and receive bytes.
It is a long time since I did LabView but from what I can remember you just send bytes are strings over from the VI. I do not recognise the problem you were having.

I must say that a lot of people here, including myself, dislike Fermatta, so we never use it. It is very inflexible and lobotomizes the Arduino.

Hey Grumpy_Mike,

I really appreciate the clarification.

I may have fallen prey to the Firmata propaganda but I did like the idea of making the Arduino microcontroller an “extension of the computer” using a generic protocol via MIDI “the language of the gods”. If that means making the Arduino a Walking-Dead version of its former-self to accomplish the desired tasks at present, then so be it (he said unable to do that).

As far as LabVIEW, you are right. You use strings through VISA read/write to receive/transmit data from the
buffer via the USB-serial connection. However, the VISA read/write is the most basic version of VISA’s read/write capabilities. If I decide to continue on this path, my guess would be that I would have to develop my own driver in VISA so that the two intermediates (Arduino’s USB driver and VISA’s Firmata-specific driver) can communicate between the software (LabVIEW) and hardware (Arduino)?

Please enlighten me. Am I introducing a hyped-middle man for no reason? Can I accomplish my goal without Firmata? Do I have to write two programs (one for LabVIEW and one for Arduino)?

Thank you for the help and for reading this, my LabVIEW-post is almost dead.
-Zach

P.S. Is this traffic (number of views) normal? I am slowly dying from seeing the view-count and few replies.

Am I introducing a hyped-middle man for no reason?

Yes. It is possible to write single bytes to the Arduino through LabView, I used to do it.

Can I accomplish my goal without Firmata?

Yes

Do I have to write two programs (one for LabVIEW and one for Arduino)?

Yes

P.S. Is this traffic (number of views) normal?

It seems to be for this section. The problem is that you are asking for a specialized group of skills, Arduino, Firmatta and LabView. I only know two out of those three.
I will see if some one I know who has a different two can help.

Hi, Is it essencial that you use the Firmata Protocol? There is a large community of people who have designed protocols to communicate between LabVIEW and Arduino. These are quite well designed and robust protocols, have you considered using one of the pre-exisiting ones? (there are many depending on your use-case/condition but) here is one to try: