You are not registered yet. Please click here to register!


 
 
plc storereviewsdownloads
This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc.
 
Try our online PLC Simulator- FREE.  Click here now to try it.

---------->>>>>Get FREE PLC Programming Tips

New Here? Please read this important info!!!


Go Back   PLCS.net - Interactive Q & A > PLCS.net - Interactive Q & A > LIVE PLC Questions And Answers

PLC training tools sale

Reply
 
Thread Tools Display Modes
Old January 12th, 2016, 07:47 AM   #1
ndzied1
Lifetime Supporting Member
United States

ndzied1 is offline
 
ndzied1's Avatar
 
Join Date: Aug 2002
Location: Chicago, Illinois
Posts: 2,357
Packing Data Into a Tag

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.
Attached Files
File Type: pdf Data Packing.pdf (894.3 KB, 77 views)
__________________
nOrM
======================
nOrM=Norman Dziedzic Jr.
"I decry the current tendency to seek patents on algorithms. There are better ways to earn a living than to prevent other people from making use of one's contributions to computer science." Donald Knuth

Last edited by ndzied1; January 12th, 2016 at 07:52 AM. Reason: additional information for clarity.
  Reply With Quote
Old January 12th, 2016, 09:41 AM   #2
gclshortt
Member
Canada

gclshortt is offline
 
gclshortt's Avatar
 
Join Date: Dec 2014
Location: Cobourg
Posts: 2,652
Nice approach.
Was the resolution OK with the application?
__________________
Garry
https://www.accautomation.ca
Connect with us on Facebook: facebook.com/accautomation/
  Reply With Quote
Old January 12th, 2016, 12:16 PM   #3
ndzied1
Lifetime Supporting Member
United States

ndzied1 is offline
 
ndzied1's Avatar
 
Join Date: Aug 2002
Location: Chicago, Illinois
Posts: 2,357
Quote:
Originally Posted by gclshortt View Post
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....
__________________
nOrM
======================
nOrM=Norman Dziedzic Jr.
"I decry the current tendency to seek patents on algorithms. There are better ways to earn a living than to prevent other people from making use of one's contributions to computer science." Donald Knuth
  Reply With Quote
Old January 12th, 2016, 01:11 PM   #4
KalleOlsen
Member
Norway

KalleOlsen is offline
 
Join Date: Oct 2008
Location: Norway (moustache area)
Posts: 1,762
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
  Reply With Quote
Old January 12th, 2016, 01:16 PM   #5
gclshortt
Member
Canada

gclshortt is offline
 
gclshortt's Avatar
 
Join Date: Dec 2014
Location: Cobourg
Posts: 2,652
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,
__________________
Garry
https://www.accautomation.ca
Connect with us on Facebook: facebook.com/accautomation/
  Reply With Quote
Old January 12th, 2016, 01:34 PM   #6
ndzied1
Lifetime Supporting Member
United States

ndzied1 is offline
 
ndzied1's Avatar
 
Join Date: Aug 2002
Location: Chicago, Illinois
Posts: 2,357
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.
__________________
nOrM
======================
nOrM=Norman Dziedzic Jr.
"I decry the current tendency to seek patents on algorithms. There are better ways to earn a living than to prevent other people from making use of one's contributions to computer science." Donald Knuth
  Reply With Quote
Old January 12th, 2016, 01:38 PM   #7
GaryS
Member
United States

GaryS is offline
 
GaryS's Avatar
 
Join Date: Aug 2003
Location: Lancaster Pa.
Posts: 779
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
  Reply With Quote
Old January 12th, 2016, 01:45 PM   #8
ndzied1
Lifetime Supporting Member
United States

ndzied1 is offline
 
ndzied1's Avatar
 
Join Date: Aug 2002
Location: Chicago, Illinois
Posts: 2,357
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.
__________________
nOrM
======================
nOrM=Norman Dziedzic Jr.
"I decry the current tendency to seek patents on algorithms. There are better ways to earn a living than to prevent other people from making use of one's contributions to computer science." Donald Knuth
  Reply With Quote
Old January 12th, 2016, 02:22 PM   #9
widelto
Member
Colombia

widelto is offline
 
widelto's Avatar
 
Join Date: Jul 2005
Location: barranquilla
Posts: 2,593
Norm: Simple but efficient
__________________
My two cents.
  Reply With Quote
Reply
Jump to Live PLC Question and Answer Forum

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Topics
Thread Thread Starter Forum Replies Last Post
Understanding RSLogix5000 I/O Base Tag Addressing Structure blanchsb1 LIVE PLC Questions And Answers 9 October 16th, 2015 07:42 AM
Reading data block from plc to a tag in wincc karofilakis LIVE PLC Questions And Answers 7 September 30th, 2014 11:29 AM
crimson redlion g3 data tag scaling kashifidrees LIVE PLC Questions And Answers 3 May 14th, 2013 07:58 AM
Help with Profibus CPU315-2 DP Rafael Guedes LIVE PLC Questions And Answers 5 September 3rd, 2007 07:44 AM
Data to STRING tag at startup JERA LIVE PLC Questions And Answers 2 July 31st, 2007 10:21 AM


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


.