Using LabVIEW with RS232 or RS485 Data Acquisition Interfaces Phone:(705) 671-2652 Fax:(705) 671-6127 Email: Using LabVIEW to Send Commands via RS232 to ADR Interfaces LM335 Temperature Measurement 1. Introduction The following application demonstrates how LabVIEW can be used with ADR interfaces, or any ASCII based serial data acquisition and control interface. The application is a simple temperature measurement and plot using an and an. It is assumed the user has a basic knowledge of LabVIEW, however, no prior experience with LabVIEW is required as long as the user manual is available to help with the generic tasks. Figure 1 shows our final operating panel for the application in operation. The panel allows adjustment of the sample rate via a rotary knob, and displays temperature vs.
Serial Communication With Labview Tutorial Torrent. Download Serial Communication and Data Logging Software. Arduino with lab view how to interface arduino with labview to get data through serial communication on labview View VI and front panel.
Time in a graph format. A digital reading of present temperature is also provided. The hardware consists of an ADR112 connected to com2, interfaced to an LM335 temperature sensor connected to AN0. Figure 1: Final Operating Panel 2. Lets Get Started. Start labview, and an blank panel will appear called untitled.VI. Save the VI as a file called 'START'.
We will now place various controls and indicators on the blank panel that will become the applications operating controls and indicators. Using the CONTROLS menu, place on the following on the panel; A waveform chart from CONTROLS/ARRAY AND GRAPH/WAVEFORM CHART A numeric knob from CONTROLS/NUMERIC/KNOB A vertical switch from CONTROLS/BOOLEAN/VERTICAL SWITCH A numeric indicator from CONTROLS/NUMERIC/DIGITAL INDICATOR. Arrange the items as shown in Figure 2 using the pointer to add labels by right clicking on each item and typing it in. Change the scale on the waveform chart vertical axis to 0 to 4095 using the hand icon. Figure 2: Initial Panel Layout Use the hot key, CTRL-F to show the control diagram. Arrange the items to the positions shown in Figure 3. Figure 3: Initial Control Diagram 3.
Building the Program Before starting to build the program we must understand what we want the program to do for us. We should have a basic knowledge the application hardware and desired operating parameters. This application will require the software to send an 'RD0' command ( followed by a carriage return ) to the ADR112, causing it to respond with a four digit integer number from 0000 to 4095 representing the temperature data in 12-bit format. The data must then be scaled and displayed on the front panel in degrees Celsius in a digital display and in a waveform chart showing temperature history. The basic program will repeat this operation at a rate determined by our adjustable sample rate knob.
For this we will start by selecting a WHILE LOOP using FUNCTIONS/STUCTSANDCONSTANTS/WHILELOOP. Position the loop as shown in Figure 4. Figure 4: Adding the While Loop We will now add the components required to have the loop execute at an adjustable interval by adding a few more components. Add the following three components; A wait function timer from FUNCTIONS/TIMEANDDIALOG/WAIT A multiply function from FUNCTIONS/ARITHMATIC/MULTIPLY A numeric constant from FUNCTIONS/STUCTSANDCONSTANTS/NUMERICCONSTANT Position the items as shown in Figure 5 and wire them as shown using the wiring tool. The timer will now delay repeated execution of the loop by 1000 times the setting of the sample rate knob on the front panel.( in ms). If the knob is set at one, the sample rate will be 1 second ( 1000 X 1=1000ms ), if the knob is set at 0.5 the sample rate will be 0.5 seconds ( 1000 X 0.5 = 500ms), etc. The on/off slide switch is wired as shown to enable or disable the loop from running.
It will serve as a simple enable/stop function on the front panel. Figure 5: The Delay 4. The Sequencer The software in the loop must now be set up to send and receive ASCII data to the ADR112 via Com2. This is accomplished by using a sequencer and a number of serial port functions provided by LabVIEW. The sequence, as the name implies, allows the execution of code in a specific sequence similar to that of a PLC. The sequencer is a series of frames that code is placed into, that determines the actual execution sequence of the code. Add a sequencer to the control diagram using FUNCTIONS/STUCTSANDCONSTANTS/SEQUENCER.
Position the sequencer as shown in figure 6. Figure 6: The Sequencer 5. Writing Data to the Serial Port The first frame will contain the actual serial write function.
Also added in this step is the serial port initialize function. Place the serial write function inside frame 0 by selecting it from FUNCTION/SERIAL/SERIALWRITE. Place the serial initialize function outside the while loop as shown in Figure 7 using FUNCTION/SERIAL/SERIALINITIALIZE. Use a numeric constant to set initialize the port to Com2 ( port 1) and set the port for the write operation by wiring as shown. A command string of 'RD0' must be sent in the write operation and it must be followed by a carriage return for the ADR112 to respond. This is done by selecting a string constant using FUNCTIONS/STUCTSANDCONSTANTS/STRINGCONSTANT.
Enter RD0 followed by a carriage return as the string constant and wire as shown in Figure 7. IMPORTANT; The default termination character for an ASCII string in LabVIEW is a linefeed character which will not cause the ADR112 to return data. The linefeed must be changed manually to a carriage return. This is done by right clicking on the data and selecting ' CODES DISPLAY'. When this is done, 'RD0 n' will be the displayed string data. Use the text icon to change the n to r ( carriage return ). If successful, the string will as be shown as in Figure 7 with the ' CODES DISPLAY' function enabled.
Figure 7: Serial Write Function 6. Adding a Step A second step is to be added to the sequencer where the serial read function will be placed. This is done by right clicking on the sequencer frame indicator and selecting ' ADD FRAME AFTER'. The sequencer will appear as shown in Figure 8. Figure 8: Adding a Step 7. Reading and Displaying Data The data returned from the ADR112 will be read using a 'serial read with timeout' vi.
This vi is included with LabVIEW in the samples directory. Place it in the frame along with a 'Format and Strip' function from FUNCTION/STRING/FORMATANDSTRIP. Wire as shown in Figure 9 including, a numeric constant of 5 for number of bytes to receive ( 4 plus CR ), and a string constant of '%d' to identify the incoming data as integer format. Wire the output of the ' Format and Strip' function to both the ' Present Temperature' display and the ' Temperature Plot ' Figure 9: Reading and Formatting Data 8.
First Run Through This would be a good time to test the program. Connect a potentiometer to AN0 on the ADR112 and run the VI from the Panel Window. Vary the pot and the display should look something like Figure 10. Vary the sample rate to become familiar with its operation. Do not forget to click on the ON/OFF switch to enable operation. Figure 10: First Run Through.
Finalizing Application Finalizing the application involves converting the ASCII data to Celsius. This is done with a one arithmetic subtraction and one division function added to the second step in the sequencer as shown in Figure 11. These functions are necessary to convert the 12-bit data to Celsius and are explained in the application note Figure 11: The Final Code The display can then be customized to give the VI a more pleasing appearance.
See your user manual for the various customizing options. The scale of the graph can also set using the hand icon to whatever range is to be measured in the application. Our final version was saved as 'ADR112.VI' as appears as in Figure 12. Figure 12: Final Panel 10. Where Do We Go From Here? This was a simple application using only one analog input port of the ADR112 interface.
Additional graphs or use of the digital ports for alarms can be facilitated simply by adding steps to the sequencer with additional write and read operations. All of the functions found on can be utilized with LabVIEW. Programs can be as complex or as simple as the application requires. The people at National Instruments have done an outstanding job developing LabVIEW and it is easy to see why it has become so popular. Note: The VI used in this example can be downloaded in zip format using the following link; Ordering LabVIEW ( Students and Educators) LabVIEW student edition is available for around $100.00 direct from the publisher. This graphical programming software is designed for scientists and engineers who automate laboratories or take industrial measurements.
When coupled with the low-cost, an affordable data acquisition and control hardware/software solution is achieved. LabVIEW Student Edition, Author, Lisa K. Wells, National Instruments Publisher: ORDERING USA 1-800-643-5506 CANADA 1-800-567-3800 ( VISA,MC,AMEX) ISBN 0-13-210709-0 Macintosh Version ISBN 0-13-210691-4 Windows Version Ordering LabVIEW ( Non-Educational) Contact for pricing and delivery of full license versions. Contact Information Address Telephone Electronic Mail Ontrak Control Systems Inc. 764 Notre Dame Ave., Unit #1 Tel: (705) 671-2652 General Information Sales or Support Sudbury,Ontario Fax:(705) 671-6127 CANADA P3A 2T2 Next-Day shipping anywhere in Continental U.S.
Via Fed-Ex Copyright © 2012 ONTRAK CONTROL SYSTEMS 764 Notre Dame Ave, Unit #1, Sudbury, Ontario, CANADA P3A 2T2 'Quality serial Data Acquisition Interfaces' PH. (705) 671-2652 FAX (705) 671-6127.
Hello, I'm about to start working with LabView for semiconductor electrical validation, so far I'm completely novice in LabView. I'm assined to perform certain validation tests that require synchronization with hardware events by means of serial communication with the external hardware on which measureemnts are conducted. The communication is to be handled by means of RS232 port message reception, parsing and decoding. I understand LabView is able to communicate with measurement equipment by several ways, including RS232, so I though to employ this method in my approach. We will have our hardware connected to PC via COM and the hardware will sent text messages (such as text lines in TXT file) to the PC where they would be picked by LabView. The parsing needs to be performed on these text lines to fetch out only those that correspond to our required measurement tasks (these text lines are flags to start particular measurements).
As soon as the text message is accepted and parsed, given it is recognized as relevant one by LabView, certain decoding is necessary to be performed on these message in favor of further test report and then the necessary measurement is to be triggered. I guess I'll have to write my own code of text message parser and decoder. Once the measurement is initiated, the samples stream (to be compiled into Excel tables) must be synchronized in time as much as possible with the following text messages received through COM that are relevant to the test.
Each text message that is relevant contains a running unique time stamp marker, so the measurement samples are need to be somehow synchronized to these messages by means of these time stamps. I hope experienced users out there will be able to hint me whether the said above is viable and realisable in LabView without some without some heavy coding overhead? Thanks in advance, Alex.
This sounds like a fairly common use of LabVIEW and you should certainly be able to do it. There are shipping examples for serial communication (i.e.
Basic Serial Write and Read) that can help you get started with that. The parsing of the response can be done with the Scan From String. A simple shipping example is called Parse String. The majority of the instrument drivers at the involve string parsing in one way or another so there are additional VIs there that you can look.
You might also want to look there to see if drivers already exist for the instruments you plan on using. I would recomend you use GPIB or Ethernet based instruments instead of serial though. The communication is more robust and faster. Getting a timestamp just requires you to call the Get Date/time In Seconds whenever you do a serial read. This data can be combined with the serial read and written to a text file in spreadsheet format with Write to Spreadhseet File. If you want to write directly to Excel, I would recomend the as the easiest way to do that.
Hi spider1112002, I am working with RS232 communication using Labview. I have thermocouple input module connected to the PC through a RS232 serial port.
I am using the labview example file Basic serial read and write to communicate to it. I am able to configure the module using the Write string and reading the output from the module in read string. The output it shows in read string is something like this, A25 r here, A refers to the header, 25 the temperature I am reading and r the carriage return.
Intend to operate the thermocouple input module in a continuous fashion at different frequency and I would like to get this output (either in the form of string (A25 r) or just the temperature value (25)) in a text file. I tried using the ' write to measurement file' but it doesn't write the value displayed in the read string to the output text file. Also I tried using write to text file option and it writes only one data (such as A25) to my output text file. Can you help me get over this problem. Appreciate your help.
If I had posted this in an inappropriate section please direct me to the right place. Thank you, vzv. Hi spider1112002, I am working with RS232 communication using Labview. I have thermocouple input module connected to the PC through a RS232 serial port. I am using the labview example file Basic serial read and write to communicate to it.
I am able to configure the module using the Write string and reading the output from the module in read string. The output it shows in read string is something like this, A25 r here, A refers to the header, 25 the temperature I am reading and r the carriage return. Intend to operate the thermocouple input module in a continuous fashion at different frequency and I would like to get this output (either in the form of string (A25 r) or just the temperature value (25)) in a text file. I tried using the ' write to measurement file' but it doesn't write the value displayed in the read string to the output text file. Also I tried using write to text file option and it writes only one data (such as A25) to my output text file.
Can you help me get over this problem. Appreciate your help. If I had posted this in an inappropriate section please direct me to the right place. Thank you, vzv. That post was from 2006 but you're in the right place.
Sounds like your problem is NOT with RS-232 but rather writing data to a file correct? There are many examples that show how to do this: Help Find Examples. Fundamentals File I/O If none of those help you, post your code.
This is usually a pretty trivial task but your problem description isn't sufficient to guess what's wrong. Although you may want to make sure you are APPENDING to the file to avoid overwriting it each time you read data.
Hi NIquist, Appreciate your reply. I am reading the serial port and yes, my problem is with writing data into a file. The examples files were a little helpful and I have constructed a VI with that and attached with this post. I am reading the port at 500 ms frequency (delay before read) for 5 seconds, for which I expect upto 10 values logged into the file. But I see only one ('A25').
I am operating at room temperature (no fluctuations in temperature), so I am not sure whether this 'A25' is the first or the last read string from the port. I am using LABVIEW 2012 SP1 (32bit) Thank you, vzv.
Vzv wrote: I am using continuous run for my work. My intended idea was to select the text file at the beginning of each data collection (create/open existing file) such that the values from the board are stored as a list in a new text file or get appended (if it is an already used text file) during the continuous run. I don't see a difference when I change the set file position between start/current/end. How do I avoid this overwriting of the data? Thank you, vzv You need to set the file position before writing to the file. This requires opening the file first and also be sure to close it when complete.