Hi everyone, i didn’t really understand the function of Memory Index tag and how to use it to read and write data on RFID TAG ! Could anyone explain it to us please ?
Hey ImGr
If you look at the description of the sensor it says:
“A RFID tag includes 128 DWORD of free memory and an unique serial number. Each DWORD can be accessed by setting the corresponding memory index in the reader (see table below).”
So, by setting the Index-Tag you can say which DWORD you want to read.
BUT I see a problem there. @brunovgr and @wayneschaefer: In the documentation of the sensor it says “128 DWORD of free memory”, but the inputs and outputs of the part (“Write_Data” and “Read_Data”) are of the type INT. AFAIK an INT only uses a WORD, and not a DWORD. So, is the documentation wrong or how do I pull the second WORD of the DWORD?
Hi @janbumer1,
Factory I/O uses three different data types for tags: Bool, Float and Int. Any is a variant that can represent any type - only used by the OPC DA driver.
Float and Int tags are always 32 bit (DWORD). When a Float or Int tag is used by a driver, it is properly cast to the expected/configured data type. For instance, when using Siemens S7-1200 you can define the numerical data type to use (WORD or DWORD):
If you use a driver that supports DWORD you can write 32 bit to each memory address of an RFID tag. However, if the driver you are using only supports 16 bit (such as Modbus TCP) you will only be able to write/read 16 bit to each memory address.
Hi @ImGr
You can see the memory index as a pointer to the memory address of the DWORD you want to access (read/write). Each RFID tag has 128 DWORD, this means that when you are using memory index = 0 you are reading/writing to the first DWORD; if you use 127 you are pointing to the last DWORD and so on.
Aaah, there lies the problem.
Per IEC 61131-3 definition an “INT” has a size of 2 Bytes, so WORD. A DINT would be 4 Bytes, which would be DINT.
Didn’t know that Factory I/O “breaks” with this norm and defines INT as 32 bit.
You might want to add a line “Index is 0 based.” to your documentation in this case. While this is obvious for programmers who use high level languages for non-PLC applications, on most PLCs you can start your array where you like.
Yes, it can be misleading. The original idea was to indicate things like: this is a Bool tag so it represents an on/off value, an Int tag represents an integer number and a Float tag a number with decimal places. Then, on the driver you would indicate on how to use this data: WORD, DWORD, UINT and so on.
This is something we will definitely improve in a future version.
Thank you @brunovgr and @janbumer1 for the explanations you guys gave !
@brunovgr Thanks for that in advance!
@wayneschaefer Problem resolved.
@ImGr Glad we were able to help!
@janbumer1, @brunovgr … could we write a String and other data types in the data’s Tag ? or only a Dint ?
Hey there
Don’t let yourself get confused by the I/Os in Factory I/O. The RFID-Tag can save 128 DWORDs, not DINTs. 1 DINT uses 1 DWORD in memory, but…
…a DWORD is a DWORD. It’s just memory space and what you do with it is up to you. 1 CHAR would be 1 Byte, so with 1 DWORD you could store 4 Chars. 128 DWORD thus would mean 512 CHARs. So, feel free.
Oh, alright then ! Thank you so much !
PS. Gotta be careful tho. For example: Siemens uses the first 2 bytes of a STRING to store the length of the string. So if you use a string, convert it into an “array[x…y] of Byte” to use it correctly.
I didn’t know that ! how should i do the conversion then ?
Depends. Are you working with Siemens?
Yes, with tia portal !
In that case you could work with the function “Strg_TO_Chars” and “Chars_TO_Strg” to convert from String to Array[0…x] of Char and vice versa.
I probably should pay more attention to whether I am using INT or DINT in my programming. I must admit to getting sloppy when rushed. Good discussion …
Happens to the best of us. Maybe you let yourself get confused by the “INT”-Datatype within Factory I/O.
… especially when switching between PLC Types and Programming Languages …