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!
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.
I've attached files saved in previous version.
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 Spreadsheet.vi should have %d for its format.
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 !!
A slightly more elegant regex to perform the task.
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.
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!