Below is a table containing information about how the LIFA packets are built. This is a work in progress as of 6/27 and should be completed soon. Please let me know if you have any questions about this (most people won't need to worry about how this works under the hood. This is for the benefit of advanced users).
Function | Description | Header | Command | ARG0 | ARG1 | ARG2 | ARG3 | ARG4 | ARG5 | ARG6 | ARG7 | ARG8 | ARG9 | ARG10 | ARG11 | ARG12 | Checksum | Return |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Sync | Used to synchronize LabVIEW and the Arduino (Required in wireless mode). | 0xFF | 0x00 | x | x | x | x | x | x | x | x | x | x | x | x | x | Checksum | "sync" |
Flush | Flush serial buffer on Arduino. | 0xFF | 0x01 | x | x | x | x | x | x | x | x | x | x | x | x | x | Checksum | None |
Set Pin Mode | Sets digital pin mode as input or output. | 0xFF | 0x02 | PIN | MODE: 0 - INPUT 1 - OUTPUT | x | x | x | x | x | x | x | x | x | x | x | Checksum | 0x00 |
Write Digital Pin | Writes a value to digital I/O pin. | 0xFF | 0x03 | PIN | Value: 0 - LOW 1 - HIGH | x | x | x | x | x | x | x | x | x | x | x | Checksum | 0x00 |
Write Digital Port | Writes a value to digital I/O pins 0 - 13. Each bit represents a pin value from MSB (Pin 13) to LSB (Pin 0) | 0xFF | 0x04 | PIN 13- 8 | PIN 7 - 0 | x | x | x | x | x | x | x | x | x | x | x | Checksum | 0x00 |
Tone | Generates a square wave of the specified frequency (and 50% duty cycle) on the specified pin. | 0xFF | 0x05 | Checksum | 0x00 | |||||||||||||
Read Digital Pin | Reads the value of a digital input pin. | 0xFF | 0x06 | Checksum | ||||||||||||||
Read Digital Port | Reads the value of digital input pins 0 - 13. | 0xFF | 0x07 | Checksum | ||||||||||||||
Read Analog Pin | Reads the analog voltage of the specified analog input pin. | 0xFF | 0x08 | Checksum | ||||||||||||||
Read Analog Port | Reads the analog voltage of analog input pins 0-5. | 0xFF | 0x09 | Checksum | ||||||||||||||
Write PWM Pin | Writes a PWM signal with the specified duty cycle on the specified PWM pin. | 0xFF | 0x0A | Checksum | ||||||||||||||
Write PWM Port | Writes a PWM signal to three PWM pins. | 0xFF | 0x0B | Checksum | ||||||||||||||
Config Seven Seg | Configures pins to use with seven segment display. | 0xFF | 0x0C | Checksum | ||||||||||||||
Write Seven Seg | Writes a character to the seven segment display. | 0xFF | 0x0D | Checksum | ||||||||||||||
I2C Init | Initialize I2C and join the bust as master. | In0xFF | 0x0E | Checksum | ||||||||||||||
I2C Send | Send I2C data. | 0xFF | 0x0F | Checksum | ||||||||||||||
I2C Read | Read I2C data. | 0xFF | 0x10 | Checksum | ||||||||||||||
SPI Init | Initialize the SPI bus. | 0xFF | 0x11 | Checksum | ||||||||||||||
SPI Set Bit Order | Set data transmission bit order. | 0xFF | 0x12 | Checksum | ||||||||||||||
SPI Set Clock Divider | Set SPI clock divider. | 0xFF | 0x13 | Checksum | ||||||||||||||
SPI Set Data Mode | Set SPI data mode | 0xFF | 0x14 | Checksum | ||||||||||||||
SPI Send / Receive | Send and Receivce SPI data | 0xFF | 0x15 | Checksum | ||||||||||||||
SPI Close | Close SPI Bus | 0xFF | 0x16 | Checksum | ||||||||||||||
Set Num Servos | Set the number of servos to use in your application and dynamically allocate memory for them. | 0xFF | 0x17 | Checksum | ||||||||||||||
Config Servo | Configure servo by setting which pin to use and angle range limits. | 0xFF | 0x18 | Checksum | ||||||||||||||
Servo Write Angle | Write a target angle for the specified servo. | 0xFF | 0x19 | Checksum | ||||||||||||||
Servo Read Angle | Read the last target angle sent to the servo. | 0xFF | 0x1A | Checksum | ||||||||||||||
Servo Write uS Pulse | Write a uS pulse for the specified servo. | 0xFF | 0x1B | Checksum | ||||||||||||||
Servo Read uS Pulse | Read the last uS pulse width sent to the specified servo. | 0xFF | 0x1C | Checksum | ||||||||||||||
Servo Detach | Detach the specified servo so that the DIO pin is free to be used for DIO. | 0xFF | 0x1D | Checksum |
Hello, i think this packets are great and could solve some problems i found trying to connect LabVIEW and Arduino for a project.
I started to use LIFA and i found a mistake in the definition of the number of "analog pin" for the Arduino Mega 2560: there are 16 analog pin and not only 8. I had to modify the "Analog Pin.ctl" and "Check for pin out of range.vi" to make it work properly.
I got also a question: i have to read a sensor with a frequency output, i've already made an attempt using only arduino reading a digital pin and using the function "pulseIN". how can i do this using LabVIEW? is it possible to use on of the packet in the table?
Thank you
Andrea
Is an updated version of the LIFA Packets table available? Looking for additional info on the stepper motor commands (30 and up).
Could you added command for reading intterupt pin in arduino ?? So labview could read and count for RPM measurement..
it's still common problems..
Thanks
Gerry