rfid2ln & rfid2wifi interfaces

Moderator: Moderators

Re: rfid2ln interface

Postby Liviu M » 29.11.2015, 09:39

Hello Gerard,

I'm glad to hear it is (maybe :) ) working.
Meantime I've made a version that is easier to read and to extand to more readers (just by defining new pins and increasing the NR_OF_PORTS).
Unfortunately it was possible only after I modified a little the MFRC522 library. I'm not sure if I'll publish this version on github, but if you want to test it, I'm attaching it here, on forum (with the changed .cpp & .h files of the MFRC522 library).

Best regards,
Liviu
You do not have the required permissions to view the files attached to this post.
----------------------------------------------
System: DCC N-Scale
CS: Profiboss (Loconet)
Server: RaspberryPi/OdroidC1/OpenSuse
Client: OpenSuse/Windows(?)
----------------------------------------------
Liviu M
 

Re: rfid2ln interface

Postby GRemmerswaal » 29.11.2015, 22:56

Hello Liviu,

The two RFID readers are still working, they read the tags of trains and wagons simultaneously and the Arduino sends the data to Rocrail.
Only sometimes the reading is not reliable and then I miss some figures.
I have the feeling that this has nothing to do with the software but more with the communication between the RFID reader and the tags.
This week I will do some experiments with shielding the tags in the metal environment of the train and wagons.
If I have some results I will let you know.

Regards,

Gerard
GRemmerswaal
 

Re: rfid2ln interface

Postby Liviu M » 30.11.2015, 13:31

Hello Gerard,
GRemmerswaal wrote:Only sometimes the reading is not reliable and then I miss some figures.

It is what I was meaning above with "slow". I think you can't do much to improve it, I should optimize the code. If I'll be able, the (Arduino) programming is not my stronger part.

Regards,
Liviu
----------------------------------------------
System: DCC N-Scale
CS: Profiboss (Loconet)
Server: RaspberryPi/OdroidC1/OpenSuse
Client: OpenSuse/Windows(?)
----------------------------------------------
Liviu M
 

Re: rfid2ln interface

Postby GRemmerswaal » 05.12.2015, 11:17

Hi Liviu,

I have some results of my tests with the RFID readers.
It is important to lower the tags and mount them in the middle.
If the distance between Reader and tag is to big then you lose information.
After doing this the results are promising but unfortunately not perfect.
Sometimes I lose one tag-reading and on a regular base the software stops running.
I think that this happens when both readers are communicating at the same time.

I do not have good results with tags under a locomotive, to much metal.
Peter Giling tries to find a solution for this. A thin ferrite plate between tag and metal should do the trick.
Regards,

Gerard
GRemmerswaal
 

Re: rfid2ln interface

Postby Liviu M » 05.12.2015, 11:38

Hello Gerard,

thanks for reporting your progress.
The problems you are reporting are with more readers connected to an Arduino, or with more Arduinos, each with one reader?
Metal locos are making troubles to me too. If you/Peter will find a solution, please let me also know. :)
Unfortunately I don't have much to report. Meantime I've received a second reader, but I haven't time to play with.
I've done some small tests though. I was trying to activate the IRQ output of the MFRC522 board (and to read its data only if a change took place). Unfortunately I had no success yet (and in Internet I found no successful report neither). I'm still trying.

Regards,
Liviu
----------------------------------------------
System: DCC N-Scale
CS: Profiboss (Loconet)
Server: RaspberryPi/OdroidC1/OpenSuse
Client: OpenSuse/Windows(?)
----------------------------------------------
Liviu M
 

Re: rfid2ln interface

Postby Liviu M » 05.12.2015, 19:40

Hello Gerard,

since few time my changes to the MFRC522 are "official", no more need for different libraries.

Regards,
Liviu
----------------------------------------------
System: DCC N-Scale
CS: Profiboss (Loconet)
Server: RaspberryPi/OdroidC1/OpenSuse
Client: OpenSuse/Windows(?)
----------------------------------------------
Liviu M
 

Re: rfid2ln interface

Postby Liviu M » 06.12.2015, 10:24

