Arduino communication with LabVIEW, using the LIFA_Base.

in #utopian-io7 years ago (edited)

What Will I Learn?

In this tutorial you will learn:

  • Know the LIFA_Base interface to communicate Arduino with LabVIEW.

  • Program the Arduino Uno card from LabVIEW.

  • Identify the arduino functions encoded in the LIFA_Base.

Requirements

  • Domain of Arduino programming

  • Knowledge of LabVIEW Programming

  • Port handling of the Arduino Uno card.

  • Know the IDE of Arduino.

Difficulty

  • Advanced

Tutorial Contents

The tutorial presents a contribution to programming the Arduino Uno using the Arduino IDE, from the LabVIEW graphical programming software with the LIFA_Base interface to make the conversion between both programming codes.

ar13.png

Arduino: It is an open source electronic platform, based on software (C / C ++ language) and hardware. Arduino represents a software design company with hardware, the latter consisting of electronic cards, based on microcontrollers and with an open source development environment (IDE) for the programming of each board.

Features of the Arduino Uno: Atmega 328, 14 digital inputs / outputs (6 can be used as PWM), 6 analog inputs and a 16MHz crystal, USB cable. 5V operation voltage. Voltage range from 7 to 12V. Flash Memory: 32KB. EEPROM: 1KB.

We will program the following application: Use the reading port of the Arduino Uno, to read the impedance variation of a potentiometer and use this variation of impedance to show the input voltage in an indicator in LabVIEW, programmed in a visual interface in LabVIEW. We will use the LIFA-Base to communicate the Arduino with LabVIEW, the figure shown below exposes the LabVIEW interface that will be controlled by Arduino through LIFA_Base.

ar0.png

The steps described below, exposes the process to perform Arduino communication with LabVIEW using LIFA_Base.

Step 1:

Program the Arduino in the IDE. The Arduino presents an IDE as a programming interface, which can be downloaded from the official Arduino website https://www.arduino.cc/. The programming interface establishes a series of configuration and connection options, a programming zone where the code and the compilation zone are established.

Step 2:

Download the free software VI Package Manager (VIPM), where you can download the toolkit of the functions or subprograms of Arduino with LabVIEW and the LIFA_Base file, as shown in the following figure:

ar2.png

You can download the free version of the following link: http://www.jki.net/vipm/download The program allows you to download the LabVIEW interface for Arduino program, this program will be the one that downloads and installs the functions of Arduino in LabVIEW.

Step 3:

Once the system has recognized Arduino, the programming is done with the sketch that communicates the board with LabVIEW, this sketch is installed with the file LIFA_Base, in the route shown below:

ar11.png

Step 4:

In the LIFA_Base directory there is the file LIFA_Base.pde, where all the libraries will open to program the Arduino Uno card. This way the Arduino board will be able to communicate with LabVIEW. As shown in the following figure:

ar6.png

Step 5:

Configure the Arduino Uno card in the Arduino programming IDE, for this we select: Tools> Arduino Uno board. As shown in the following figure:

ar4.png

Step 6:

Proceed to look in the IDE tools menu, the communication port where the card is connected, the Arduino Uno card presents a USB communication port. In the image you can see the port selection:

ar5.png

Step 7:

Review in LabVIEW the functions downloaded by the LabVIEW interface for Arduino program. All the functions of Arduino, generate a direct connection of LabVIEW with the input and output ports of the Arduino Uno card, the following figure shows the function of Arduino in LabVIEW, some examples and applications:

ar12.png

Step 8:

The LabVIEW program code is established, in the programming diagram in Graphical language, using the programming functions for reading the analog ports of the Arduino Uno card. In the following image the Arduino program is observed, with the functions of starting the connection with the Arduino, reading the port in a repetitive cycle, closing the communication and detecting errors of the functions in the communication.

ar7.png

Step 9:

The user interface is observed on the front panel of LabVIEW, in this interface you can see a virtual voltmeter used to measure the analog voltage of the Arduino Uno card port, a numerical selector for the analog reading port and a stop button to close the cyclic sequence of the program.

