Showing results for 
Search instead for 
Did you mean: 

convert an array of hexadecimal numbers to decimal numbers and write to spreadsheet

i'm trying to acquire data from a micro-turbine and there are a set of commands which i use to communicate with it. For example, the SPVDAT command gives an output in this format : SPVDAT,<turbno>=0,6,<ARG0>,<ARG1>,<ARG2>,<ARG3>,<ARG4>,<ARG5>


Sample output: SPVDAT,0=0,6,0,0,0,20,0,0


ARG 0-5 are the values i need and these are in hexadecimal format; the rest of the stuff is not important. I need these values converted to decimal numbers and written to a spreadsheet.


I've attached the original VI and a modified VI where we attempted to convert HEX to decimal. Unfortunately, my output is a bunch of zeros which led me to believe something was wrong.


This is just one command. Different commands have different number of arguments ranging from 1 to 20 ARG's! One other command (ALLDAT) has close to 15 sub-commands within it, each with varying ARG's, all in hexadecimal format.


Would appreciate any help...thanks!

0 Kudos
Message 1 of 12



I don't have labview 2011, so I can't open you program. if you save it for previous versions (I have 2010), I could take a closer look.


It appears you're getting this arguments from VISA, so you're reading them as strings. Once you've parsed the string you received (I'd like to take a look in the software to comment on this) you can use function block "hexadecimal string to number" in order to convert it. The value displayed will be converted to decimal if your indicator is configured to show values in decimal base.




0 Kudos
Message 2 of 12

I've attached files saved in previous version.

0 Kudos
Message 3 of 12

You have a classic race condition.  You are reading data from the serial port and writing it to a local variable.  You then expect the other loop to read at the same rate to save to disk.  Local variables are NOT a good way to do this.  You can miss data, have stale data, and it just isn't a good idea.  You should look into using a queue to send the data between the loops or putting all of the code into a single loop.


The other thing I see is that your Write to should have %d for its format.

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
Message 4 of 12

I was afraid of that, thank you crossrulz. Would that solve my conversion problem (HEX to decimal)? I could use any help in setting up the VI !!


Thanks again



0 Kudos
Message 5 of 12

I'm sure this is a bit of a rube goldberg (especially how I get the string subset). You can probably use a regular expression to more cleanly get the string between the equals sign and the "new line", but I'm regex illiterate. Anyways, Does this do what you need it to?


0 Kudos
Message 6 of 12

A slightly more elegant regex to perform the task.


Regex to pick data between equal and eol.png


If you had multiple lines you could place this in a loop and put the offest past match into a shift register and then process all of the lines. Other regular expressions could be created which would be specific other commands if required.

Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 7 of 12

@Mark_Yedinak wrote:

A slightly more elegant regex to perform the task.


Regex to pick data between equal and eol.png

HA, i knew it was possible! Time to get a regex book...

0 Kudos
Message 8 of 12

Hello again,


I tried out the regex solution you suggested. The "Match Regular Expression" is taking in the input string and Regex, but there is no output from it at all, once we tested it with the turbine. Could use your help with this. We tried another way of splitting the string at the regex and i've attached that VI. This is for just one input command.


We have another command, "ALLDAT" with 21 sub-commands. The output would look something like the following, in HEX code like the earlier problem :




This is one block of data and i need to just separate the necessary values. For eg: the 1st sub-command, ENGDT1 has 8 ARGS (7d4,1,17,c,f,32,0,0) and the last, CHPDAT has 2 ARGS (00000041,0). I just need the ARG's from each sub-command. I was thinking of putting it in a loop, but since this is one single block of output, i'm not sure how well that would work.


Thanks again for the help!

0 Kudos
Message 9 of 12

this may help you out


Array hex to decimal.png

0 Kudos
Message 10 of 12