Note that there is only 1 word available to pack this data and only 15 bits of the word can be used.

My suggestion is in the attached PDF file. Resolution is pretty low but if you have to do what is asked, "pack 4 pieces of data into 15 bits" of course it will be low.

Quote:

I need to be able to encode/mask and decode the values of 4 PLC tags being written to the RFID Tag.

So if I have four PLC tag values that I need to put on the RFID tag for example:

Tag 1 (35.3)

Tag 2 (400.1)

Tag 3 (75.4)

Tag 4 (112.7)

The sum total is 623.5 since the RFID tag can only hold a 16 bit integer value. I can multiple it by 10 and that's 6235 I can write that value on to the RFID tag no problem I can get that far.

It's when the RFID tag passes another reader and it reads a value 6235 I can divide the value by 10 and bring it back to its original value of 623.5 but I need to be able to decode that value and know that it is comprised of the following:

Tag 1 is 35.3

Tag 2 is 400.1 and so on

That's the problem I'm having decoding the RFID tag when it passes another reader, if it displays a value of 6235, it means nothing to anyone else but me as I know that the value comprises of four PLC tag values.

So what I'm asking is there a method of decoding the sum total and retrieving the original four PLC values solely using Codesys to convert the sum total 6235 back to the original 4 PLC values.

Apologies I haven't been clearer it hasn't been easy from your point of view as I have kind of said the same thing to you twice regarding arrays when arrays are not the issue.

I can post the thread in the forum no problem it's just a very specific issue and if you're busy that's no problem either.

I was just looking for an opinion on how to approach this.

Thanks for your help

My answer to this problem is in the attached PDF file. Note that the values in my pdf file for the range of each piece of data came in a prior PM to me.

I don't believe what you want to do is possible
you have 4 4 bit words to work with binary value of 4 bits = 0-15
all1"s would only yield 15 15 15 15 split out the way you show
I don't see any way to make it work just adding the values together will not work because you have no way to separate then without knowing the values before hand.
you may have to pick 2 of the 4 values that will give you 2 8 bit words each word = 0- 255 you may be able to work with that