Vous êtes sur la page 1sur 5

LAB 12

How to Interface LabVIEW with Serial Port


Objective
Lesson overview: Serial Port Interfacing using LabVIEW.

Theory
In computing, a serial port is a serial communication ph sical interface through which information transfers in or out one bit at a time. !hroughout most of the histor of personal computers, "ata transfer through serial ports connecte" the computer to "evices such as terminals an" various peripherals. In serial ports, there will be two "ata lines: #ne transmission an" one receive line. !o sen" a "ata in serial port, it has to be sent one bit after another with some e$tra bits li%e start bit, stop bit an" parit bit to "etect errors.

&igure '()': Serial Port Pin outs 1

E erci!e 12"1#
'. Launch LabVIEW an" then clic% on *lan% VI. (. +o to *loc% ,iagram, &unctions Palette, Instrument I-#, Serial, an" then select Visa .onfigure Serial Port an" Visa /ea". 0. +o to !ools Palette an" select automatic tool selection from there. 1. 2ow right clic% on VIS3 resource name, top left si"e of Visa .onfigure Serial Port an" then clic% on create constant. 3n" then clic% on /efresh button.
4. 2ow right clic% on bau" rate, (
n"

from top on left si"e of Visa .onfigure Serial from top on left si"e of Visa .onfigure Serial

Port an" then clic% on create constant.


5. 2ow right clic% on "ata bits, 0 6. 2ow right clic% on parit , 1
th

r"

Port an" then clic% on create constant.


from top on left si"e of Visa .onfigure Serial Port
st

an" then clic% on create constant. Select 2one from Parit "rop "own menu.
7. 2ow right clic% on stop bits, ' on bottom from left si"e of Visa .onfigure Serial

Port an" then clic% on create constant. Select '.8 from stop bits "rop "own menu.
9. 2ow right clic% on flow control, (
n"

on bottom from left si"e of Visa .onfigure

Serial Port an" then clic% on create constant. Select 2one from flow control "rop "own menu. '8. 2ow connect Visa /esource 2ame #ut :/ight top; of Visa .onfigure Serial Port with Visa /esource 2ame :Left top; of Visa /ea".
''. 2ow right clic% on b te count, (
n"

from top on left si"e of Visa /ea" an"

then clic% on constant. E"it its value from 8 to '. '(. 2ow right clic% on error out, last from top on right si"e of Visa /ea" an" then clic% on in"icator.
'0. 2ow right clic% on rea" buffer, (
n"

from top on right si"e of Visa /ea" an"

then clic% on in"icator. '1. 2ow go to &unctions Palette, Programming, String, String - 2umber .onversion, an" select ,ecimal String to 2umber. '4. 2ow connect string terminal of ,ecimal String to 2umber with /ea" *uffer Input.

'5. 2ow go to &ront Panel, <o"ern, an" 2umeric an" then select +auge from there. Set its range from 8 to '8. 3lso right clic% on properties of +auge an" then go to ,ispla &ormat tab an" then select ! pe: ,ecimal from there. '6. 2ow go to &ront Panel, .lassic, an" 2umeric an" then select !an% from there. Set its range from 8 to '8.
'7. 2ow go bac% to *loc% ,iagram an" right clic% on number, (
n"

from top on

right si"e of ,ecimal String to 2umber an" then clic% on in"icator. '9. 2ow right clic% on the 2umber in"icator an" change its representation to =7 an" then rename it to unsigne" 7bit integer. (8. Wire the +auge an" !an% with unsigne" 7bit integer. ('. 2ow go to &unctions Palette, Programming, .omparison, an" then select two bloc%s of +reater than #/ E>ual an" two bloc%s of Less than #/ E>ual. ((. 2ow arrange them all four +reater than #/ E>ual, Less than #/ E>ual, +reater than #/ E>ual an" Less than #/ E>ual from top to bottom. (0. 2ow connect $ terminal of all four +reater than #/ E>ual an" Less than #/ E>ual with the input of !an%. (1. 2ow if !an% level is less than or e>ual to 0 it will glow L#W Le", If !an% level is between 1 an" 6 it will glow <e"ium Le" an" If !an% level is greater than or e>ual to 7 it will glow ?I+? Le". (4. 2ow place constant on terminal of all +reater than #/ E>ual an" Less than #/ E>ual accor"ing to point (1. (5. 2ow go to &unctions Palette, Programming, 3rra an" then select 32, operator from there. (6. 2ow 32, the two con"itions for <E,I=< Le". (7. 2ow right clic% on top +reater than #/ E>ual an" create in"icator. /ename it to ?I+?. (9. 2ow right clic% on mi""le 32, operator an" create in"icator. /ename it to <E,I=<. 08. 2ow right clic% on bottom +reater than #/ E>ual an" create in"icator. /ename it to L#W.

0'. 2ow create W?ILE loop b

going to &unctions Palette, Programming,

Structures an" then clic% on W?ILE loop from there. 0(. 2ow right clic% on the loop con"ition :at the right bottom of the while loop; an" clic% on control from there. 00. 2ow go bac% to &ront Panel an" then replace LE,s from roun" to s>uare. @ou can replace LE,s b right clic% on LE, in the &ront Panel an" then clic% on replace an" then LE, an" then S>uare LE,. 01. 2ow save the VI after saving ou can run the VI. *ut before running VI ma%e sure that connect two P.s serial port using cross cable. #ne P. runs the above VI an" another VI is connecte" to ? per!erminal. ,o the ,efault settings for ? per !erminal. When ou run the above VI its +auge an" !an% will in"icate the status of 2=<P3, %e s from 8 to 9 of another P.. 04. 2ow finall our VI will loo% li%e as follow:

&igure '()(: &ront Panel of E$ercise '()'

&igure '()0: *loc% ,iagram of E$ercise '()'

Vous aimerez peut-être aussi