ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Conversion to Base 36

Solved!
Go to solution

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. 

0 Kudos
Message 1 of 11
(6,701 Views)

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.

0 Kudos
Message 2 of 11
(6,678 Views)
0 Kudos
Message 3 of 11
(6,677 Views)

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

0 Kudos
Message 4 of 11
(6,672 Views)

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, …

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 11
(6,663 Views)

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.

aputman
0 Kudos
Message 6 of 11
(6,655 Views)
Solution
Accepted by topic author mmarsden23

@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....

base36.png

 

Message 7 of 11
(6,613 Views)

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.

0 Kudos
Message 8 of 11
(6,562 Views)

Many thanks for posting that version Alex. I've managed to adapt it into converting my 1D array. 

 

 

0 Kudos
Message 9 of 11
(6,556 Views)

@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

 

SIMPLE-LUT.PNG

what do you think do  these numbers represent?

Smiley Wink

 

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/

 

 

 

 

0 Kudos
Message 10 of 11
(6,547 Views)