LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

RS232 in LabVIEW

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

0 Kudos
Message 11 of 19
(794 Views)

Number to Hexdecimal String followed by Reverse String.  Look at the string palette.  There are lots of useful functions in there.

 

Lynn

 

Hex string.png

0 Kudos
Message 12 of 19
(782 Views)

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.

0 Kudos
Message 13 of 19
(769 Views)

There may be other ways.  But this one should work

 

.

0 Kudos
Message 14 of 19
(755 Views)

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.

0 Kudos
Message 15 of 19
(751 Views)

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.

0 Kudos
Message 16 of 19
(747 Views)

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

0 Kudos
Message 17 of 19
(738 Views)

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.

0 Kudos
Message 18 of 19
(724 Views)

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.

0 Kudos
Message 19 of 19
(720 Views)