130 likes | 224 Views
Lab 7 – Misc. pieces. Objective: Understand how to build and implement these components as needed within your design. How to create a SubVi How to convert from numeric value to string How to concatenate strings How to use logical data paths How to translate the origin. Creating a SubVi-
E N D
Lab 7 – Misc. pieces Southern Methodist University Bryan Rodriguez
Objective: • Understand how to build and implement these components as needed within your design. • How to create a SubVi • How to convert from numeric value to string • How to concatenate strings • How to use logical data paths • How to translate the origin Southern Methodist University Bryan Rodriguez
Creating a SubVi- This allows you to build a sheet and save it as block to be used in another sheet. This helps clean up and consolidate big and messy sub circuits. Southern Methodist University Bryan Rodriguez
Simplify your design to use constants whenever possible, and the fewest number of inputs and outputs. • In the top right corner of the lab sheet, right click on the logo box (shown below) and select “Show connector” • Each block is an input/output terminal. If you need more terminals, right click and select “Pattern” to find a different layout. • To assign a terminal, click on a terminal ( it should turn black) then click on its Numeric control or indicator to be assigned. • You can change the logo by right clicking and selecting “edit logo” Southern Methodist University Bryan Rodriguez
Implementing a SubVi- • In a different lab sheet go to the block diagram window. • Right click to add a component, select “Select a Vi” and search for your SubVi you saved. • Make necessary terminal connection. Southern Methodist University Bryan Rodriguez
Converting a Numeric value to a string- To do this you simply need to add the “Number to Decimal String” block in the block diagram. This block takes in a numeric value and converts it to a string. A sample connection is shown below: Southern Methodist University Bryan Rodriguez
Concatenate string- If you have multiple strings you would like to consolidate into one long string you can concatenate them into a single string. To do this you need the “Concatenate String” block from the block diagram window. This block takes in string components and appends them to one another. An example connection is shown below. Ex: String 1(upper left wire): 123 String 2(lower left wire): 456 Concatenate string output (right wire): 123456 Southern Methodist University Bryan Rodriguez
An example of how to use numeric to string and concatenate string with the TCP connection is shown below. To better understand how to use this, build the circuit show above and repeat the test procedures from Lab 2. You can also use this test or Lab 2 to test communications and ability to transmit data to your CSE students. Southern Methodist University Bryan Rodriguez
Logical paths- You can use logical operators, boolean values, and case statements to implement different data paths that are logically controlled. This means that you can change connections based on logic. In the example to follow, I am comparing two arrays so that I can use and display the smaller value of 2 arrays. I have built 2 1D arrays of 2 elements. I am indexing the arrays so that I can have accesses the second element of each array. I am comparing to see if the second element of the first array is less than the second element of the second array. If it is the “less than” block will output a TRUE. If it is not, the result will be a FALSE. I want to display and use the smaller of the two arrays. I can do this using a case statement. Southern Methodist University Bryan Rodriguez
The case statement allows you to define 2 distinct cases corresponding to a TRUE or FALSE value. The TRUE or FALSE signal should be connected to the “?” on the frame. On the top of the frame you can select between the 2 windows: TRUE and FALSE I connected a through path for my first array to the display if the result is TRUE and it is smaller. In the False frame, I made the connection for the second array to the display. Note: On the right side connection out of the frame you need to select “Use Default if Unwired” Try to build the example on the following slide to gain a better understanding of how this works. Blocks used: Numeric control Build array Index array Less? Case statement frame Numeric Indicator Southern Methodist University Bryan Rodriguez
Translating an origin’s coordinates- This can be done by subtracting the offset we want in each direction. In our example we have a resolution of 1024 x 786. We need to adjust our origin from the lower left corner to the center of our screen. We need an offset of 512 in the X direction and 384 in the Y direction. So we need to simply subtract these offsets from our obtained values. Southern Methodist University Bryan Rodriguez