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.
Attached
My labview program
My Firmata set-up commands
Standard Firmata sketch for Arduino
References
Firmata protocol
https://github.com/firmata/protocol/blob/master/protocol.md
Firmata home page (old)
http://firmata.org/wiki/Main_Page
Firmata labview example
https://code.google.com/p/labviewduino/
Firmata download
https://github.com/firmata/arduino
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