Hello Gerard,

I've implemented a small buffer for the TAG data to be sent to the PC.
If you'd like to test it, the new version is on the github (multi-reader branch), as usual.

Regards,
Liviu

LE rfid2ln_multi branch cloning command:
Code: Select all
git clone https://github.com/lmmeng/rfid2ln.git --branch rfid2ln_multi --single-branch
----------------------------------------------
System: DCC N-Scale
CS: Profiboss (Loconet)
Server: RaspberryPi/OdroidC1/OpenSuse
Client: OpenSuse/Windows(?)
----------------------------------------------
Liviu M
 

Re: rfid2ln interface

Postby GRemmerswaal » 06.12.2015, 22:49

Hello Liviu,

I will test your latest software version this week.
In the mean time I found another RFID library for Arduino.
On http://www.addicore.com/RFID-AddiKit-p/126.htm you will find the library and some examples.
Maybe it is more easy to use interrupts with this software.

Regards,

Gerard
GRemmerswaal
 

Re: rfid2ln interface

Postby Liviu M » 06.12.2015, 22:59

Hello Gerard,

thanks for the new library, but (I suppose) the problem I have isn't because of the library.
Using the library functions I can program the MFRC522 chip, but it seems that the IRQ pin of the MFRC522 doesn't react to any "stimulus" - I've activated all the interrupt sources but I never had a reaction on the IRQ pin. It is true that I wasn't watching the pin with an oscilloscope - I've only connected the pin to an Arduino input and I polled that input.
Still searching.

Regards,
Liviu
----------------------------------------------
System: DCC N-Scale
CS: Profiboss (Loconet)
Server: RaspberryPi/OdroidC1/OpenSuse
Client: OpenSuse/Windows(?)
----------------------------------------------
Liviu M
 

Re: rfid2ln interface

Postby GRemmerswaal » 08.12.2015, 00:44

Hello Liviu,

Your newest software reacts much faster than the previous one.
Every time I approach the RFID reader with a tag I get an average of five measurements. Sometimes I get only 2 measurements but 10 measurements is also possible. To get a more reliable measurement I took a plastic wheel with two tags on it. In the final test I want to use two of those wheels and two motors to drive the wheels.
The distance to the RFID reader will always be the same so you get a reliable measurement. With magnets on the wheels and hall sensors I can count the revolutions.

DSCN3813.png


At this moment, with your newest software, only one RFID reader is functioning. Can you change this again to two readers or did I do something wrong ?
Suppose we get 5 measurement from 1 tag. Is it possible you send the first measurement to Loconet and block the other 4 measurements ? You stop the blocking of the measurements when you get another (new) tag number. Again you only send the first measurement to Loconet and block the rest of the measurements.
When the software works this way then the traffic on Loconet is not as busy and I can do my tests. Every revolution will give a reading on the hall sensor and one for tag A and one for tag B

Regards,

Gerard
You do not have the required permissions to view the files attached to this post.
GRemmerswaal
 

Re: rfid2ln interface

Postby Liviu M » 08.12.2015, 08:36

Hello Gerard,

The program should work with two readers, but I think I've changed to many pin definitions (I've had to change my setup for the second reader). May you tell me once again which board and which pins are you using?
Regarding the number of reads, in the single reader program I have implemented a "repetition test", avoiding to many events for the same reader (in a time window *)). In the multireader program, because of slowness, I've deactivated this test. I'll reactivate it this evening.

*) I prefer the "time inhibit" to the "UID inhibit" because in this way I can still receive information when I'm playing with a single loco around a station.

Regards,
Liviu

PS I like your "test environment" :)
----------------------------------------------
System: DCC N-Scale
CS: Profiboss (Loconet)
Server: RaspberryPi/OdroidC1/OpenSuse
Client: OpenSuse/Windows(?)
----------------------------------------------
Liviu M
 

Re: rfid2ln interface

Postby GRemmerswaal » 09.12.2015, 11:46

Hello Liviu,

