How to Convert Hex To String

RRoc

Member
Join Date
Jan 2017
Location
California
Posts
45
I'm trying to display a Allen Bradley Controller Serial Number that's in HEX to String for my SCADA to display.

Any ideas?
 
Yes I'm trying to do that inside my PLC so my SCADA Programmer does not have to worry about it.

I saw that thread. I'll look at it again.
 
Last edited:
Looks like he is masking the sint storing the result in temp and converting to ASCII equivalent

so for example 1F

first mask takes just the '1' portion
Xf0
ie mask is 1111 0000

result is 16#10 or 16
/16
gives 1
add 48
gives 49
which if you look up in ascii table is '1'

store in string

next mask you original SINT 1F
0x0f
0000 1111

result is
16#0f
or 15
add 48
gives 63 however ascii table 0-9 is 48-57 and 'A-F' is 65-70
so since our result is > 57 add another 7 to make it 70 in this case which happens to be ascii 'f'

so result is ascii '1' and ascii 'f'

hope this helps

ascii table http://www.asciitable.com/
 
Last edited:

Similar Topics

Hi I need to convert a DINT with HEX value e.g A0F15663 to a string with the same value 'A0F15663'. Any tips of good instructions to use ...
Replies
11
Views
3,402
We are doing some testing communicating serially with a linear actuator in order to get its current position using an Allen Bradley Compact Logix...
Replies
8
Views
21,180
I actually solved this, but I thought this info may help others. Condition which prompted this need: I was using a function provided to me by...
Replies
13
Views
3,756
Hey All, i have been fortunate enough to play around with an Applied Motion Products Servo Drive SV200 with 100 watt/ 24vdc congif. I managed...
Replies
2
Views
1,889
Good morning, I am running a controllogix and I am connected to a hydrocarbon gas alalyzer over an EWEB module. I am picking up a Hex number...
Replies
40
Views
13,938
Back
Top Bottom