Friday, 21 February 2014

Serial port interface using labview



Serial port interface using labview

Aim:- To access the device having serial port (like weighing machine)  using labview.
Objectives:-
1.       To connect computer with external device (weighing machine) having serial port.
2.       To read the data from serial port of computer through the labview.
3.       To understand functions of different blocks those are use for serial communication.
4.       To understand the serial port of computer.


Introduction to serial port:-


Pin no
Description
1
Data carrier detect
2
Receive data
3
Transmit data
4
Data terminal ready
5
Signal ground
6
Data set ready
7
Request to send
8
Clear to send
9
Ring indicator

Procedure:-

o   Connect serial port of external device (weighing machine) to the computer through RS_232 cable.
o   Open “Hyper terminal”, select the com port (0 or 1), select the baud rate (2400) and check whether information (data) through serial port is coming or not.
o   After satisfactory result open labview.
o   Take a block of “VISA configure serial port” in block diagram panel of labview.
Path :- (right click on block diagram panel ,instrument I/O, serial block, VISA configure serial port)
o   Give the visa resource name (com port 1), give the baud rate 2400, add parity block and set the time for read operation which is necessary for VISA configure serial port as shown below.



Out of all these pins we use only few pins as below


Figure:- VISA configure serial port block.

o   Take a case structure for continues data reading in true case, in false case terminate the loop (or just bypass the data if condition is wrong).
o   For case selector mode take a button to start or stop reading process.
Read the data from serial port by using “VISA read” block.
Path :- (right click on block diagram panel, instrument I/O, serial block, VISA read)



o   These are in bundle like [05025], separate the bracket by “Search and replace string” block.
Path :- (right click on block diagram panel, programming, string, additional string functions, search and replace patter block)


o   Each “Search and replace string” block remove only one bracket therefore use two blocks for removing two bracket.
o   This result is in string and we want number, for that use string to number block.
Path :- (right click on block diagram panel, programming, string, string/number conversion, fract/exp string to number block)




o   String to number block give us weight in gram.
o   Convert gram to kilogram (by simple multiplication and division blocks) and according to that display item, quantity and price.
o   To select number of item take dropdown menu bar as shown below
Path :- (right click on front panel, express, menu string block)   

o   Select different items like Rice, Dal and Nuts according to that we can see the quantity and price.
o   This weighing scale allows weight up to 10 kilogram.
o   When we put weight more than 9Kg OVER FLOW indicator will on.
o   For the above reason use comparator.

On front panel we get window like this



On block diagram panel we get window like this




REFERENCES
Core LabVIEW Concepts
LabVIEW Environment Basics – VI, front panel, block diagram, palettes, controls, and indicators
(Link:- http://www.ni.com/gettingstarted/labviewbasics/environment.htm)
Dataflow Programming Basics – dataflow, wires, and data types
(Link:- http://www.ni.com/gettingstarted/labviewbasics/dataflow.htm)
Common Tools – tools palette, shortcut menus, property dialogs, and the front panel toolbar
(Link:- http://www.ni.com/gettingstarted/labviewbasics/tools.htm)
Debugging Tools – fixing broken VIs, execution highlighting, and the block diagram toolbar
(Link:- http://www.ni.com/gettingstarted/labviewbasics/debug.htm)





Programming in LabVIEW
  Execution Structures – while loops, for loops, and case structure
(Link:- http://www.ni.com/gettingstarted/labviewbasics/exestructures.htm)
Data Structures – arrays, clusters, and enumerated data
(Link:- http://www.ni.com/gettingstarted/labviewbasics/datastructures.htm)
(Link:- http://www.ni.com/gettingstarted/labviewbasics/shiftregisters.htm)
Handling Errors – error handling and error clusters
(Link:- http://www.ni.com/gettingstarted/labviewbasics/handlingerrors.htm)
Finding Examples and Getting Help
  Finding Examples – Example Finder and ni.com/code
(Link:- http://www.ni.com/gettingstarted/labviewbasics/examples.htm)
Using the LabVIEW Help – context help and the LabVIEW help
(Link:- http://www.ni.com/gettingstarted/labviewbasics/producthelp.htm)
Online Help Resources – Knowledge Base and forums
(Link:- http://www.ni.com/gettingstarted/labviewbasics/onlinehelp.htm)
Getting Additional Help – help from a LabVIEW expert


THANK YOU
s