Sending ASCII data in Hex format?

skkn

Member
Join Date
Aug 2013
Location
Wisconsin
Posts
11
Can someone help me to find instruction which stores ASCII characters to String data type tag and Is it possible to convert an ASCII string to Hex (hexadecimal) format?

My printer accepts ASCII characters in Hex format. I have a gateway from RTA which takes data in String tag and transfers it to printer which accepts ascii data using TCP/IP.
I am using Control Logix PLC.
 
You are mixing concepts in your question.

ASCII is a defined code for text (visible characters) and format control characters (like linefeed and carriage return).

Hex(adecimal) is a method for displaying the contents of a binary word by showing a code for each group of 4 bits. The codes are the characters 0-9 and a-f.

Can you provide a link to the manual for your printer and also point out where it defines 'characters in Hex format'?
 



Here is what documentation of printer said. It actually uses ESI protocol.
"The printer communicates with ASCII characters. All characters sent to the printer over RS-232, RS-485, or Ethernet must be sent as ASCII characters. As you will see many commands are written in there hexadecimal form, this is for the ease of presentation for the writing of the documentation, since all the characters in the ASCII table are not printable and may be difficult to represent or write. The "[ ]" denotes that the characters between the brackets are the hexadecimal value of the ASCII character that will be sent to the printer. You will see several control characters. The TAB character [09] is used to separate multi line message it is the character that represents the line terminator. The carriage return "[0D]" represents the message terminator this is added to the end of the entire message string to terminate the message.
[09] = TAB Character
[0D] = Carriage Return (Message Terminator)


Examples of Message Structure


Command:[1B][00][00]
Request Printer Status
Response from Printer:
[07][05] Print OFF
[07][06] Print ON


 
in there hexadecimal form, this is for the ease of presentation for the writing of the documentation

So you see, they are showing the hexadecimal form for clarity. It does not affect the sending. The ASCII will be sent in their standard form. Now, the 'ESI' protocol sounds like a data protocol (which command codes are used and how they are interpreted by the printer) as opposed to a transmission protocol (how the transfer of information is handled on the Ethernet cable). I have no information on whether TCP/IP transmission is supporter by ControlLogix.

Here is an interface unit which may help.
 
Last edited:
Thank you for your reply. I already bought that RTA unit which sends ascii data from Control Logix to TCP/IP device. You are correct, ESI is data protocol. I have all these commands in hexadecimal form. Was not sure how to convert it into ascii and send it through PLC.
 
The control codes ARE ASCII characters. The upper hex character is either 0 or 1.

Assuming you are using a string tag in the ControlLogix PLC simply fill one with the required control characters (using the RSLogix5000 tag monitor/editor) ending in the 0D (Carriage Return) control characters. Set the string length to the number of control characters including the terminating CR. (Edit - actualoly the editor will properly set the length for you.)

You should set these up in seperate strings from the one used for communication to the RTA device then use the COP command to copy them into that communication string when they are needed.

The RTA device will see the non-zero length, copy out the characters and send them to the printer. It will also zero the string length. This is the clue for your PLC code to place another string (using COPy) into the communication string.

We have used Ethernet <-> RS485 Gateways from RTA. The 'String Length' method of handshaking (both directions) makes the PLC code incredibly easy.
 
Last edited:

Similar Topics

Hello, Thanks in advance. How can I send more than 82 characters using AWA or AWT? to Zepra Printer via serial Rs232 communication? Normally I...
Replies
1
Views
758
I am very new to programming PLCs, and one of the first tasks I received was to create a program that creates a socket connection between my PLC...
Replies
5
Views
2,534
I am new to programming in PLC, i have Allen Bradley SLC 5/03. I tried using AWT inst. with data in ST9:0 file directly but in 3 inst. getting...
Replies
4
Views
4,047
:wish:Hello I want to sent the commands attached from PLC to DMX Controller.When i00 command is sent it replies as shown as fig in hyperterminal...
Replies
2
Views
2,050
Hi, I am trying to get Allen Bradley Micrologix 1400 to send ASCII commands over a RS-485 2 wire connection. I can get PuTTy to communicate just...
Replies
5
Views
9,082
Back
Top Bottom