09-23-2019 09:18 AM
Hi,
I am working on a serial number code converter which stores 5 digit serial numbers as 3 digit alphanumerical codes. For this project I need a way of creating an array of base 36 numbers, however I cannot find a way to convert decimal numbers to base 36 strings in Labview.
Does anyone know of a simple way to do such a conversion? Any help would be much appreciated.
My organisation is only running Labview 2014, so any VIs need to be compatible with that, thanks.
Solved! Go to Solution.
09-23-2019 09:38 AM
I had never heard of base36 until now. If your serial number is only 5 decimal digits, why would you even need to convert to a 3 digit base-36 number? It doesn't seem to give you much advantage is saving space.
I think it is so uncommon that it is unlikely you will find anyone with ready-made VI's.
I think you'll just need to google some algorithms and code them yourself in LabVIEW. I imagine that you will need a look-up table of some sort to convert the letters to their decimal equivalent. And the Quotient Remainder Function will likely come in handy.
09-23-2019 09:39 AM
09-23-2019 09:43 AM
Thanks for the response.
Unfortunately the base 36 code has been chosen by our customer; it certainly provides a challenge for me as I'm still fairly new to LabVIEW.
I have found a perfect VI that converts from base36 to decimal, post linked below. Is there an easy way to reverse engineer this to work backwards?
https://forums.ni.com/t5/LabVIEW/CONVERT-BASE-36-TO-DECIMAL/m-p/728370/highlight/true#M333385
09-23-2019 09:50 AM
Hi mars,
Is there an easy way to reverse engineer this to work backwards?
Yes.
It involves some Quotient&Remainder functions and a simple conversion (using a LUT/look-up table) to convert the base36 values into readable chars.
It's a nice project to actually learn some LabVIEW basics, like loops with shift registers and autoindexing, array handling, …
09-23-2019 09:57 AM
If you want to learn to code in LabVIEW, take this as an opportunity to figure it out on your own. The Wikipedia article has a C implementation. Use this as a guide.
09-23-2019 11:12 AM
@mmarsden23 wrote:
I have found a perfect VI that converts from base36 to decimal, post linked below. Is there an easy way to reverse engineer this to work backwards?
https://forums.ni.com/t5/LabVIEW/CONVERT-BASE-36-TO-DECIMAL/m-p/728370/highlight/true#M333385
I'd rather use the Altenbach-version....
09-24-2019 03:34 AM
That version does seem a little cleaner. I'm not sure how a matrix just full of 256 0's can be considered a lookup table, however. What is being "looked up", just the index position?
I'm not sure my coding ability is able to reverse engineer this one, even though I know the theory behind for loops etc, I don't think I'm ingenious enough to figure this stuff out yet.
09-24-2019 04:01 AM
Many thanks for posting that version Alex. I've managed to adapt it into converting my 1D array.
09-24-2019 05:09 AM
@mmarsden23 wrote:
That version does seem a little cleaner. I'm not sure how a matrix just full of 256 0's can be considered a lookup table, however. What is being "looked up", just the index position?
he posted a previous version, which is easier to read :
base36StringToDecimalString.vi 10 KB
it's not completely filled with 0 - there are 35 non-zero values
what do you think do these numbers represent?
there's also a reason, why there are 256 elements in the LUT
you may also want to read the quite short help for the "string to byte array" function
https://zone.ni.com/reference/en-XX/help/371361R-01/glang/string_to_byte_array/