LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Can express VI, Build Table, display two numerical representations?

I have a string,converted to a number, and two other numbers built into an array. The string that is converted to a number is actually a hex number read from a serial device. I am using the express VI, Build Table, to display the data on the from panel. The problem is that I want to display the one result as hex and the other two as a fractional with two digits of precision. Is there a way to do that or is it better to do it from scratch and not use the express VI in this case? Any help would be appreciated.

Thanks,
Troy
0 Kudos
Message 1 of 11
(3,657 Views)
The express VI can only, afaik, convert to a single representation. If you use individual Format Into String functions for each column of data, you can easily display the data you want. If you were to open the express VI, you'd see that this is the function being used there. If you're not familiar with the function, the format string for converting to hex is %x and for a fractional with 2 digits of precision, it's %.2f.
0 Kudos
Message 2 of 11
(3,645 Views)
Thank you for the reply. I am painfully finding out that is the case. So let me take this one step further. I have a hex string that I received from the device under test. If I could get that hex string converted to a numerical hex equivalent, that would solve my problem. I have been all over the place trying to find out how to convert a hex string to a hex number and have not been having much luck. I know you can convert a hex string to a number but that converts it to decimal. I need the hex equivalent of the hex string. Any ideas? Thanks again.
0 Kudos
Message 3 of 11
(3,640 Views)
Well, if you want to display the result in a table, you should just leave it as a string since a table is 2D string array. But, if you want a numeric indicator, set it to U32 representation, in format & precision set it for hex, and then use Scan From String with a %x format string.
0 Kudos
Message 4 of 11
(3,636 Views)
Dennis - Thanks again for the reply. Maybe I am not explaining myself clear enough. I am fairly new to Labview so I may be having trouble getting my real problem through. I have three parameters that I got back from my unit under test, two decimal numerics and one hex string. I am trying to display them all in a table on the front panel. When I do a hex string to number conversion it converts it to a decimal display and I want to keep it hex. That is the jist of my problem. I have tried it two ways. The first was with the express VI to build a table. The second was to display them in an array. Either way I am geting the decimal equivalent instead of the hex. Maybe my methodology for trying to display this is wrong. Would you have any other ideas as how to display these two different data types in the same table?
0 Kudos
Message 5 of 11
(3,633 Views)
Here's a little example that shows how to write to a table the way I think you want it. I included two string string controls that are displaying a floating point number because I'm not sure if you UUT is truly returning numbers or the string representation. If you are still having problems after looking at the example, could you attach your program so someone could look at it. It would also help if you could save front panel indicators with data representative of what you are actually getting back from the UUT.
0 Kudos
Message 6 of 11
(3,631 Views)
Dennis - Here is my program. I ran it a little bit to show you the data that I want to show up as hex. I noted on the front panel and on the block diagram where I want the hex string to show up as a hex number. From the front panel right click on the table and select Find Terminal to take you to the part that I am having trouble with. Thanks.
0 Kudos
Message 7 of 11
(3,628 Views)
As I said in my first post, get rid of the build table express VI. You can skip the Hex String To Number and just convert the two numerics to a string with the Format Into String function. I've attached a modified version of yourVI that should work better.
0 Kudos
Message 8 of 11
(3,626 Views)
I have already done that and it works ok. I just find it hard to believe that something as simple as a decimal to hex conversion is so hard to come by in Labview with all of its other versatility. Anyway, one last thing and I believe I will be done with this part of the VI. Now that I am using the array and results table instead of the express VI, how do I get the table on the front panel to append the data instead of over writing it each time? Again thanks for your help.
0 Kudos
Message 9 of 11
(3,623 Views)
Express VIs are great for doing some things but they lack some of the versatility of the regular functions. Because of your mix of data types that you wanted to represent, the Express VI was unsuited to the task and the modification I made to your program is actually simpler (just look at how much code is inside the build table Express VI some time.

As to your second question, you will need to have a shift register maintain the contents of the table so that each repetition of the loop will append new data to the table. In the smiple example that I had attached in an earlier post, there is a shift register doing exactly that. I initialize the shift register at the start of the program with an empty 2D array. Each time the Add button is pressed, it takes the new row and appends it to the existing 2D array that is connected to the table. At some point, you might also want to consider redoing your program to eliminate all of those sequence structures. They make programs harder to read and debug. I would add some error in/error out connections to your serial VI. This would help you enforce dataflow without using sequences. It would also help track down problems shen an error does occur.
0 Kudos
Message 10 of 11
(3,620 Views)