oman rs300 topo Lave W ta Sane: GaphelPreganmr Mas aya Fn an
Flylib.com
Download Now Free
Convert thousands of aucio files in one go fast. Download Switch Fres
File InputOutput
File InputiOutput
File input and output (VO) operations rtieve information from ane store information ina ask fle, LABVIEW has a numberof
very versatle fle 10 functions, as well a some simple functions that take care of almost all aspects of fle UO in one shot, Well
{alk about the simple fle functions in tis chapter. Al relocated inthe Programyming>>File I/O subpaette ofthe Functions
palette,
How They Work
oni comteckte3382.128 veeoman rs300 Fetnptosoat | AVN Tr vane: GapiealPrgarmrg Mad any a Fu
7
The File funetions expect file path input which looks kind of ike a sting, path isa specific datatype that provides a platform
‘specie way to enter path to fie, We talked about them briefly in Chapter 4, and they come up again in Chapter 14,
“Advanced LabVIEW Data Concepts." you don't wire a fle path te File functions will pop up a alog box asking you to select
‘or enter aflename. Wen called, the File functions open or create a fle, read or write the data, and then close te fe. The files
‘created wih the Vis wel lak about now are just ordinary text fle. Once you have wrt dala toa fle, you can oper the fle
using any word processing program to See your data
‘One very common application fr saving data to fe isto format the textile $0 thal you can open itn a spreadsheet progran. In
‘most spreadsheets, tabs eoparate columns and EOL (ond of tne) characters eoparate rows,
Express Wilting and Reading of Measurement Flos
For quick and interactive configuration of data fle V0 operations in LabVIEW, consider using the Wrte To Measurement File and
Read From Measurement File Express Vi, shown in Figure 9.29 and Figure 9:30.
Faure 9.20, Wee To Measrament
Are ——]
ieee eet
ose Somacae
Fipwe 930, Ras For Measurerant Flo
wonton) ol
oni comteckte3382.128cores. s300 topos LBW ta Sane: GaphelPreganmr Mas ay ad Fn an)
‘These Vi pass data asthe dynamic data lype (which we leamod about in Chapler 8, “LabVIEW's Exciting Visual Displays:
‘Charts and Graphs", so they can handle just about any type of fle containing measurement data,
“To configure these Express Vis after they ae placed on the block diagram, open the configuration dialog by double-ceking on
‘he subVI or selecting Properties from the pop-up menu.
From the Witte To Measurement File Express VI coniguation ealog (shown In Figure 9.31), you can specty how a fe wil be
{orratted, and what data to stor inthe fe.
Figure 9.21, Wee Te Maseuement File conigurasn log
nua comteckte3 821.1281cores. s300 topos LBW ta Sane: GaphelPreganmr Mas ay ad Fn an)
From the Read From Measurement File Express VI configuration dialog (shown in Figure 8.32), you can specty the format of
‘the file tobe read. I you press the Read File Now button, LABVIEW wil ead the fle once ane populate the Sample Data table to
‘show you whether the read operation worked successfully
Figure 922, Rad From Mesure Fie confguton
‘Writing and Reading Spreadsheet Fes
nue comteckte3 38211281oman rs300 tno] nV sae: Gap Prgarmr Ma any anu
2
Ifthe Express Vis do not provide you with enough flexibly, you can read and wri directly to spreadsheet tex fles with Write
‘To Spreadsheet File and Read From Spreadsheot File.
ite To Spreadsheet File conversa 2D or 1D aray of single-precision numbers toa text string, and then writes te string o @
new by‘ siraam fle or appends the string ta an existing fle. You can optionally transpose the data. Do not wire inputs for oth
41D and 20 data (or one will be ignored). The text files created by ths VI are readable by most spreadsheet application.
ferme ah mneny
eon as) rentleosh at.
‘asa
scowetnnte®
Taner
Read From Spreadsheet Fle reads a spectid numberof ines or rows from a numeric txt il, begining ata specified
‘character offet, and conver the data lo @ 2D eingle-precision array of numbers (see Figure 9.34). You can optionally transpose
the array. This VI will read spreadsheet les saved intext format.
Fura, Read From Spaaesbet Flos
feat)
eam ae ney) om
‘brevet
ae
on peuthene rat
(em
3)
ona comteckte3 382.128eno] anv sane: Gap Prgarmr Ma ay anu
white To Spreadsheet File.vi and Read From Spreadsheet File.vido not have érrer in or cero out terminals. They do al of hele
‘error handling internally, and will open an error dialog if an error does occur inside the VI. This behavior can be nice for simple
"
applications, bu is generally undesirable for advanced application.
te To Sproadsh:
‘comma or tab) to separate columns and an end of line character, \n, or Win) to separate rows. Commanly, a spreadsheet fle
1 Fila. and Read From Spreadshest File-vi wre and read data as text files using a delimiter (usualy @
‘hat uses commas as the delimiter i referred to as @ Comma Separated Values (CSV) file and i routinely saved withthe
flename extension "cs" which Microsoft Excel, OpenOffice.org Cale, and other spreadsheet applications will recognize. For
‘example, on a computer with Microsoft Excel installed, you can double-click on a CSV fle andi will open in Excel. Infact, CSV
files (framed witha *.>*ile 10 palette) converts the 20 aray to a spreadsheet string and writes it to
ale. no path name is specified (asin this actviy), then a file calog box wil pop up and prompl you fra fle name.
Boolean Constant
‘The Boolean Constant (Programming>>Boolean palette) conttals whether of not the 20 aay ie transposed before it writen to
fp, To change ito TRUE, click on the constant wth the Operating too. In ths ease, you do want the data transposed because
‘tho data arrays are row specific (each row ofthe 20 array isa data aay). Because you want each column ofthe spreadsheot
‘ie to contain data for one waveform, the 20 aray must frst be transposed,
3. Retum tothe front panel and run the VI. Aer the data arrays have been generated, a fe dialog box wil prompt you forthe
fle name of te new fle you are creating. Type ina fle name (orf you dont see this opton click onthe "New. button
‘tom the dialog box, and choose *Fle") and clk the OK button. Remember the name and location ofthe fle, as you wil
ead in the data in the next exercise,
=)
Do not atlampt to wite data les in VI libraries withthe file V0 Vis. Doing so may everwite your Ibrary and destroy your
previous work
4. Save the Vin your macnx directory, name it Graph Sine Array to File, and cose the VI
5. Uso sproadsheot software if you have i, or simple tox elitr, o open and view the fle you ust created. You should soe
twa columns of 100 elements each,
‘Activity 84: Reading rom the Spreadsheet Fle
nue comteckte3 38211281orn rs30m le ptt SVEN Ear: pte Pann Many nd Fu EB)
You wil write a VI to read in te data fom the le writen inthe lst exercise an plat ton a graph.
41. Open a new Vi and place a waveform graph on Is font panel. Make sure auloscaling ison,
2. Create the litle block diagram shown in Figute 9.87. Use the Read From Spreadsheet Fle function to bring in data and
spay ton the graph,
Peel
4 Using the TRUE Boolean Constant, you must transpose the array when you read tin, Because graphs pot data by ow and
thas been stored inthe fle by column, Note that f you had’ transposed the data in the last exercise to stor tin columns.
In the fle, you wouldnt have to transpose It hack now,
‘4. Run the VI. Because you are nt provicng file path, a dalog box will prompt you to enter a filename. Select the fle you
created in Activity 95,
oxi cook 52828 wxoman rs300 ents] snVEW a sane: Gap Prgarmr Ma ay anu
The VI wil read the data rom the fle and plot both waveforms on the graph
‘Save the VI in your rmx directory as Read File.
More Wing and Reading of Files
Youve s
n how to read and write spreadsheet fles or measurement data (using the dynamic data type). These functions are
very easy to use.
Now we will diecuss basic fle UO functions for working with text ane binary fils.
2
It you need to read or write plain ext le, you can use the LabVIEW functions onthe Programming>>File VO palette Write To
“Text File and Read From Text File.
Use the Whe To Text Fle (shown in Figure 9.38) to wrte a string of characters toa fle. Use Read From Text Fie (shown in
Figure 9.39) to read sting of characters rom a fle
Hone (Checee vn
arden inmate
ona comteckte3 382.128 saFlnpuospt| nV W er vane: GaphelPrramnrg Mass anys Fu
Hen open euena te) me
Se
|
“The fle input of Wrte To Text Fle and Read From Text Fle are path datatypes. However, you can wie a fle refnum (which is
liscussed in Chapter 14, "Advanced LabVIEW Data Concepts") instead and the file input will adapt o arefnum type. These Vis
‘are smart, inthe sense thal they can accept either a path or arefnum as ther input
Iti important o not, that when you wire @ path input ino these Vis, you do nt connect a wire ta the refnum out ermal
‘then you da not need to clase the file refnum using the Close File function (whichis discussed in Chapter 14), White To Text File
‘and Read From Text File re smart and will automaticaly close the fl, i you do not wire anything tothe refnum out
“The samo tus for Wite To Binary File and Read From Binary Flo
\whan you call Wit To Text Filo and Read From Text File repeatedly (in a While Loop, for example), they wil "remember where
‘hey lf off For the Write To Text File function, his moans thal each Le you wie a strng of characters, hey are appended to
the last string of charactors that you wrote, For the Read From Text Fle function, this means that when you read some number
‘of characters (epectied by the count inp wil read thal number of characters starting where you left of, ast Ue you read
the file. LabVIEW koops track of where you et off automaticaly, string this position inthe fle marker, to make your life easior.
‘As wo wil oar nox. we can explicitly set and got the positon of te fla marker, which makes it possible to have random
‘access to data stored in large fle.
2
Just as you can read and write plain ex les, LabVIEW alga gives you functions to read and wre binary files.
oni comteckte3382.128 2oman rs300 Fetnptospat | aVEW vane: GapiealPrgarmrg Mad anya Fu
7
Binary fe are efficient for storing large amounts of non-text data because, generally, they take up much less disk space than
text files, For example, storing the number “3.1415826535879" na binary hile might only take up eight byes (asa double
precision number, whereas in text fe t would take up 16 byes (one bye fr each characte),
(On the other hand, you can't easily open binary files with another appicaton (ike Word or Excel because those other
applications dont "know" how the data was formatted. Because a binary fle could contain any type of data (for example, an
array of integers, ofa cluster of strings), upto you to specify how to read back that dala, When you write a binary fe with
LabVIEW, yout gonorally use LabVIEW to oad back thal binary fle
Te Whte To Binary Fle function is very easy to use and works just ke the Write To Text File function we saw eae, except
‘that you can wire any kind of data you lice to the data input (see Figure 8 40). Th file input can be either a path ora file rfnum
ron Chese aa 7
Hl seb. refunelt
“tae “samlet
‘The Read From Binary Fi
is also ea8y to use, and is sinilarto the Read From Text File function, except that you must tll
Read From Binary File what kindof binary datas stored inthe fle you are trying to read (see Figure 9.41). You do this by wing
the right kind of data t the data type input, You must wire the same data type that you used to wrt the fl, Otherwise, youl gst
‘garbage results in the data ouput
faange———
rene Ceeneset
iii
oy
oni comteckte3382.128 saoman rs300 eno spats sane: Gap Prgarmr Ma ay anu
"
For example, you wrote arrays of Booleans to your binary data file, then you need to wire an array of Booleans fo the data type
Inout.
Activity 9-6: Reading a Text File
‘You wil create a V that reads the entre contents ofa tex fle and splays the contents ina string incicator and the filesize in a
numeric indicatr.
4 Build the front panel shown in Figure 9.42,
‘The VI wil read the contents ofthe fila specified by the Fle Path contol and display th output in the sting indicator. The
lita indicator wil cisplay the files length,
Foire 942. Front pana one VI you wil tete dng the acy
+ ==
feel]
2. Build the block diagram in Figure 9.43.
Fire 943, Block gram oft VI you wl rst aug hs ety
ona comteckte3 382.128 twetnpt0spat| sav sae: Gap Prgarmrg Ma any anu
Feces
Henn
El
Read from Text File Function
Read From Text File function (Programming>>File VO palette) returns the contents of text fle ina sting
i
Simple Eror Handler
Simple Eror Handler. (Programming>>Dialog & User Interface palette) cisplays a cialog f theres an error in one ofthe File
Wo functons.
4. Retum to the front panel and enter a path to a text fla into te fle path control. Make sure that you don select a file that is
(0 large (which will cause LabVIEW to use a lot of memory), or 8 binary fle {which wil just splay funny characters).
4. Run the VI and look atthe fle contents that ae displayed in the string indicator, ard the filesize thats displayed inthe
rumerie inciator
5. Save and close the VI. Name it Read Text Fle.wi and place In your mx directory. Great jobyours just made a text le
viewer!
oni comteckte3382.128 waorn rs30m Fe pt SVEN tr Ear: pte Pegannny Muy nd Fu EB)
Activity 9-6: Writing and Reading Binary
'As you saw inthe previous activiy, reading a tex le pretty tv. In ths activ, youl bull @ VI that writes toa binary fle and
then another VI that can read tose binay les
Fst lets create the VI that writes @ binary fle. Bula front panel Ike the one shown in Figure 8:4, with one chart and one
array of numbers,
2. Build a block dlagram tke the one shown in Figure 9.45,
Faure 94, rte To nay bse taraoman rs300 Fetnptospat | BW Tr vane: GapielPrrarmrg Ma anya Fu
datos
ge
xefacesh
cate = —EL_
ao vrs igtEre
chaste “Brae
‘Well make our binary data by generating an array of points that represents sinewave, To do this, we can use a function
called Sine Wave wl. You can find tis funtion Inthe Programming>>Signal Processing>>Slgnal Gonoration paleo, a5
shown in Figure 8.45,
3. Save your VI as Write To Binary Fle.vi, Run your VIto test it, You should see the data plotted, and you wil be prompted to
save to file. You call your fe "My Data.éat" of something snl.
‘Sine Wave. (ound on the Programming>>Signal Processing>>Signal Generaton palette) generates an aay containing a
sinewave (see Figure 8.48),
reseghza
selon
4. Now lets build the VI that can read the binary fle you just created
shown in Figures 9.47 and 9.48,
reat a front panel and black diagram lke the ones
oni comteckte3382.128 waFe pt SVEN tr Ear: pte Pegannny Muy nd Fu EB)
a et
awd
ao aie ohn alt
cethngpan ure
tranpesorayetos, atest
Ei =o
=: eercores. s300 topos LBW ta Sane: GaphelPreganmr Mas ay ad Fn an)
5. For the block diagram, use the Read From Binary Fle function from the Programming>File 10 pate
‘Notice that you MUST wire the “datatype” inp. Unike tex! les, wen you read a binary file, you have to epeciy what kind
of data inside the Mle, Because we know that this fle was writen ag an arty of DBL, we ereate an array constant on the
block diagram of OBL,
To creat the array constant “datatype: array of DBL" you do the folowing:
a. From the Programming>>Array palette, choose Aray Constant and place the blank array constant onthe block
‘diagram.
»b. From the Programming>»Numeric palate, choose Numeric Constant and place this inside the array box
«, You have an array now, but the default numeric datatype isan integer (192). Right-click onthe numeric constant
Inside the aray and select Roprosontaton>>DBL.
4. Now wir this aay constant to the “data typo" input on the Rad From Binary Filo
{6 Save your VI as Read From Binary File. vi and un i, When prompted, selec the binary fle you saved eae.
7. As an intresting exercise, use the Read From Text Fil. you created and open the binary fle.
nua comteckte3 821.1281 twoman rs300 topos LBW ta Sane: GaphelPreganmr Mas ay ad Fn an)
Leaked Photos From North Korea
wy th
rtwertyoutosee
LabVIEW for Everyone: Graphical Programming Made Easy and Fun (3rd
i
=a
Edition)
san, Author: Jtioy Tai, parenteral
oratesere3 Pages: 234 am Kong
EAN
214483647
oni comteckte3382.128 2Osea VEN Evra npc Peganm Ma Easy ad an)
Leaked Photos From North Korea
yt
ona comteckte3 382.128 weRare But Powerful Photos T-Shirt Fails Show
Everything
topos LBW ta Sane: GaphelPreganmr Mas ay ad Fn an)
Some Funny Airport
Moments
Chilling Historical Photos Woodstock Pics Show How Did We Never Notice
Everytt ‘Those?
eens penriyine ano wannoqse emasecr cree. nareD wuMaN nesounce
Se Nae eran 0
nua comteckte3 821.1281‘Sian 4.5 ow to use Onenssit Qusnilting and Analyzing Peolact
Passnneane Aaanis ak,
Agents Sonelusion
‘lan 6.2 Using Por Forwarding Within
topos LBW ta Sane: GaphelPreganmr Mas ay ad Fn an)
‘xb bo remactve TeeHboT oa
nua comteckte3 821.1281
DISCRETE LINEAR sysrEMs
ALIASING: SLGNAL AMBIGUITY IN THE