Block Diagram. Open a blank VI and build the block diagram shown in Figure. Display the front panel and run the VI. Save the VI as Serial Communication.vi in the C:ExercisesLabVIEW Basics I directory. Close the VI when finished.
Several LabVIEW packages can be usedfor data acquisition but in this tutorial I chose NI DAQmax library to interfacewith an Arduino microcontroller via a USB cable. The Arduino polled four Infra-Reddistance sensors and transmitted the sensor values in tab-delimited ASCII formattedstrings to the serial port. Here is the Arduino code that was used:
A LabVIEW program took in the datafrom the serial port and split it into 4 arrays, plotted 4 graphs and saved thedata in a text file.
- The first step is to configure theserial port settings. VISA Open VI initializes the serial communication. VISASerial Port Configure sets the COM port and Baud rate to the ones the Arduinomicrocontroller is set to.
- Open the file stream.
- Read the serial data using VISA Read. This VI outputs ASCIIstrings by default. Be sure to wire the byte count into VISA Read.
- At this stage, output strings can be manipulated indifferent ways. I splitted the output string into 4 arrays and plotted 4 graphsbefore I saved the strings to a text file.
- Lastly,close the file stream and the VISA serial session.
LabVIEW is one of the frequentlyused software in Data Acquisition. To program in LabVIEW, you use graphicalicons (Virtual Instruments or VIs) the almost the same way you would use functionsin other programming languages. To create the desired data flow, connect the VIswith color coded wires. LabVIEW offers two GUIs; namely, the block diagram(contains the main code) and the front panel (nicer interface which containscontrols, indicators and graphs). For a more detailed introduction to LabVIEW,visit NationalInstrument website.
The Arduino is programmed in C++, Ifound this tutorial to be usefulfor beginners.
I hope you find this tutorialuseful.
- Jonah.