PLCS.net - Interactive Q & A

PLCS.net - Interactive Q & A (http://www.plctalk.net/qanda/index.php)
-   LIVE PLC Questions And Answers (http://www.plctalk.net/qanda/forumdisplay.php?f=2)
-   -   Packing Data Into a Tag (http://www.plctalk.net/qanda/showthread.php?t=100288)

ndzied1 January 12th, 2016 06:47 AM

Packing Data Into a Tag
 
1 Attachment(s)
I received this via PM but am re-posting it here so all can see.

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.

gclshortt January 12th, 2016 08:41 AM

Nice approach.
Was the resolution OK with the application?

ndzied1 January 12th, 2016 11:16 AM

Quote:

Originally Posted by gclshortt (Post 673322)
Nice approach.
Was the resolution OK with the application?

I think so. He seemed pretty happy but not sure the lack of resolution has set in yet....

KalleOlsen January 12th, 2016 12:11 PM

What about using bit 0 and 1 as index 0-3, and use bit 2 to 14 as value holder?

More complicated, better resolution.

Kalle

gclshortt January 12th, 2016 12:16 PM

I was thinking the same thing kalleOlson but:

This is on a TAG.

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

Regards,

ndzied1 January 12th, 2016 12:34 PM

Just to confirm, Garry is right. Sorry if it was not obvious. The request was to pack 4 pieces of data into an RFID Tag with only 15 bits available.

GaryS January 12th, 2016 12:38 PM

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

ndzied1 January 12th, 2016 12:45 PM

Oh, I'm sure what I presented will work as advertised. Whether or not the OP can live with the super low resolution I have no idea.

widelto January 12th, 2016 01:22 PM

Norm: Simple but efficient


All times are GMT -5. The time now is 02:15 AM.

.