Probably we can use the RFID readers also at the CAN bus, there is an 8 channel RFID concentrator available.
The concentrator scans continuously all the inputs looking for serial RS232 information from RFID readers.
So , to let it work our RC522 reader needs only a small microcontroller who's task will be to sent the tag information to the RS232 port.
For the first trial I have used parts of your software and the RC522 library of course.

The function " bool compareUid(byte *buffer1, byte *buffer2, byte bufferSize) " did not work the way I wanted it and I found some strange declaration in the for--next loop.
I changed the function to :

Code: Select all
bool compareUid (byte *buffer1, byte *buffer2, byte bufferSize)
{
        for (byte i = 0; i < bufferSize; i++)
    {
        if (buffer1[i] != buffer2[i])
           return false;                                                       // if only one byte differs then leave the function and return "false"
    }   
    return true;   
}


In the main loop i wrote this part of the program :

Code: Select all
if ( mfrc522.PICC_IsNewCardPresent() && mfrc522.PICC_ReadCardSerial() && bSerialOk)
    { 
        if ( ! compareUid( mfrc522.uid.uidByte, oldUid, mfrc522.uid.size))                                         // if the tag-ID differs from the previous tag-ID
          {
             Serial.print(F("Card UID:"));
             dump_byte_array(mfrc522.uid.uidByte, mfrc522.uid.size);                                               // print out tag-ID
             Serial.println();
          }
         copyUid  ( mfrc522.uid.uidByte, oldUid, mfrc522.uid.size);                                                // fill  "oldUid"  with the latest tag-ID
    }   


The result is now that the tag-ID is print out the first time the reader finds a tag.
The next print out will be when the tag differs from the previous one.
This information is sent to the serial port.

Maybe you can use the above information :)

Regards,

Gerard
Last edited by GRemmerswaal on 09.12.2015, 12:19, edited 1 time in total.
GRemmerswaal
 

Re: rfid2ln interface

Postby Liviu M » 09.12.2015, 12:03

Hello Gerard,
do you found a MFRC522 board with RS232 interface? :shock: May you post a link, please? When I've started playing with it, I've studied my MFRC522 board and come to the conclusion that the protocol is "hard coded" and not possible to be changed. More than that, I've said that to Bernhard too and changed his mind from implementing the i2c communication between ESP8266 & MFRC522.
Once you have the UID in the Arduino, you can use any protocol supported by Rocrail to sent the data to it. I've done the Loconet version because it is the protocol my CS is supporting.

Regards,
Liviu

PS Your new device should be named rfid2can :) and it deserve a dedicated topic. :thumb_up:
----------------------------------------------
System: DCC N-Scale
CS: Profiboss (Loconet)
Server: RaspberryPi/OdroidC1/OpenSuse
Client: OpenSuse/Windows(?)
----------------------------------------------
Liviu M
 

Re: rfid2ln interface

Postby Liviu M » 09.12.2015, 12:11

Hello Gerard,
GRemmerswaal wrote:The function " bool compareUid(byte *buffer1, byte *buffer2, byte bufferSize) " did not work

And probably it is not the only one that can be improved. I'm just a "hobby programmer" (I write programs for my hobbies). :)

Regards,
Liviu
----------------------------------------------
System: DCC N-Scale
CS: Profiboss (Loconet)
Server: RaspberryPi/OdroidC1/OpenSuse
Client: OpenSuse/Windows(?)
----------------------------------------------
Liviu M
 

Re: rfid2ln interface

Postby Liviu M » 09.12.2015, 12:32

Hello Gerard,
Liviu M wrote:do you found a MFRC522 board with RS232 interface?

Answering myself - yes, it seems that changing the mode to UART should be possible by cutting a wire on board and connecting the pin 32 to the GND. Somehow I missed this possibility. The i2c protocol, however, can't be selected (meaning I haven't false informed Bernhard).

Regards,
Liviu
----------------------------------------------
System: DCC N-Scale
CS: Profiboss (Loconet)
Server: RaspberryPi/OdroidC1/OpenSuse
Client: OpenSuse/Windows(?)
----------------------------------------------
Liviu M
 

PreviousNext

Return to DIY Hardware