01-02-2014 07:05 PM
Sorry for bugging again,
As I was controlling my motor, turns out my motor can go from a value between -240,000 and 240,000 for a full rotation. I was wondering if there's a way to convert a numeric control into a hexadecimal value and then parse the entire hexadecimal number in two bytes each?
For example if my icoming number was -240,000 which is 8056FCFF in hex, can I parse it to be 80 56 FC FF? Same for 240,000 where the hex value is 80A903 to 80 A9 03?
Thanks again,
butterwafle
01-02-2014 07:30 PM
Number to Hexdecimal String followed by Reverse String. Look at the string palette. There are lots of useful functions in there.
Lynn
01-02-2014 08:41 PM
Sorry for bothering yet again,
I am trying to send my position number, but when I am printing out the hexadecimal string through an indicator I am not getting the value that I want in the correct order.
FOr example, if I try to print out 240,000 in hex I end up getting 00003A980 when I really want 80A90300.
The same goes for when I want to print out -240,000 in hex, I end up getting 0FFFFFFFFFFFC5680 when all I want is just 8056FCFF
In my attachment I have the image of the code I'm trying to currently fix.
01-02-2014 09:10 PM - edited 01-02-2014 09:11 PM
There may be other ways. But this one should work
.
01-02-2014 09:13 PM
May I ask what are those tube looking things that are covering the reverse string block?I can't seem to find it in the string palette.
01-02-2014 09:15 PM
Typecast.
It is on the Numeric >> Data Manipulation palette.
The picture is a snippet. You can drag and drop it on a block diagram to get the actual code to poke around with.
01-02-2014 09:26 PM
Thank you I seem to have got it, my only problem now is that when I type in any number except 0 I end up displaying a 14 byte hex number. But if it is 0 then it will just display 00000000.
What I mean is that if I type in the value 1, I will end up printing out 10000000000000
01-02-2014 09:56 PM
Post your code so we can see what you are doing.
You aren't showing a 14 byte hex number, you are showing a 14 character hex number. which is only 7 bytes.
It seems like you are using the wrong representation. You should be using an I32 which is only 4 bytes, thus 8 characters in a hex formatted number that is fully padded with zeroes.
01-02-2014 10:03 PM
Nevermind I just saw my problem-- turns out I was using a signed 64-bit number instead of a signed 32-bit number, doh!
Thanks for the help everybody! I'll be sure to post if I have more questions.