09-11-2011 12:44 PM
Hi there! i am making a vi to check the lamp hours of my projector Sony. I send an Hexadecimal command that is: A901 1301 0000 139A . When the projector receives it respond with 1901 1302 0031 339A. 0031 is the data that i have to convert to decimal because it tells me how many hours we have used the lamp. How can i get that string readed separated to get only the third part of hexadecimal numbers converted to decimal? Thanks in advance!
Solved! Go to Solution.
09-12-2011 04:27 AM
I have found here some examples, but i cannot make them work for my problem. Anyone? Thanks!
09-12-2011 04:35 AM - edited 09-12-2011 04:36 AM
Hey roundish!
As the data is in a String format, then the Hexadecimal String to Number VI should work fine in this instance.
To grab only a particular numeral from that String to use in the Hexadecimal String to Number VI, then I'd suggest using the String Subset VI; this returns a specified segment of a string. By modifying the offset input which determines what part of the String the data begins to be parsed from, and changing the length to control the amount of characters to be parsed, you'll be able to grab the character you want to convert.
Regards,
09-12-2011 05:23 AM
Hi! Thank you so much Alex!!! It worked pretty well. Let me post for the forum my example code. Thanks!
09-14-2011 11:45 AM
Ho again! i have another problem now, the string i am reading is in Hexadecimal format, so when i maked that vi it worked, but when i use it on the projector i always return the value 0. I have checked the hexadecimal option on the display style so i receive the data but the conversion doesn't work. This is the code, thx in advance.
09-14-2011 12:11 PM
What is the data you are getting from the VISA read look like?
Earlier you were converting Hex formatted strings to data. But now you are actually sending Hex data to the VISA Write. So I'd think you'd be getting similar data back. In which case converted from hex formatted strings would be wrong.
Are you getting data like "0" and "F" (2 characters), or a hex value such as 0F, (one byte)?
09-14-2011 01:43 PM
09-14-2011 02:02 PM
You need to use typecast to convert the string data to the appropriate datatype.
09-14-2011 02:41 PM
09-14-2011 05:08 PM
No No No.
Get rid of that hexadecimal string to number conversion.
Just take your string bytes and typecast them.