Compact GuardLogix MSG result tag conversion dint to ascii

Jake98

Member
Join Date
Aug 2023
Location
Mattawan
Posts
1
Im trying to use a MSG instruction to get the serial numbers of all addon cards and display the serials on a HMI interface. I have the logic done and everything works except that the MSG returns a number instead of raw string. The number converts to ASCII characters but I want a plain string to show on the HMI. All of the logic is written inside of an AOI which uses a IN/OUT to import the message result.

EX. MSG Returns Dint(-794295010)
Converted to ASCII would be String("$D0$B2$C2$EC")
What I want is String("D0B2C2EC")

Software: Studio 5000 Rev 34.011
Controller: 5069-L306ERS2
 
I am not sure about the syntax, but this might work:



VAR
lcldint : DINT;
nibble : DINT;
hexchars : STRING(16); := '0123456789ABCDEF'; (* The sixteen hexadecimal characters in character positions .DATA[1] to .DATA[16] *)
String_result : STRING(8);
END_VAR;

lcldint := input_argument;

FOR i=8 to 1 BY -1 DO (* Loop over output string characters from right to left *)
nibble := lcldint AND 15; (* Bit-wise and of low four bits *)
lcldint := lcldint / 16; (* Shift next four bits to the right *)
String_result.DATA = hexchars.DATA[nibble+1]; (* Next hex character *)
END_FOR;

 

Similar Topics

gents, I am trying to configure communication with EMERSON PK300 controller through port A1 using generic ethernet communication module . I could...
Replies
0
Views
98
I had a comms fault between my VFD and Controller (5069-L320ERS2) that started about a month ago and happened maybe once a day to now where it...
Replies
1
Views
286
Hi I am having comms issues between Citect 8.2 and Compact Guardlogix. 2023-07-14 07:50:54.788 +10:00 [ERROR] [CORE ] [0x114c] [IOServer...
Replies
2
Views
885
Hi all, we have a 1768 compactlogix 5345s safety controller firmware 20.14. it is randomly giving a major fault and a minor fault. the minor...
Replies
7
Views
1,412
I have an installation with a Compact GuardLogix 5380 CPU [5069-L306ERS2] that is experiencing a strange issue I have never encountered before...
Replies
15
Views
2,781
Back
Top Bottom