Control IO RFID Example

Here is some code with two RFID stations in response to a request from another user. One station Reads the Serial Number and then Writes the Minutes and Seconds to Register 1 and 2 respectively (I skip register 0). The second station Reads the Serial Number and then the data in Registers 1 and 2. The boxes continue to move which limits the number of Registers that can be written to or read from based on the 400ms timing. Timing was chosen to allow some visual observation of the chart although it could be tightened up a bit.

RFID.controlio (34.1 KB)
RFID.pdf (856.6 KB)
RFID Test Controlio.factoryio (81.9 KB)

This timing helps demonstrate the importance to proper sequencing and accounting for read/write delays with a real system with no status bits for Operation Successful or Tag Present. Controlio does not scan like a PLC so I delayed the count reset.

Oct 2020 Update:
Please see attached Factory, Compact Logix Program (see zip file) and pdf Printout that allows for some testing of the RFID system using ladder. Operation is similar to the Controlio version with the exception of some extra time allotted to allow the Read Data to transfer from the Simulation to the PLC.

Home_RFID_Simulation.zip (1.5 MB)
RFID Test - Rockwell.factoryio (85.4 KB)
RFID Test Program - Schaefer.pdf (127.4 KB)

4 Likes

Hi ! could you please explain the Memory index and how it works ? i didn’t understand it from the description that is given ! thanks a lot !

Are you referring to just the RFID Sensor Itself or my Controlio Code? If you need a better explanation of my code, I can create a step by step sequence of operation and add more detail to my charts (probably should have done that anyway). Let me know.

Hi @wayneschaefer i was just referring to the RFID Sensor itself ! but thanks for the porposition anyway
!

1 Like

Glad you got the answer you were looking for …

1 Like

Thanks a lot @wayneschaefer !

1 Like

Hello sir, i would like to know if u have reference guide on RFID using ladder logic because it is the only language that i am familiar of.i am struggling on how to use it. Since i do not have personal experience about this sensor.thank you

1 Like

Give me a bit of time and I will convert to Siemens Ladder for you … can you wait a week or so? This school week is very busy as we deal with reopening the Colleges here in Canada due to Covid-19.
Wayne

Thank you very much Sir.that sounds perfect to me because siemens is what i am using.have a nice day. Thanks

1 Like

I have not forgotten about this. Online Teaching has kept me quite busy these days. I will get the conversion done, just a bit later than expected. Sorry about the delay.

No problem sir, i am also reading your programming tips technique which is very good.

Are you struggling with a particular bit of the process or are you struggling with it in general?

In general since i do not have experience about rfid or training.

Have you read into the documentation?
I would suggest that you try the whole thing in a static environment. Place a part in front of the reader (so it doesn’t move and you don’t have to deal with timing) force the tags of the reader from the simulation (no PLC involved at this stage)

  1. If you have a box correctly aligned (with the small white RFID tag in the red detection zone of the reader) and you set the “Execute Command” on TRUE (with no other tag changed) you should get a “Status” of 0 and the “Command ID” should increment by 1.
    Congrats, you just successfully detected if a RFID tag is in front of the reader!
  2. Now move the box with your cursor so the RFID tag is out of the detection zone. If you now trigger the “Execute Command” from FALSE to TRUE again you should get a “Status” of 1, which indicates that no tag was found and the “Command ID” increments by 1.
    You just detected an error!
  3. Put the box back in blace and change the “Command” integer from 0 to 1 (“Read serial number”).
    Execute the command again and you should now see a number in the “Read Data” tag.
    Congrats, you just read some data from the RFID tag!
  4. Now change the “Command” from 1 to 3 (“Write Data”) and input a number to the “Write Data” tag. Execute the command.
    Don’t panic now, you will see that nothing except the “Command ID” has changed.
    Now change the “Command” to 2 (“Read Data”) and execute the command again.
    You should now see the number you have previously typed into the “Write Data” tag in the “Read Data” tag.
    You have just wrote and read data to and from the Memory of the RFID tag!

If you were paying attention you may have noticed that we haven’t even touched the “Memory Index” tag. You can play around with it and write data to and from different places in the memory of the RFID tag (range for “Memory Index” is 0-127 because you got 128 DWORD of memory). Just repeat step 4 from above with different memory indices and see what results you get.

Feel free to reply to this thread again if you got stuck anywhere.

2 Likes

So @ElectriZero, how’s it looking? Were you successful? Did you figure it out / get it running?

1 Like

Just and update: I have my controlio almost converted to Ladder (been crazy busy teaching this semester with everything online). I wanted to keep the same timing as my original diagram but I think I need to add more comments and explanations so the rungs make more sense. I must admit that it took me some time to remember what my controlio program did … lol … However, the ladder will be much easier to understand. The timing I created is basically just one example I use for training purposes and may not be entirely necessary for the Factoryio RFID to function. Most manufacturers would either provide the routines or more detailed instructions.

1 Like

IMHO the RFID reader is one of the parts that can be a little bit trickier to understand when you encounter it the first time. I think it would make it easier for people to make their first steps with it in a static environment instead of a dynamic one. If you start with a dynamic one you add the complexity of timing and movement in general to it. In a static one you can work with a state based program.

1 Like

Good point … In my example, if you stop the conveyors from running and add buttons to read and reset, you can create a static environment for each station; however, it would probably be better to create a single station that writes to the tag and then switch the station to read mode. BTW, I have the ladder complete from the previous example, just have to fix the comments before posting. Embarrassed to admit that I got hung up on timing and should have known better. The controlio can read the tag much faster then the PLC interface. My original timing waits 100ms before transferring the data read from the tag which was not long enough for the PLC. 150ms seems to work okay. Since I left lot of flexibly in the timing, no other changes needed to be made.

1 Like

If I want to write to/read from more than one memory index, should I execute ‘Execute Command’, toggling from FALSE to TRUE, for every memory index?
Thnx in advance!

1 Like

Generally speaking, I would say that is a correct statement and makes logical sense based on my experiences … although, on real devices, the exact sequence would depend on the RFID manufacturer. However, now that you have asked the question, I have not attempted to leave the Execute command active while incrementing the Memory Index in the simulated environment. Definitely something I need to try.