ar8.png

Step 10:

In the LIFA_Base, the LabVIEW interface is generated in Arduino programming code, in order to execute the data reading function of the analog port in the LabVIEW-Arduino connection.

The Low Level Analog Commands code is used to read from the analog port of the Arduino Uno card, then the code in Arduino that generates the LIFA_Base for this function is shown and it depends on the port and configuration that is made in LabVIEW:

    Low Level - Analog Commands
    *************************************************************************/
    case 0x08:    // Read Analog Pin    
      retVal = analogRead(command[2]);
      Serial.write( (retVal >> 8));
      Serial.write( (retVal & 0xFF));
      break;
    case 0x09:    // Analog Read Port
      analogReadPort();
      break; 

The functions generated by the LIFA_Base to read the analog ports and send the data frames using the serial port are the following:

*************************************************************************/
// Reads all 6 analog input ports, builds 8 byte packet, send via RS232.
void analogReadPort()
{
  // Read Each Analog Pin
  int pin0 = analogRead(0);
  int pin1 = analogRead(1);
  int pin2 = analogRead(2);
  int pin3 = analogRead(3);
  int pin4 = analogRead(4);
  int pin5 = analogRead(5);

 //Build 8-Byte Packet From 60 Bits of Data Read
  char output0 = (pin0 & 0xFF);   
  char output1 = ( ((pin1 << 2) & 0xFC) | ( (pin0 >> 8) & 0x03) );
  char output2 = ( ((pin2 << 4) & 0xF0) | ( (pin1 >> 6) & 0x0F) );
  char output3 = ( ((pin3 << 6) & 0xC0) | ( (pin2 >> 4) & 0x3F) );    
  char output4 = ( (pin3 >> 2) & 0xFF);    
  char output5 = (pin4 & 0xFF);
  char output6 = ( ((pin5 << 2) & 0xFC) | ( (pin4 >> 8) & 0x03) );
  char output7 = ( (pin5 >> 6) & 0x0F );

  // Write Bytes To Serial Port
  Serial.print(output0);
  Serial.print(output1);
  Serial.print(output2);
  Serial.print(output3);
  Serial.print(output4);
  Serial.print(output5);
  Serial.print(output6);
  Serial.print(output7);

Step 11:

To finish, we made the connection of the Arduino Uno card through the USB port with the computer that has the LIFA_Base application and the program in LabVIEW, we proceed to test the analogical acquisition of the voltage coming from the potentiometer, as shown in the figure, different voltage values are observed for variations of the potentiometer. The analog port used for the Arduino card is A0.

ar9.png

Thank you very much for your attention…



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Congratulations! This post has been upvoted from the communal account, @minnowsupport, by edagmi from the Minnow Support Project. It's a witness project run by aggroed, ausbitbank, teamsteem, theprophet0, someguy123, neoxian, followbtcnews, and netuoso. The goal is to help Steemit grow by supporting Minnows. Please find us at the Peace, Abundance, and Liberty Network (PALnet) Discord Channel. It's a completely public and open space to all members of the Steemit community who voluntarily choose to be there.

If you would like to delegate to the Minnow Support Project you can do so by clicking on the following links: 50SP, 100SP, 250SP, 500SP, 1000SP, 5000SP.
Be sure to leave at least 50SP undelegated on your account.

  • this project is mostly about the LABVIEW while LABVIEW is not a open source software
  • in your tutorial , the part related to the Arduino is just involved with communication with Serial and Analog reading ,which is basci use of the Arduino
  • in addition , the part of the Arduino in this psot does not have enough details to teach an End-user since you just listed out the part of the fucntion (maybe the main fucntion) but it still was not clear enough for the readers

Need help? Write a ticket on https://support.utopian.io.
Chat with us on Discord.

[utopian-moderator]

Coin Marketplace

STEEM 0.21
TRX 0.20
JST 0.034
BTC 99331.95
ETH 3298.98
USDT 1.00
SBD 3.05