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 ?
Help appreciated
Hi I was looking at the instruction help in Studio V. 32 and there are ASCII conversion instructions. Click the drop down and select "Dint to String". You would probably have to convert the hex to a Dint but maybe not. I remember doing some of this converting a hex to decimal in alarm logic for a job I did last summer however I've misplaced the copy of the program. Hope this helps.
I have tried DTOS instruction and it unfortunatly only returns the decimal value to the string, I have not found a way to force it to report HEX.
Thanks for the reply.
MOV dint_tag tmp_dint_tag CLR string_tag.LEN 0
AND tmp_dint_tag 15 tmp_4_dint_tag CONCAT string_array[tmp_4_dint_tag] string_tag string_tag SUB tmp_dint_tag tmp_4_dint_tag tmp_dint_tag DIV tmp_dint_tag 16 tmp_dint_tag
AND tmp_dint_tag 15 tmp_4_dint_tag CONCAT string_array[tmp_4_dint_tag] string_tag string_tag SUB tmp_dint_tag tmp_4_dint_tag tmp_dint_tag DIV tmp_dint_tag 16 tmp_dint_tag
AND tmp_dint_tag 15 tmp_4_dint_tag CONCAT string_array[tmp_4_dint_tag] string_tag string_tag SUB tmp_dint_tag tmp_4_dint_tag tmp_dint_tag DIV tmp_dint_tag 16 tmp_dint_tag
AND tmp_dint_tag 15 tmp_4_dint_tag CONCAT string_array[tmp_4_dint_tag] string_tag string_tag SUB tmp_dint_tag tmp_4_dint_tag tmp_dint_tag DIV tmp_dint_tag 16 tmp_dint_tag
AND tmp_dint_tag 15 tmp_4_dint_tag CONCAT string_array[tmp_4_dint_tag] string_tag string_tag SUB tmp_dint_tag tmp_4_dint_tag tmp_dint_tag DIV tmp_dint_tag 16 tmp_dint_tag
AND tmp_dint_tag 15 tmp_4_dint_tag CONCAT string_array[tmp_4_dint_tag] string_tag string_tag SUB tmp_dint_tag tmp_4_dint_tag tmp_dint_tag DIV tmp_dint_tag 16 tmp_dint_tag
AND tmp_dint_tag 15 tmp_4_dint_tag CONCAT string_array[tmp_4_dint_tag] string_tag string_tag SUB tmp_dint_tag tmp_4_dint_tag tmp_dint_tag DIV tmp_dint_tag 16 tmp_dint_tag
AND tmp_dint_tag 15 tmp_4_dint_tag CONCAT string_array[tmp_4_dint_tag] string_tag string_tag SUB tmp_dint_tag tmp_4_dint_tag tmp_dint_tag DIV tmp_dint_tag 16 tmp_dint_tag
DestString.LEN := 12;
for i := 0 to 5 do
// Lower four bits if incoming SINT to second ASCII character
Temp := Source & 15;
if Temp < 10 then
DestString.DATA[2*i+1] := Temp + 48;else DestString.DATA[2*i+1] := Temp + 55;
end_if;
// Upper four bits if incoming SINT to first ASCII character
Temp := (Source & 240) / 16;
if Temp < 10 then
DestString.DATA[2*i] := Temp + 48;else DestString.DATA[2*i] := Temp + 55;
end_if;
end_for;
