ASCII character conversion to Hex

Noob_MW

Member
Join Date
Feb 2020
Location
Ireland
Posts
25
Hi All,


have a quick one new enough to this type of programming, I am using a Allen Bradley point IO with 1734-232ASC card to send out data, I have some simple commands which are easy to convert E.G. /1ZR to hex will be $2F $31 $5A $52


but I have a command that goes /1A300R I know the first 3 characters will be $2F $31 $41 but for the 300 would anybody know how to convert this, I would appreciate any help or advice,


Thanks in advance


Noob
 
Going by you own example, it would be ASCII "3" = 33 hex, ASCII "0" = 30 hex.

But I think that you are complicating something that is probably very simple.
The values are not converted between ASCII and Hex. These are merely different representations of the same bit-patterns.
The data is probably stored in either an array of CHARS, or in a STRING.
If you need to send the command /1A300R then you just send a STRING with the value '/1A300R'

Disclaimer: I have no experience with 1734-232ASC. I am just assuming things.
 
Hi JesperMP,


Thanks for the quick reply, I have a quick snip attached of what I am trying to send but would they need a $ sign in front of them also would you think,


thanks again

Command array.PNG
 
Okay, it is an array of CHARs. It should be good as far as I can see.
edit: It may actually be a STRING, rather than an array of CHARs. I am not familiar with RSLogix5000. If you expand .LEN and it becomes 2 parts, then it is a STRING.
The $ is merely a visual indicator when programming, that the value is shown with hexadecimal representation.
Similar, the ' ' (the apostrophes) is a visual indicator that values are shown as CHARs (i.e. with ASCII encoding).
 
Last edited:
Hi All,


have a quick one new enough to this type of programming, I am using a Allen Bradley point IO with 1734-232ASC card to send out data, I have some simple commands which are easy to convert E.G. /1ZR to hex will be $2F $31 $5A $52


but I have a command that goes /1A300R I know the first 3 characters will be $2F $31 $41 but for the 300 would anybody know how to convert this, I would appreciate any help or advice,


Thanks in advance



Noob

Hi, perhaps this may help.

ASCII to Hex converter.PNG
 
Hi JesperMP,


Thanks for the quick reply, I have a quick snip attached of what I am trying to send but would they need a $ sign in front of them also would you think,


thanks again
Jesper is spot on, that is a string within RSLogix/Studio5000. With that you shouldn't need to do any conversion, RSLogix will do it for you. If you simply want to know what each character is in Hex, do a google search for "ASCII Table" and you will get all kinds of tables.
 

Similar Topics

Hi, How would I write a program to get the PLC to calculate a value for a set of characters in a string? I'm using RSLogix 500 and a SLC 5/05...
Replies
1
Views
1,661
I'm trying to read in ASCII strings from an RS232 card reader to an AB 5/03. I get some strange characters in my string. As you can see in the...
Replies
8
Views
7,831
Hello, I am reading several BYTES from a PLC which each represent one ASCII character. How do I convert this so that WinCC will display the...
Replies
3
Views
5,144
Unregistered
U
Hi all, My requirement is to send out escape character ( and also enter , line feed characters)from MicroLogix serial port configured in ASCII...
Replies
3
Views
7,539
Hi, We couldn’t find anything specific, so am starting a new thread. I’m trying to migrate a config from a ML1400 to a micro820 & am experiencing...
Replies
1
Views
109
Back
Top Bottom