Instrument Control (GPIB, Serial, VISA, IVI)

Showing results for 
Search instead for 
Did you mean: 

Send Hex string over Modbus to SMC Actuator

Go to solution
Accepted by Lazer723

NO!!!! Just NO!!!!


This code is just plain ridiculous! Why format it in normal display in hex format with space delimiters using 3x more momory, just to strip it all out nanoseconds later.


Here's code that gives exactly the same output as yours!

(note the correct representation of the controls!)




You NEED to do a few tutorials and understand the difference between a hex formatted string using characters 0..F and a binary string where each character can be anything from 00 to FF). You also need to understand the display style of strings.


Also note that your FOR loop and shift register is just pure Rube Goldberg code! Compare the two alternatives:




I also strongly recommend to stay away from stacked sequences. There is a reason they are no longer in the palettes!

0 Kudos
Message 11 of 13

Ah yes. It seems I have a lot to learn about hex strings and 'text' strings and type casting in Labview!

Sorry, this is my first foray into digital types.


So if I understand correctly, finally, inputting the hex data into a hex-displayed string actually stores the data in binary (a binary string?) rather than ascii, which leaves it free to be easily reinterpreted into any desired numerical representation. And the Type cast block formats the input into the same hex displayed string (binary string?) that is connected to at the output. So the string concatenate block is now in binary string mode as soon as you wire a hex-string to it? Or is it in fact that everything is always in binary string mode but the 'regular' string just displays the binary in ascii. Still not used to the whole non-text string thing, but I think I'm getting there.


I was also not aware that the Hex to number vi works with arrays as well, that's pretty neat and definitely neutralises my loop.


Thanks for the code





0 Kudos
Message 12 of 13

The display style of a string is a purely cosmetic property and does not change the actual string data. But yes once a string is in hex display, it know what to do when you enter data.


Typecast just blindly does big endian and never generates errors. If you need more control, you can use "flatten to string.


A string is a string is a string. ASCII is just a convention how to interpret bit patterns to alphabetic characters.

0 Kudos
Message 13 of 13