From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

problem with concentrating string - hex

Solved!
Go to solution

Hello All,

I am at a loss,

A simple code for controlling a digital servo is taking me days instead of hours.

I guess I do not fully understand the ins and outs of hex strings.

I need to send to the servo a string composed of headers, the data and checksum.

the checksum part is solved.

and now I am trying to dynamically build the data and header string.

the problem is the the conversion of a number that represent the desired angle, I try to concentrate the string with the headers. but it appears that the final result is empty string instead of the header. as can be seen in the attached screen shot. although the headers concentrate correctly. when I see spaces after concentrating it with the angle data.

I have attached a screen shot and the VI in 2018 version.

Thanks!

GIl,

Download All
0 Kudos
Message 1 of 5
(1,090 Views)
Solution
Accepted by topic author GilMaor

You are mixing hex and ASCII (ie "Normal") displays.

 

1) The Number To Hex String just converts a number into an ASCII representation of the hexidecimal value.  You just want the raw value.  So use Flatten To String.

2) It looks like your value should just be 2 bytes.  So coerce the value to a U16 before flattening it.

3) It also appears that the value should be represented using Little Endianness.  Luckily, there is an input on the Flatten To String to do this for you.

4) Make sure all of your indicators are in the correct display format.  In this case, you want them all to be in "hex".


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Download All
0 Kudos
Message 2 of 5
(1,055 Views)

And just to put it all together with your previous thread...

NOTE: You will want the CRC calculation and adding to the end in a subVI since I am sure you will be needing to do this with a bunch of different commands.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 3 of 5
(1,052 Views)

You have some non printable characters which are displayed as spaces if your indicator is set to normal string. Switch it to hex and you will see your header. Conversion of the angle is wrong: I think you need that value to be converted into a binary string for which you can use Flatten to String function. From your expected result string it seems that this value should be stored using little endian order so I set it accordingly:

LucianM_0-1608390631557.png

 

Edit: I did not see @crossrulz already responded.

Lucian
CLA
0 Kudos
Message 4 of 5
(1,047 Views)

Thanks!

0 Kudos
Message 5 of 5
(991 Views)