LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

ASCII to hexadecimal

Solved!
Go to solution

 

Hi there,

 

 

 

I am trying to send a hex string to my Profibus card. The string represents a serial number that I read from a file serial.txt. The number has 9 digits which i convert to hexadecimal string.

 

To be able to write to the Profibus device I need to send a command first to let the network know that I am sending the MSB and so on.

 

Example:

 

If I want to write serial umber 111111111 to Profibus I need to follow the following procedure:

 

 

Convert d111111111 - 0x69F6BC7

 

To send the MSB in this case 06 I need to send the following hex sting

 

1306 0000 0000 0000 for the MSB 

 

149F 0000 0000 0000 for the MSB - 1 

 

156B 0000 0000 0000 for the MSB -2  

 

16C7 0000 0000 0000 for the LSB 

 

As a procedure I convert the number to a hex integer and then I use the string subset function to select the first byte and then concatenate the string with the write command 0x13. But the function string subset outputs ascii string. How can I subset and then concatenate an hex string?

 

Please see the attachment.

 

0 Kudos
Message 1 of 5
(3,312 Views)

Hi Marken,

 

that should do the trick and is pretty self-explaining (once you use the context help) Smiley Wink

23902i23A1AA56BFC78E0C

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 5
(3,305 Views)

Hi GerdW,

 

Very kind of you to replay so quick, thank you.

 

I have implemented your suggested method and I am very impressed works fine for sending the hex stings.

 

I have selected the first element of the 1D array of string and try to send it to my Master Profibus function but creates a conflict.

As you see in the diagram the cluster sent to the Master vi has the slave address which always will be 1 so I can hard wire a constant plus the hex string of 1306 for example.

 

How can I convert the 1D string array to the unsigned byte array ?

 

Thanks again for your time please see the attachment.

 

Kind Regards

Marken

 

 

0 Kudos
Message 3 of 5
(3,285 Views)

Hi GerdW,

 

Very kind of you to replay so quick, thank you.

 

I have implemented your suggested method and I am very impressed works fine for sending the hex stings.

 

I have selected the first element of the 1D array of string and try to send it to my Master Profibus function but creates a conflict.

As you see in the diagram the cluster sent to the Master vi has the slave address which always will be 1 so I can hard wire a constant plus the hex string of 1306 for example.

 

How can I convert the 1D string array to the unsigned byte array ?

 

Thanks again for your time please see the attachment.

 

Kind Regards

Marken

 

 

Download All
0 Kudos
Message 4 of 5
(3,285 Views)
Solution
Accepted by topic author Marken

Hi Marken,

 

my FOR loop creates an Array of Strings (4 Strings for each byte of the U32 value). You have to index the string you want to process, then you can convert the string to [U8]...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 5
(3,281 Views)