Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

How do you implement a lookup table?

I'm reading in 5 parallel TTL lines which signify filter center frequencies for a box I'm simulating. I want to convert that string of 5 binary values into the actual center filter values (e.g. 5.4 MHz, 7.3 MHz, etc.) I have using an Excel lookup table, and want that displayed on the LabVIEW GUI to the user. It's a lot easier for my users to read a value (e.g. 5.4 MHz) than it is to read 01010 and look that up by hand. How can I do that using LabVIEW?
Thanks
0 Kudos
Message 1 of 6
(4,398 Views)
Hi Tsimpkins!

Well, there are a couple ways of doing this. The straight forward way of doing this would be to just use a case structure whose input is the binary value and whose output is the corresponding numerical value. To do this, you will need a case for each possible input/output (this may not be what you want if this is a huge lookup table).

The second method would be to actually implement the mathematical conversion formula in LabVIEW. Meaning, if you have 10101010 and it is supposed to translate to xxxxxxxx, there is probably a mathematical formula that can be used to do this. You can easily implement this mathematical formula in LabVIEW to do the translation.

I've attached a VI (written in LV 7.1) to help explain this.

I hope this helps!

Travis H.
National Instruments
Travis H.
LabVIEW R&D
National Instruments
0 Kudos
Message 2 of 6
(4,384 Views)


@tsimpkins wrote:
I'm reading in 5 parallel TTL lines which signify filter center frequencies for a box I'm simulating. I want to convert that string of 5 binary values into the actual center filter values (e.g. 5.4 MHz, 7.3 MHz, etc.) I have using an Excel lookup table, and want that displayed on the LabVIEW GUI to the user. It's a lot easier for my users to read a value (e.g. 5.4 MHz) than it is to read 01010 and look that up by hand. How can I do that using LabVIEW?
Thanks


The table I have has about 150 entries in it and they may/will change as we get into testing. That's why I was hoping I could have a table in Excel instead of a case structure. Nice to know I could use a case structure for that, and definitely for smaller number of outcomes, but that will be very laborious if and when values change. Any other advice or thoughts? I can't do the mathematical lookup either. There's no conversion formula that would fit for all values.
0 Kudos
Message 3 of 6
(4,376 Views)
Hi Tsimpkins,

If I were you, I would save the Excel file as a tab-delimited txt file. This way, you can read it into LabVIEW using the VIs in the I/O palette (Read Spreadsheet File.vi, etc). Note, tab-delimited txt file is considered a spreadsheet file in LabVIEW). You can then search through the string and find the code (1010101) that you are looking for and use the corresponding data (xxxxx). This would actually be pretty easy to do.

Hope this helps!

Travis H.
National Instruments
Travis H.
LabVIEW R&D
National Instruments
Message 4 of 6
(4,362 Views)
Have you considered using a Ring control? Either storing the human-readable values directly in a ring typedef control, or programmatically configuring the ring from the Excel lookup table.
0 Kudos
Message 5 of 6
(3,552 Views)

My initial thought was to just have an array constant that you can index from your binary values (convert then into an integer first).


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 6 of 6
(3,549 Views)