as a Word document

advertisement
Practice P1-1 Random Number Generator
Using of the input button of parallel port to interrupt the random number, and showing
random number outputs value to seven-segments display.
On the LabVIEW module please connect J3 to J12 and J5 to J11.
1. The hardware circuit is as follows
2. Please execute LabVIEW program, in the Front Panel select All Controls ► Modern ►
Array, Matrix & Cluster ►Array, and setup the input name as „output data of seven
segments display“. As well, also please select All Controls ► Num Ctrls ► Num Ctrl,
and add it to the array of „output data of seven-segments display“.
3. Now please change the numerical format as Unsigned 8 Byte (U8), and change Decimal
format into Hexadecimal format at Display Format.
4. Next please input sixteen records of data, one after another is C0, F9, A4, B0, 99, 92, 82,
F8, 80, 90, 88, 83, C6, A1, 86 AND 8E. Respectively. Why we want to setup above values?
In order to have an easily mapping relationship to the output statement of seven segments
display, its worth to create a data table for it. Please also select All Controls ► Num Inds.
► Num Ind, and input the name as “Random Number”. This indicator will be used to
display the calculated result of random number. The more functional explains of this
indicator will be described on step 6th .
5. In the Block Diagram window, select All Functions ► Programming ► Structures ►
While loop, drag a new function blocks.
6. Please select All Functions ► Mathematics ► Numeric ► Random Number(0-1) and
iside it into the while Loop´s frame. As well, also select All Functions ► Mathematics ►
Numeric ►Quotient & Remainder and wire each connection as following. Because we
want easily to perform the 0~9 range of the random number generation, the value of random
number generation is divided by value “0.1”.
7. Please select All Functions ► Programming ► Array ► Index Array, connect the index
of array to output of random number, and connect the input array to “output data of seven-
segments display”
8. Please select All Functions ► Connections ► Port I/O ► Out Port.vi, establish the
register address as hexadecimal input format, and key-in the number 378 which means the
data will be on the data bus, the output data will be just a byte to parallel port default.By
now we have established the function of successfully transferring the arithmetic figure
“0~9” into the output of seven-segment displays, therefore the “output data of sevensegments display” will be decided by the input random number of Index Array.
9. Please select All Functions ► Connectivity ► Port I/O, establish the register address as
hexadecimal input format, and key-in the number 379 which means the data will reading
from status register. Next create the constant “false” to read a byte or a word that is
represented to read a byte.
10. Please select All Functions ► Programming ► Boolean ► And and again select All
Functions ► Programming ► Boolean ► Not equal to 0 ?. The whole wiring
relationship between each terminal is as follows. At the end of AND, we add the
hexadecimal number 10 to determine the forth bit status register. Because the keysroke
switch is on the 13th pin of the parallel port, that is just corresponding to the forth bit of the
status register. When the input keystroke has pressed, it will interrupt loop and stop the
random number generator. As well, the last value of random number generated will be
displayed on the circuits of seven-segments display.
11. Finally please select All Functions ► Programming ► Timing ► Wait(ms), and add the
value 100 for 100ms time-delay. We expect ewery 100ms to generate a new random number
and show on seven-segments display.
12. Everything is done. Run your completed program to check if some input keystrokes have
been pressed. Is the seven-segments display terminated or not?
Download