Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Effective use of interrupts #554

Closed
fabianoriccardi opened this issue Mar 10, 2021 · 3 comments
Closed

Effective use of interrupts #554

fabianoriccardi opened this issue Mar 10, 2021 · 3 comments
Labels
enhancement 🚀 a wish or proposal for future features
Milestone

Comments

@fabianoriccardi
Copy link

Hi everyone,
I was carrying on a project in which multiple RFID readers are involved (i.e. 10) and I need to recognize when the card is removed.
Actually this system work, and to detect the card removal I use the well-known trick of "double read":

bool result1 = mfrc522.PICC_ReadCardSerial();

bool result2 = mfrc522.PICC_ReadCardSerial();

and then I check both the value of result1/2. However my problem is that a single PICC_ReadCardSerial() usually takes 25ms.
So to perform a full loop, of 10 MFRC522 takes about 500ms, making the system not very responsive.

So I started to wonder about interrupt, but it seems that the library do not support this "advanced feature" and interrupts are left to the user code.

Unfortunately, the bottleneck I have highlighted resides at the core of the library (in PCD_TransceiveData()), which takes usually 25ms (and 37ms in the worst case) to return. In this time it basically waits for a predefined timeout while polling the interrupt register of the MFRC522

Is it possible to improve this aspect? Are there reasons to abandon the idea of using interrupts in the library? Are there alternative libraries for rfid making smart use of interrupts? (I had searched but I don't find valid alternatives).

I would ask to the community if anyone has meet or wondered about this problem. In case I may help with the code, it is a pity that such a great library doesn't fully benefits of interrupts.

@Rotzbua Rotzbua added the enhancement 🚀 a wish or proposal for future features label Mar 11, 2021
@Rotzbua Rotzbua added this to the fork milestone Mar 11, 2021
@Rotzbua
Copy link
Collaborator

Rotzbua commented Mar 11, 2021

Are there reasons to abandon the idea of using interrupts in the library?

Interrupts are not easy to manage. They can cause a lot of site effects and problems. The target group of this library are makers and not full stack embedded devs.

To detect presence, rfid is not a good choice. I would recommend to use in addition e.g. light barriers to decrease detection time.

If you implement the interrupt function, you have to fork or make a pr to my fork #522 because I will not add new features to this library.

Best

@fabianoriccardi
Copy link
Author

I would recommend to use in addition e.g. light barriers to decrease detection time

This is interesting and for sure I will try, however it think it leads to higher hardware cost (the light sensors), increases the assembly time, and also the case should allow the light flow in. So if a "good" software solution is available, I would prefer it.

In the next days I will look at your fork, thanks.

@srcastor
Copy link

srcastor commented Oct 4, 2021

Hi everyone, I was carrying on a project in which multiple RFID readers are involved (i.e. 10) and I need to recognize when the card is removed. Actually this system work, and to detect the card removal I use the well-known trick of "double read":

bool result1 = mfrc522.PICC_ReadCardSerial();

bool result2 = mfrc522.PICC_ReadCardSerial();

and then I check both the value of result1/2. However my problem is that a single PICC_ReadCardSerial() usually takes 25ms. So to perform a full loop, of 10 MFRC522 takes about 500ms, making the system not very responsive.

So I started to wonder about interrupt, but it seems that the library do not support this "advanced feature" and interrupts are left to the user code.

Unfortunately, the bottleneck I have highlighted resides at the core of the library (in PCD_TransceiveData()), which takes usually 25ms (and 37ms in the worst case) to return. In this time it basically waits for a predefined timeout while polling the interrupt register of the MFRC522

Is it possible to improve this aspect? Are there reasons to abandon the idea of using interrupts in the library? Are there alternative libraries for rfid making smart use of interrupts? (I had searched but I don't find valid alternatives).

I would ask to the community if anyone has meet or wondered about this problem. In case I may help with the code, it is a pity that such a great library doesn't fully benefits of interrupts.

Hi Fabian, I have exactly the same problem did you make any improvement this time? Also can you give me more info about the "double read" trick? Thanks

@Rotzbua Rotzbua closed this as completed Oct 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement 🚀 a wish or proposal for future features
Projects
None yet
Development

No branches or pull requests

3 participants