LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Formatting command/response to Serial Port using RS-232

Solved!
Go to solution

I am trying to write commands to change the settings on a device using RS-232.  I am unsure how to best format the string command.  Attached is my VI and some images from the user manual of the device on how the messages should be formatted. Serial_example_capture.PNGSerial_example_capture2.PNG

Download All
0 Kudos
Message 1 of 7
(3,704 Views)
Solution
Accepted by topic author LeroiVinncent

It seems like what you are doing is okay.  It is a combination of control codes (hex 02 and hex 03) and visible ASCII characters.  Make sure control codes are in hex codes display like you have, but make the display style visible so it is obvious.

 

Since your response end with a carriage return, you should make your termination character "D" in the constant wired to the VISA Configure.  And set the radix to be visible on that constant so it is obvious it is hex.

Message 2 of 7
(3,697 Views)

So just some clarifying questions:
1. The termination character should be "D", and with the radix on it says "xD" and this should be in hex format, correct?

2. Do I have it correct that the checksum includes the values between STX and ETX? (not including the STX or ETX)

3. When I concatenate the string constants, should STX and ETX appear as hexadecimal [x02] and [x03] ,respectively? and the other commands such as *CALHH200000, are those to be in "normal display" in the program? How does the * character work?

 

 

Thank you,

0 Kudos
Message 3 of 7
(3,649 Views)

Also for the checksum I enter *CALHH200000 but I don't get a hex value of "B1" like it says in the example.

0 Kudos
Message 4 of 7
(3,648 Views)

@LeroiVinncent wrote:

So just some clarifying questions:
1. The termination character should be "D", and with the radix on it says "xD" and this should be in hex format, correct?

2. Do I have it correct that the checksum includes the values between STX and ETX? (not including the STX or ETX)

3. When I concatenate the string constants, should STX and ETX appear as hexadecimal [x02] and [x03] ,respectively? and the other commands such as *CALHH200000, are those to be in "normal display" in the program? How does the * character work?

 

 

Thank you,


 

 

1.  Yes.

2.  I interpret it as including the STX and ETX

3.  Yes, STX and ETX should appear as 02 and 03 in the string constants, with an x in the border when you turn on Display Style Hex.  The rest should appear that way in normal display.

Message 5 of 7
(3,645 Views)
Solution
Accepted by topic author LeroiVinncent

@LeroiVinncent wrote:

Also for the checksum I enter *CALHH200000 but I don't get a hex value of "B1" like it says in the example.


I was able to calculate the Checksum "B1" for the command using this algorithm

 

fp.PNG

 

bd.png

 

 

However it doesn't work with the "Response". I get "CB" vice "CA". Could it be a typo in the users manual?

 

If you look at syntax for the response data, it specifies a "*D..." but the example uses a "#D..." No matter which symbol I use, it still doesn't result in the example's checksum.

 

fp response.PNG

Message 6 of 7
(3,627 Views)

@jamiva wrote:

However it doesn't work with the "Response". I get "CB" vice "CA". Could it be a typo in the users manual?

 


Looks like you are off by exactly 1 bit.  So 1 character is off.

 

Not likely the problem, but I am noticing a space in the response that is not in the command.  How sure are you that the space is supposed to be in there?


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 7 of 7
(3,576 Views)