LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

convert string with hex to byte and back to string

Hello everybody,

i have a problem, which i can't solve. From an GPIB instrument i get an answer. It's a string like "00ffffff". This hex-data i want do convert in byte with all zeros!!! After this, i want write an string over GPIB with the converted data like "00000000,11111111,11111111,11111111;" Can anybody help me????

PLEASE!!!!

Thanks Thomas
0 Kudos
Message 1 of 9
(3,830 Views)
Hi,

I made a quick example, it can probably be made easier, but I hope this can get you started:
0 Kudos
Message 2 of 9
(3,821 Views)
Sorry, your question is not entirely clear.

Is "00ffffff" a 4byte string containing four hexadecimal characters x00 and xFF or is it a 8 byte string containing the numbers 0 and letters f?

If you want to "convert" it to a byte with all zeroes, you can just use a diagram constant with all zeroes, because it is independent of the input.
Can you explain?

The attached VI (LabVIEW 7.0) shows two possible solutions to write your desired string output, depending on the actual input format.
Message 3 of 9
(3,816 Views)
Altenbach,

I think the received data is actually HEX, such as 0x00FFFFFF. He want to represent that value to binary, as in: 0000 0000 1111 1111 1111 1111 1111 1111 b
Then take this binary and convert it to string, probably using TypeCast in order to have a string representation of the binary. This way, you can transit it using the serial port.

However, the question is: does the instrument expect a string that looks like: 00000000 11111111 11111111 11111111 b?

If so, then convert the number to it's binary equivalent and Typecast it to string, right?

-JLV-
Message 4 of 9
(3,811 Views)
My interpretation was quite literal for the output, otherwise the "," and ";" in it would be quite misleading and the surrounding double quotes would not make much sense. 😉

Of course anything is possible, so we are waiting for further clarifications from thomla. 🙂
Message 5 of 9
(3,803 Views)
thanks for your answers,...

the incoming data is a message from gpib and this is a string with characters for example: "data:00ffffff". this string i receive by the gpib read function. I think these are all characters. Then i can split the answer in "data:" and the rest "00ffffff". And after this i'll convert the rest-string of "00ffffff" to and binary expression which should be "0000000111111111111111111111111". This binary data i must convert in to a string which i can send with the gpib write function. this string have to be "data:00000000,11111111,11111111,11111111;". This means i need the first part "data:" and the second part with the converted binary expression, which is divided by an "," after eight postions and ended with a ";" at the last postion.

i hope now it's all clear for you and you can help me, please.

Thanks all!

Thomas
0 Kudos
Message 6 of 9
(3,795 Views)
The attached should do what you need (LabVIEW 7.0).

(You don't really need the binary intermediary result, but the second attached example shows how to display it.)

Message Edited by altenbach on 05-17-2005 11:43 AM

Download All
Message 7 of 9
(3,788 Views)
hey altenbach,

yes that's it what i need. my own solve for this problem is the vi asciitobitstoascii.vi i have attached it.

the base for it was StringtoBits.vi....Thanks!!! I think that was to difficult for me, because i'am a beginner of labview.

How can you learn such combination of functions? The books in german i do know, tells only the basics. Were they other good resources, where i can learn it better?

Thanks for solving this problem!

Ciao Thomas
0 Kudos
Message 8 of 9
(3,779 Views)
Hello,

here is a link to a book:
http://digital.ni.com/worldwide/germany.nsf/sb/Literature?OpenDocument&node=163360_d

We offer courses:
http://digital.ni.com/worldwide/germany.nsf/sb/Customer+Education?OpenDocument&node=163206_d

If you need more Information you cann call us:
Tel.: +49 89 / 741 31 30 | Fax: +49 89 / 714 60 35

And you can use our big example library:
http://www.ni.com/devzone/dev_exchange/ex_search.htm



Markus Weigl
NI Germany
0 Kudos
Message 9 of 9
(3,753 Views)