Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

RS232 Question

Status
Not open for further replies.

markaut

New Member
Hi All,
I am trying to get a computer to tak to a piece of laboratory kit. Comms should be via RS232, but the details seem to be unclear, even with the manual. My aim is to be able to drive it via hyperterminal, then script the commands, possibly via autoit.

From the manual it says:
The format of the command string is:

STX Command block ETX Checksum

The checksum is the hex equivalent of the modulo 256 of the sum of the ASCII values of the characters in the command block string.

So an example command could be:

STX GD ETX checksum

would have the ASCII command as ^BGD^C90

The checksum calc is STX=(Hex) 2, G=47, D=44, ETX=3 giving a checksum of 90.

I'd be very grateful for any help with the following:

How does STX change to ^B and ETX get to ^C?
Why does STX and ETX equate to hex values of 2 and 3 respectively?
If my checksum addition equalled 257, would the checksum value equal 1?

Many thanks for any help offered.
--
Mark.
 
From the manual it says:
The format of the command string is:

STX Command block ETX Checksum

The checksum is the hex equivalent of the modulo 256 of the sum of the ASCII values of the characters in the command block string.

So an example command could be:

STX GD ETX checksum

would have the ASCII command as ^BGD^C90

The checksum calc is STX=(Hex) 2, G=47, D=44, ETX=3 giving a checksum of 90.
I agree checksum=90 (hex)

How does STX change to ^B and ETX get to ^C?
Why does STX and ETX equate to hex values of 2 and 3 respectively?
Making the charater into a control character by pressing the Control key on the keyboard strips the high bits as shown below:
Code:
Character      Binary        Hex
  C             0100 0011    43
ctrl C          0000 0011    03
Thus ctrl C is the same as the ASCII character STX which has the hex value of 3.

If my checksum addition equalled 257, would the checksum value equal 1?
Yes

JimB
 
You make it all very simple! It hadn't even occurred to me that The caret (sp?) indicated control! Many many thanks for giving me the insight into working it all out.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top