Array of SINTs (Hex) to Strings

janner_10

Lifetime Supporting Member
Join Date
Dec 2014
Location
Tewkesbury
Posts
1,301
We have a IFM DTE102 RFID Reader. PLC is L82E v32

It presents the results into an array of SINTs, I have to select HEX as the style in the tag editor so it matches with the IFM web browser monitor.

All is good, it works, I can see the results.

I now need to convert my results, say E0 C4 00 63 62 in Hex into a string.

So when the Hex result on SINT[0] for example is 16#E0, I need the string to read E0, this is the bit I am struggling with.

If i can do one, I can do the rest and concat at my leisure, so the results keep the customer paying!

Any ideas?

TIA
 
The results make no sense - However the customer just wants a unique number so, thinking as I type the Hex thing may be a red herring!
 
ControlLogix has a DINT to String (DTOS) and a REAL to String (RTOS) instruction, but not "HEX to String".

To do this you would have to run a loop, separating out each 4-bit section of each SINT and converting it to ASCII.

The brute force method is just to look at the ASCII chart; (48 + X) gives you the digits 0 through 9, and (55 + X) gives you ASCII values 65 through 70, "A" through "F".

I wrote a little subroutine that you could imitate, or roll up into an AOI if you wished.
 
Ken meant 65 for A to F

It is true that ASCII 65 = "A" and ASCII 70 = "F".

But we're extracting a four-bit value between 10 and 16 from the series of hex stuff, so the value of the "nibble" itself is already at least 10.

I added that "nibble" to 55 to get the desired ASCII character.

I typed 65 the first time I tried it, and wondered why I got "K" through "P" in my string !
 
- Do bitwise AND with 0x0F mask on the first array byte

- Add to the result 0x30 or 0x37 instead if the result is equal or greater than 0x0A and you will get the Ascii code for the first character.

- Bit shift the original byte 4 positions to the right.

- Repeat from the beginning and you will get the second character Ascii code

- Repeat for the other elements of the array.
 

Similar Topics

Hello, I will try to be as succinct as possible, and hopefully this will make some sense. Say, in Logix Designer, I have a generic Ethernet...
Replies
5
Views
5,063
Hi, I'm having an issue in crimson 3.0 when I create a programme using a case statement referencing a fault word that each bit needs to change the...
Replies
4
Views
189
I am trying to copy an array of real numbers into a UDT with a real data type element. I have attached a snip below showing my COP instruction...
Replies
4
Views
203
I have an array of 55 REAL values. Is there a way to multiply based on the array location ? I have 55 transfer belts that are equally spaced...
Replies
3
Views
152
Hello everyone, I'm working on a project that involves controlling an array of nozzles within a CNC environment, where the nozzles travel along a...
Replies
5
Views
176
Back
Top Bottom