Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

VISA Write/Read Hex/String

Hi Sir, 

 

For the communication with some sensors or BLE, we need to write the Hex data, also read the Hex data, then parse to what we want.

 

But looks like the VISA VI is accept string, also output string.

 

Normally, how should be set this ?

Thanks.

 

 

Brzhou_0-1680236169606.png

 

Learning from other people
0 Kudos
Message 1 of 10
(1,594 Views)

Do you have more details on the data frame?  For reading, you need to use the format of the data frame to read it properly.

 

When dealing with non-normal display format strings, make sure the Display Visibility is turned on for your controls/indicators/constants.


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 2 of 10
(1,569 Views)

Hi Sir,

 

Sorry for late reply, I had a business trip to Vietnam for two weeks.

The background is that I purchase a temperature sensor, from the instruction of the sensor:

 

send :  01 03 00 02 00 02 65 CB 

and also get back some hex value like that.

 

So that is the reason i asked this, how to deal with this when the sensor accept hex data and return hex data.

Thanks.

Learning from other people
0 Kudos
Message 3 of 10
(1,476 Views)

Hi

Hex is a translation of integer, or other number representations in hexadecimal.

 

Attached a vi in LabVIEW 2020  that translates the first part of your string into a 16 bit integer. (I16)

And also translates that back to the same string even with the leading zero by asking for 4 places.

 

This should help you in realising your own translation dependend on the integer type(s) used.

greetings from the Netherlands
0 Kudos
Message 4 of 10
(1,448 Views)

Thanks for your info,

What is the difference for hex display and normal display:

 

Brzhou_0-1682171932086.png

 

Also for the output, we need to convert like this ?

Brzhou_1-1682172251493.png

 

Learning from other people
0 Kudos
Message 5 of 10
(1,441 Views)

@Brzhou wrote:

What is the difference for hex display and normal display:


Normal display shows the string as ASCII characters.  Hex display will show the hexadecimal representation for every byte.  For instance, if you have the string "301" in normal display, it will show as "3330 31" is hex display.

 

 


@Brzhou wrote:

Also for the output, we need to convert like this ?


Since you have not given us information on the content of the messages, we cannot say how to do the conversion.


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 6 of 10
(1,408 Views)

Understand.

 

"301"  --> 33 30 31

But finally this will impact the content to VISA write or not ? or just different kind of display to us ?

Thanks.

Learning from other people
0 Kudos
Message 7 of 10
(1,401 Views)

Visa needs a string, so you need to convert the numbers into a string.

greetings from the Netherlands
0 Kudos
Message 8 of 10
(1,395 Views)

@Brzhou wrote:

Understand.

 

"301"  --> 33 30 31

But finally this will impact the content to VISA write or not ? or just different kind of display to us ?

Thanks.


Only the display to us is different.  The bytes in the string are the same.


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 9 of 10
(1,390 Views)

Thanks both for your reply.

Learning from other people
0 Kudos
Message 10 of 10
(1,361 Views)