LabView Physics 3 - IT skills Miles Padgett [email protected].
-
Upload
felix-brines -
Category
Documents
-
view
219 -
download
0
Transcript of LabView Physics 3 - IT skills Miles Padgett [email protected].
![Page 2: LabView Physics 3 - IT skills Miles Padgett m.padgett@physics.gla.ac.uk.](https://reader038.fdocuments.us/reader038/viewer/2022110205/56649cc15503460f949885d0/html5/thumbnails/2.jpg)
Objectives To acquire familiarity with the LabView
Programming language To be able to write LabView programmes
incorporating pre written and new VI’s To use LabView in the study of 2-D
diffraction patterns You get exercise marks for completion of
each milestone.
![Page 3: LabView Physics 3 - IT skills Miles Padgett m.padgett@physics.gla.ac.uk.](https://reader038.fdocuments.us/reader038/viewer/2022110205/56649cc15503460f949885d0/html5/thumbnails/3.jpg)
LabView - the basics
All LabView programmes comprise of two screen types The “front panel” (grey) which acts as
the user interface The “diagram” (white) which contains
the “programme”
![Page 4: LabView Physics 3 - IT skills Miles Padgett m.padgett@physics.gla.ac.uk.](https://reader038.fdocuments.us/reader038/viewer/2022110205/56649cc15503460f949885d0/html5/thumbnails/4.jpg)
LabView - getting going Like most programs,
LabView can be launched by double clicking on the LabView icon
Programs themselves are called “vi” (virtual instruments)
To start a new “vi”, select “new vi” from the LabView start up screen
The LabView icon
The LabView start up screen
![Page 5: LabView Physics 3 - IT skills Miles Padgett m.padgett@physics.gla.ac.uk.](https://reader038.fdocuments.us/reader038/viewer/2022110205/56649cc15503460f949885d0/html5/thumbnails/5.jpg)
LabView - front Panel Controls (data input) and indicators
(data output) can be selected from the “controls” window and placed on the front panel.
To find controls select “show panel” from “window” menu select “show controls palette” from
“window” menu
The controls palette
![Page 6: LabView Physics 3 - IT skills Miles Padgett m.padgett@physics.gla.ac.uk.](https://reader038.fdocuments.us/reader038/viewer/2022110205/56649cc15503460f949885d0/html5/thumbnails/6.jpg)
LabView - diagram Functions (program operations)
can be selected from the “functions” window and placed on the diagram.
To find functions select “show diagram” from
“window” menu select “show functions palette”
from “window” menu
The functions palette
![Page 7: LabView Physics 3 - IT skills Miles Padgett m.padgett@physics.gla.ac.uk.](https://reader038.fdocuments.us/reader038/viewer/2022110205/56649cc15503460f949885d0/html5/thumbnails/7.jpg)
LabView - tools Tools (cursor/mouse
functions) can be selected from the “tool” window
To find tools select “show tools palette” from
“window” menu
The tools palette
![Page 8: LabView Physics 3 - IT skills Miles Padgett m.padgett@physics.gla.ac.uk.](https://reader038.fdocuments.us/reader038/viewer/2022110205/56649cc15503460f949885d0/html5/thumbnails/8.jpg)
Using LabView to add two numbers Create new program
Select “new VI” from the file menu
Select a digital control from the controls palette and place it on the front panel (grey)
Do the same again Select a digital indicator
from the controls palette and place it on the front panel
Selecting a digital controlSelecting a digital control
Selecting a digital indicatorSelecting a digital indicator
![Page 9: LabView Physics 3 - IT skills Miles Padgett m.padgett@physics.gla.ac.uk.](https://reader038.fdocuments.us/reader038/viewer/2022110205/56649cc15503460f949885d0/html5/thumbnails/9.jpg)
Adding two numbers - front panel
Controls and indicator placed on front panel
N.B. software automatically numbers controls of the same type in sequence
The front panel
![Page 10: LabView Physics 3 - IT skills Miles Padgett m.padgett@physics.gla.ac.uk.](https://reader038.fdocuments.us/reader038/viewer/2022110205/56649cc15503460f949885d0/html5/thumbnails/10.jpg)
Adding two numbers - diagram
Data terminals automatically appear on diagram
The diagram
![Page 11: LabView Physics 3 - IT skills Miles Padgett m.padgett@physics.gla.ac.uk.](https://reader038.fdocuments.us/reader038/viewer/2022110205/56649cc15503460f949885d0/html5/thumbnails/11.jpg)
Adding two numbers - placing the function
Select and drag the “addition function onto the diagram
To find addition Show function panel Click on numeric Select and drag
addition onto diagram
Selecting a numeric functionSelecting a numeric function
Dragging onto the diagramDragging onto the diagram
![Page 12: LabView Physics 3 - IT skills Miles Padgett m.padgett@physics.gla.ac.uk.](https://reader038.fdocuments.us/reader038/viewer/2022110205/56649cc15503460f949885d0/html5/thumbnails/12.jpg)
Adding two numbers - wiring the function
Select “wiring tool” from tools palette Cursor now changes
function “click” on wire start point
“drag” to end point then “release”
Use wiring tool to connect Digital controls to
function inputs Function output to digital
indicator
![Page 13: LabView Physics 3 - IT skills Miles Padgett m.padgett@physics.gla.ac.uk.](https://reader038.fdocuments.us/reader038/viewer/2022110205/56649cc15503460f949885d0/html5/thumbnails/13.jpg)
Adding two numbers - running the program
Select “arrow” from tools palette Cursor now changes
function Running the program
Use arrow tool to “click” single arrow on front panel to run once
Or “click” looped arrow on front panel to run continuously
Stopping the program Use arrow tool to “click” red
stop button
Run onceRun once
Run continuouslyRun continuously
Stop the programStop the program
![Page 14: LabView Physics 3 - IT skills Miles Padgett m.padgett@physics.gla.ac.uk.](https://reader038.fdocuments.us/reader038/viewer/2022110205/56649cc15503460f949885d0/html5/thumbnails/14.jpg)
Adding two numbers - operating the program
Select “finger hand” or “text tool” from tools palette
Cursor now changes function
Changing the input Use “finger” on up/down
arrows of numeric controls Or use “text tool” to
highlight and edit number field (white) within numeric control
If running continuously then program is interactive
Up/down arrowsUp/down arrows
Text fieldText field
![Page 15: LabView Physics 3 - IT skills Miles Padgett m.padgett@physics.gla.ac.uk.](https://reader038.fdocuments.us/reader038/viewer/2022110205/56649cc15503460f949885d0/html5/thumbnails/15.jpg)
Adding two numbers - saving the program
Select “save” from within the file menu When prompted enter filename Note in windows LabView files have a
***.vi file extension Vi - stands for virtual instrument
DO IT NOW AND KEEP DOING IT!
![Page 16: LabView Physics 3 - IT skills Miles Padgett m.padgett@physics.gla.ac.uk.](https://reader038.fdocuments.us/reader038/viewer/2022110205/56649cc15503460f949885d0/html5/thumbnails/16.jpg)
Customising the program (text)
Select “text tool” from tools palette
Cursor now changes function
Changing the name of the input
Use “text tool” to highlight and edit the names (grey) numeric control
Use “text tool” to highlight and edit the name (grey) numeric indicator
Control text fieldControl text field
Indicator text fieldIndicator text field
![Page 17: LabView Physics 3 - IT skills Miles Padgett m.padgett@physics.gla.ac.uk.](https://reader038.fdocuments.us/reader038/viewer/2022110205/56649cc15503460f949885d0/html5/thumbnails/17.jpg)
Customising the program (data)
Select “arrow tool” from tools palette
Cursor now changes function
Changing the allowed range and up/down increment of the controls
Right click (windows) on the numeric control to generate menu then select “Data range…”
Within data range can set upper limit/lower limit and increment
Now run the program again
Max/Min/IncrementMax/Min/Increment
Selecting data rangeSelecting data range
![Page 18: LabView Physics 3 - IT skills Miles Padgett m.padgett@physics.gla.ac.uk.](https://reader038.fdocuments.us/reader038/viewer/2022110205/56649cc15503460f949885d0/html5/thumbnails/18.jpg)
Customising the program (display) -1
Select the front panel Show “controls panel from
window menu” Use “arrow tool” to select
numeric control Use “arrow tool” to select
“meter” and “drag” it onto front panel
Use “text tool” to optionally edit name of meter
Use “text tool” to optionally highlight and edit the range of the meter
Selecting a digital meterSelecting a digital meter
Range of meterRange of meter
Name of meterName of meter
![Page 19: LabView Physics 3 - IT skills Miles Padgett m.padgett@physics.gla.ac.uk.](https://reader038.fdocuments.us/reader038/viewer/2022110205/56649cc15503460f949885d0/html5/thumbnails/19.jpg)
Customising the program (display) -2
Select the diagram Select “wiring tool” from tool
palette Use wiring tool to connect
meter terminal to existing output wire of the “addition” function or equivalently to the existing numeric indicator terminal
I.e. click on start, drag to end then release
Run the program again, note meter display matches indicator
![Page 20: LabView Physics 3 - IT skills Miles Padgett m.padgett@physics.gla.ac.uk.](https://reader038.fdocuments.us/reader038/viewer/2022110205/56649cc15503460f949885d0/html5/thumbnails/20.jpg)
Accessing LabView’s help To get help on a function
Select the diagram Select “arrow tool” from tool
palette Use arrow tool to right click
(windows) on function Select help from pop up menu Function help appears in sub-
window More general help can be
obtained through the “help menu”
“Content and index” is good for specific questions
LabView comes with a “learn by activities package”
Also a great set of example programs
![Page 21: LabView Physics 3 - IT skills Miles Padgett m.padgett@physics.gla.ac.uk.](https://reader038.fdocuments.us/reader038/viewer/2022110205/56649cc15503460f949885d0/html5/thumbnails/21.jpg)
Useful tips - indicators, controls and terminal Every indicator on the front
panel has a terminal on the diagram
Every control on the front panel has a terminal on the diagram
Right clicking(windows) on any terminal, control /indicator gives the option of highlighting the corresponding control /indicator or terminal
![Page 22: LabView Physics 3 - IT skills Miles Padgett m.padgett@physics.gla.ac.uk.](https://reader038.fdocuments.us/reader038/viewer/2022110205/56649cc15503460f949885d0/html5/thumbnails/22.jpg)
Useful tips - switching between tools Rather than picking your tool from the “tools palette” pressing
the “tab” key toggles the tool between On the diagram
Arrow (allows selection and/or movement of terminals and functions around diagram
Text (allow text edit of terminal and addition of extra text comments)
Wiring (allows wiring connection of functions and terminals) Finger (allows selection of terminals)
On the panel Arrow (allows movement of controls around panel Text (allows text edit of control/indicator and addition of extra
text comments) Paint (allows colour change of control or indicator) Finger (allows adjustment of controls)
![Page 23: LabView Physics 3 - IT skills Miles Padgett m.padgett@physics.gla.ac.uk.](https://reader038.fdocuments.us/reader038/viewer/2022110205/56649cc15503460f949885d0/html5/thumbnails/23.jpg)
Useful tips - showing various windows Any window or tool panel can be made
active by selecting it from the window menu
Alternatively “clicking” on a window will make it active This is a quick way of switching between the
diagram and the front panel
![Page 24: LabView Physics 3 - IT skills Miles Padgett m.padgett@physics.gla.ac.uk.](https://reader038.fdocuments.us/reader038/viewer/2022110205/56649cc15503460f949885d0/html5/thumbnails/24.jpg)
Useful tips - finding errors If the current LabView
programme is non executable the “run” arrow on the front panel appears broken
Activating the arrow results in an error list contain the faults
Selecting any fault highlight the offending part of the diagram
Broken “run” arrowBroken “run” arrow
error listerror list
![Page 25: LabView Physics 3 - IT skills Miles Padgett m.padgett@physics.gla.ac.uk.](https://reader038.fdocuments.us/reader038/viewer/2022110205/56649cc15503460f949885d0/html5/thumbnails/25.jpg)
Looping programs Computers become
power when you make them do something many times!
LabView loops are examples of structures and placed on the diagram Show diagram Shows functions palette Select structure
Selecting the Selecting the structure sub palette structure sub palette from the functions from the functions palettepalette
![Page 26: LabView Physics 3 - IT skills Miles Padgett m.padgett@physics.gla.ac.uk.](https://reader038.fdocuments.us/reader038/viewer/2022110205/56649cc15503460f949885d0/html5/thumbnails/26.jpg)
Incorporating a “while loop” Select a “while loop”
from the structure palette
Place while loop on diagram to surround program Click top left drag to
bottom right and release While loop will run whilst
condition is true
““While loop”While loop”
ConditionCondition
![Page 27: LabView Physics 3 - IT skills Miles Padgett m.padgett@physics.gla.ac.uk.](https://reader038.fdocuments.us/reader038/viewer/2022110205/56649cc15503460f949885d0/html5/thumbnails/27.jpg)
Setting the condition of a “while loop” Need Boolean (true/false)
control to set state of while loop Show front panel Show controls palette Select “boolean” Select “push button” and
drag and place (release) on front panel
Optionally use “text tool” to highlight and edit name (grey) of new control
![Page 28: LabView Physics 3 - IT skills Miles Padgett m.padgett@physics.gla.ac.uk.](https://reader038.fdocuments.us/reader038/viewer/2022110205/56649cc15503460f949885d0/html5/thumbnails/28.jpg)
Wiring the condition of a “while loop” Need to wire the Boolean
terminal to the condition of the while loop Use arrow tool to move (if
necessary) the terminal of the Boolean control to the inside of the while loop
Use the wiring tool to connect the boolean terminal to the condition terminal
![Page 29: LabView Physics 3 - IT skills Miles Padgett m.padgett@physics.gla.ac.uk.](https://reader038.fdocuments.us/reader038/viewer/2022110205/56649cc15503460f949885d0/html5/thumbnails/29.jpg)
Running a “while loop” Running/stopping the
program within a while loop Use finger tool to toggle
Boolean control to true (dull green arrow becomes bright green)
Use finger or arrow tool to “run” program (NB not continuously run)
Program will now run continuously
Use finger or text tool to change/edit numeric controls
Use finger tool to toggle boolean control to stop program
![Page 30: LabView Physics 3 - IT skills Miles Padgett m.padgett@physics.gla.ac.uk.](https://reader038.fdocuments.us/reader038/viewer/2022110205/56649cc15503460f949885d0/html5/thumbnails/30.jpg)
Using LabView to draw a sine curve
Objective To plot a sine curve in the range 0-
10 Start a new program
Select “new VI” from the file menu Save it now
Select “save” from the file menu and when prompted provide name
![Page 31: LabView Physics 3 - IT skills Miles Padgett m.padgett@physics.gla.ac.uk.](https://reader038.fdocuments.us/reader038/viewer/2022110205/56649cc15503460f949885d0/html5/thumbnails/31.jpg)
Using a “for loop” Show the diagram Select a “for loop” from
the structure palette Place the “for loop” on
the diagram “click” “drag” “release”
A “for-loop” will run N times then stop
i increments from 0 to N-1
For loopFor loop
Terminal for NTerminal for N
Terminal for iTerminal for i
![Page 32: LabView Physics 3 - IT skills Miles Padgett m.padgett@physics.gla.ac.uk.](https://reader038.fdocuments.us/reader038/viewer/2022110205/56649cc15503460f949885d0/html5/thumbnails/32.jpg)
Wiring N on a “for loop” Show the front panel
Select digital control from the controls palette
Place control on front panel
Show diagram (If necessary) move
terminal of digital control to outside of loop
Wire digital control terminal to N terminal of for loop
NB one terminal is blue the other orange!
![Page 33: LabView Physics 3 - IT skills Miles Padgett m.padgett@physics.gla.ac.uk.](https://reader038.fdocuments.us/reader038/viewer/2022110205/56649cc15503460f949885d0/html5/thumbnails/33.jpg)
Understanding data types
Computers store number in different forms, e.g. Integers, 8 bit, 16bit, 32 bit - BLUE in
LabView Floats single precision, double precision -
Orange in LabView
![Page 34: LabView Physics 3 - IT skills Miles Padgett m.padgett@physics.gla.ac.uk.](https://reader038.fdocuments.us/reader038/viewer/2022110205/56649cc15503460f949885d0/html5/thumbnails/34.jpg)
Converting Data type Show either diagram or
front panel Right click (window) on
control or terminal and select “representation”
“click” on data type of choice to convert numeric
Do this to change numeric control to I32 integer
Edit numeric value to 100
![Page 35: LabView Physics 3 - IT skills Miles Padgett m.padgett@physics.gla.ac.uk.](https://reader038.fdocuments.us/reader038/viewer/2022110205/56649cc15503460f949885d0/html5/thumbnails/35.jpg)
Drawing a sine curve - defining the range (1) To define the 0-10
range Show diagram Select and place constant
outside loop - edit to 10 Select and place
outside loop Select and place multiple
function outside loop Wire “10” and “”””””“ into
“x” function
Selecting a constantSelecting a constant
Selecting Selecting
![Page 36: LabView Physics 3 - IT skills Miles Padgett m.padgett@physics.gla.ac.uk.](https://reader038.fdocuments.us/reader038/viewer/2022110205/56649cc15503460f949885d0/html5/thumbnails/36.jpg)
Drawing a sine curve - defining the range (2)
Select and place divide function inside loop
Wire “i “into quotient of divide
Wire numeric input through wall into denominator of divide
Select and place multiple function
Wire output of divide into multiply
Wire “10 x ””“ product through loop wall into multiply
![Page 37: LabView Physics 3 - IT skills Miles Padgett m.padgett@physics.gla.ac.uk.](https://reader038.fdocuments.us/reader038/viewer/2022110205/56649cc15503460f949885d0/html5/thumbnails/37.jpg)
Drawing a sine curve - calculating the value To calculate the sine
value Select and place sine
function inside loop Wire output of
multiply to input of sine
Wire output of sine to loop wall
Selecting sineSelecting sine
![Page 38: LabView Physics 3 - IT skills Miles Padgett m.padgett@physics.gla.ac.uk.](https://reader038.fdocuments.us/reader038/viewer/2022110205/56649cc15503460f949885d0/html5/thumbnails/38.jpg)
Drawing a sine curve - displaying the curve Show front panel
Select and place “waveform graph” on front panel
Show diagram (if necessary) move
waveform graph terminal outside loop
Wire wall of loop to waveform graph terminal
Selecting waveform graphSelecting waveform graph
![Page 39: LabView Physics 3 - IT skills Miles Padgett m.padgett@physics.gla.ac.uk.](https://reader038.fdocuments.us/reader038/viewer/2022110205/56649cc15503460f949885d0/html5/thumbnails/39.jpg)
Drawing a sine curve - displaying the curve (2) Show diagram
(if necessary) move waveform graph terminal outside loop
Wire wall of loop to waveform graph terminal
NB orange wire on outside of loop is thicker than inside Indicates wire carries
an array of numbers
![Page 40: LabView Physics 3 - IT skills Miles Padgett m.padgett@physics.gla.ac.uk.](https://reader038.fdocuments.us/reader038/viewer/2022110205/56649cc15503460f949885d0/html5/thumbnails/40.jpg)
Drawing a sine curve - running the program Use arrow tool to “run
continuously the program Adjust numeric control to
change number of points calculated
Use arrow tool to “stop” program when finished
Use text edit tool to rename x-axis of graph (angle), name of numeric control (number of data points) and name of waveform graph
![Page 41: LabView Physics 3 - IT skills Miles Padgett m.padgett@physics.gla.ac.uk.](https://reader038.fdocuments.us/reader038/viewer/2022110205/56649cc15503460f949885d0/html5/thumbnails/41.jpg)
Drawing a sine curve - modifying the program To make 10 range variable
Select and place digital control on front panel
Show diagram Delete 10product structure
and wire from outside loop to leave unwired loop entry
Move new numeric terminal to similar position
Wire in terminal to loop entry Run continuously and
experiment with changing the range
![Page 42: LabView Physics 3 - IT skills Miles Padgett m.padgett@physics.gla.ac.uk.](https://reader038.fdocuments.us/reader038/viewer/2022110205/56649cc15503460f949885d0/html5/thumbnails/42.jpg)
Drawing a sine curve - extending the program FFT (1) To obtain an FFT of the sine
wave Select and place FFT function
on diagram near existing waveform graph terminal - the route to FFT is
• Functions• Analyse• Signal processing• Frequency domain
Wire waveform graph (or neighbouring wire to Input of FFT function
Selecting FFT functionSelecting FFT function
![Page 43: LabView Physics 3 - IT skills Miles Padgett m.padgett@physics.gla.ac.uk.](https://reader038.fdocuments.us/reader038/viewer/2022110205/56649cc15503460f949885d0/html5/thumbnails/43.jpg)
Drawing a sine curve - extending the program FFT (2)
Wire waveform graph (or neighbouring wire to Input of FFT function
On front panel place additional waveform graph
On diagram wire output of FFT function to terminal of waveform graph
Use text tool to edit name of waveform graph and x axis of graph on front panel
![Page 44: LabView Physics 3 - IT skills Miles Padgett m.padgett@physics.gla.ac.uk.](https://reader038.fdocuments.us/reader038/viewer/2022110205/56649cc15503460f949885d0/html5/thumbnails/44.jpg)
Drawing a sine curve - seeing the FFT
Run program continuously
Update range control Examine FFT of sine
wave Note the FFT has two
peaks Note FFT peaks have
+ve and -ve values
![Page 45: LabView Physics 3 - IT skills Miles Padgett m.padgett@physics.gla.ac.uk.](https://reader038.fdocuments.us/reader038/viewer/2022110205/56649cc15503460f949885d0/html5/thumbnails/45.jpg)
Drawing a sine curve - seeing the power spectrum (1) More usual to consider the
power spectrum Need to take modulus squared
of each FFT component Delete wire between FFT and
waveform graph terminal (if necessary) move terminal of
waveform graph away from FFT Select and place modulus
function after FFT Select and place multiply
function after modulus Wire FFT to modulus Wire modulus to both inputs of
multiply Wire multiply to waveform
graph terminal
![Page 46: LabView Physics 3 - IT skills Miles Padgett m.padgett@physics.gla.ac.uk.](https://reader038.fdocuments.us/reader038/viewer/2022110205/56649cc15503460f949885d0/html5/thumbnails/46.jpg)
Drawing a sine curve - seeing the power spectrum (2) Power spectrum is +ve Still twin peaked Run program
Note that a higher “frequencies” of sine wave power spectrum peaks move towards centre
Double peaks can be through to represent +ve and -ve frequency
![Page 47: LabView Physics 3 - IT skills Miles Padgett m.padgett@physics.gla.ac.uk.](https://reader038.fdocuments.us/reader038/viewer/2022110205/56649cc15503460f949885d0/html5/thumbnails/47.jpg)
Using LabView to draw a 2D function
Objective To plot an “egg box” type pattern
Start a new program Select “new VI” from the file menu
Save it now Select “save” from the file menu
and when prompted provide name
![Page 48: LabView Physics 3 - IT skills Miles Padgett m.padgett@physics.gla.ac.uk.](https://reader038.fdocuments.us/reader038/viewer/2022110205/56649cc15503460f949885d0/html5/thumbnails/48.jpg)
Double nested “for loop” A single for
loop will create a vector of N elements
To create an array use a for loop within a for loop
![Page 49: LabView Physics 3 - IT skills Miles Padgett m.padgett@physics.gla.ac.uk.](https://reader038.fdocuments.us/reader038/viewer/2022110205/56649cc15503460f949885d0/html5/thumbnails/49.jpg)
Useful tips - copying and moving items on the diagram To move a selection of functions and wires on a
diagram Use arrow tool to define rectangle of interest, i.e. click
upper left and drag to lower right Use cursor keys to move selected region
To copy a selected section of the program Use arrow tool to define rectangle of interest, I.e. click
upper left and drag to lower right Use standard copy and paste functions to replicate
program
![Page 50: LabView Physics 3 - IT skills Miles Padgett m.padgett@physics.gla.ac.uk.](https://reader038.fdocuments.us/reader038/viewer/2022110205/56649cc15503460f949885d0/html5/thumbnails/50.jpg)
Calculating the “egg box” Assume an egg box is
generated by taking the product of two sine functions (one in the x-direction and one in the y)
Use double nested loop and repeat logic of previous program, note Both N terminals of loop wired
to control i indices of loops wired to form
x and y axis Out wired through inner loop to
form output from outer loop
![Page 51: LabView Physics 3 - IT skills Miles Padgett m.padgett@physics.gla.ac.uk.](https://reader038.fdocuments.us/reader038/viewer/2022110205/56649cc15503460f949885d0/html5/thumbnails/51.jpg)
Visualising the “egg box” (1) Show front panel
Select and place intensity graph on front panel
Use text tool to rename x-axis, y-axis and name of graph
Selecting an intensity graphSelecting an intensity graph
![Page 52: LabView Physics 3 - IT skills Miles Padgett m.padgett@physics.gla.ac.uk.](https://reader038.fdocuments.us/reader038/viewer/2022110205/56649cc15503460f949885d0/html5/thumbnails/52.jpg)
Visualising the “egg box” (2) Show diagram
(if necessary) move terminal of intensity graph to outside of nested loop
Wire output from outer loop to terminal of intensity graph
NB note orange wire becomes “double wire” which indicates it is an array
![Page 53: LabView Physics 3 - IT skills Miles Padgett m.padgett@physics.gla.ac.uk.](https://reader038.fdocuments.us/reader038/viewer/2022110205/56649cc15503460f949885d0/html5/thumbnails/53.jpg)
Useful tips - Polymorphic In LabView, most
functions are polymorphic. e.g.. the same addition
function will add two numbers or two vectors or two arrays (vectors or arrays must have the same dimensions
Adding numbersAdding numbers
Adding vectorsAdding vectors
Adding arraysAdding arrays
![Page 54: LabView Physics 3 - IT skills Miles Padgett m.padgett@physics.gla.ac.uk.](https://reader038.fdocuments.us/reader038/viewer/2022110205/56649cc15503460f949885d0/html5/thumbnails/54.jpg)
Running the “egg box” Show front panel
Use finger or text tool to set numeric controls to ≈100 loop iterations and a plot range of ≈30
Run or run continuously the program
Need to set z-axis of graph to autoscale
• “right click” (window) on graph, select z-scale and select autoscale z
Auto-scaling the z-axis of an intensity graphAuto-scaling the z-axis of an intensity graph
![Page 55: LabView Physics 3 - IT skills Miles Padgett m.padgett@physics.gla.ac.uk.](https://reader038.fdocuments.us/reader038/viewer/2022110205/56649cc15503460f949885d0/html5/thumbnails/55.jpg)
Useful tips - changing the number format Previously we have seen how
to change the range over which a numeric control can be varied
To change the way it is displayed Show front panel “rick click” (windows) on
control Select “format and precision” Edit forma and precision
window as desired NB this only affects the
display NOT the precision of the calculations
![Page 56: LabView Physics 3 - IT skills Miles Padgett m.padgett@physics.gla.ac.uk.](https://reader038.fdocuments.us/reader038/viewer/2022110205/56649cc15503460f949885d0/html5/thumbnails/56.jpg)
The challenge - diffraction patterns To calculate and display the far field
diffraction pattern of a circular aperture The far field diffraction pattern of a circular
aperture is the same form as the Fourier-transform (but in 2D)
In the first instance “forget” about the wavelength (which sets the scaling between the aperture and the diffraction pattern) - just concentrate on the “shape”!
![Page 57: LabView Physics 3 - IT skills Miles Padgett m.padgett@physics.gla.ac.uk.](https://reader038.fdocuments.us/reader038/viewer/2022110205/56649cc15503460f949885d0/html5/thumbnails/57.jpg)
Useful functions for challenge (1) “Comparison” functions
allow logic decisions NB wire carrying logic, i.e.
Boolean (0..1) date are green
When defining the aperture, you may need “select” “less” or “greater”
Use LabView’s help to understand these functions
![Page 58: LabView Physics 3 - IT skills Miles Padgett m.padgett@physics.gla.ac.uk.](https://reader038.fdocuments.us/reader038/viewer/2022110205/56649cc15503460f949885d0/html5/thumbnails/58.jpg)
Useful functions for challenge (2) “array” functions allow
manipulations of array and vectors Wire containing array data
appear a two parallel wires. These may be blue (for integer)or orange (for floats)
When doing the FFT, you may need “transpose” “rotate 1D array”
Use LabView’s help to understand these functions
![Page 59: LabView Physics 3 - IT skills Miles Padgett m.padgett@physics.gla.ac.uk.](https://reader038.fdocuments.us/reader038/viewer/2022110205/56649cc15503460f949885d0/html5/thumbnails/59.jpg)
Useful functions for challenge (3) If the N terminal is left unwired,
“for loops” will self-index When a vector is wired into a
“for loop” the loop will split the array and run it on each element
When an array is wired into a “for loop” the loop will split the array and run it on each row
To switch off “self-indexing” right click (windows) on wire entry to loop and select “disable indexing” (not needed in challenge)
vector to elementvector to element array to vectorarray to vector
![Page 60: LabView Physics 3 - IT skills Miles Padgett m.padgett@physics.gla.ac.uk.](https://reader038.fdocuments.us/reader038/viewer/2022110205/56649cc15503460f949885d0/html5/thumbnails/60.jpg)
Useful functions for challenge (4) Standard LabView does
not have a function for 2D FFT
Given a 2D array, a 2D FFT can be completed by doing 1D FFT’s on each row and each column
You may need this when calculating the diffraction pattern - note use of “self-indexing”
A component of a “diagram” for completing a 2D FFT
![Page 61: LabView Physics 3 - IT skills Miles Padgett m.padgett@physics.gla.ac.uk.](https://reader038.fdocuments.us/reader038/viewer/2022110205/56649cc15503460f949885d0/html5/thumbnails/61.jpg)
Diffraction pattern Run your programme
Do you get a diffraction pattern centred in the four corners?
This is a issue with most FFT algorithms - where should the zero “frequency” be located? At the centre or the edges?
We need to centre our zero in the middle of the image
![Page 62: LabView Physics 3 - IT skills Miles Padgett m.padgett@physics.gla.ac.uk.](https://reader038.fdocuments.us/reader038/viewer/2022110205/56649cc15503460f949885d0/html5/thumbnails/62.jpg)
2D FFT with zero at centre Can use “1D rotate
function to move zero to centre (NB need to rotate by N/2)
Note also modulus squared added to output of FT to give power spectrum (i.e. light intensity)
![Page 63: LabView Physics 3 - IT skills Miles Padgett m.padgett@physics.gla.ac.uk.](https://reader038.fdocuments.us/reader038/viewer/2022110205/56649cc15503460f949885d0/html5/thumbnails/63.jpg)
Calculating a diffraction pattern
One program that works! Autoscale-z
switched off and z-scale set to reveal structure
![Page 64: LabView Physics 3 - IT skills Miles Padgett m.padgett@physics.gla.ac.uk.](https://reader038.fdocuments.us/reader038/viewer/2022110205/56649cc15503460f949885d0/html5/thumbnails/64.jpg)
Calculating a diffraction pattern
One program that works