rfid2ln & rfid2wifi interfaces

GRemmerswaal
Posts: 21
Joined: 06.06.2015, 12:37

Re: rfid2ln interface

Post by GRemmerswaal » 09.12.2015, 12:36

Hello Liviu,

We can shake hands, I am a hobby programmer too.
Peter Gilling asked me to connect the RFID reader to his CAN-bus concentrator and then you need RS232 communication.
The easiest solution is to use a small PCB with an attiny microcontroller to do the conversion.
It is possible to load Arduino software in the official Studio 7 program environment from Atmel.
I hope it will be possible to load the software in a smaller controller and keep the same functions.
I must strip your software much more of course otherwise it will never fit in the small memory space.
I will keep you updated.

Regards,

Gerard

GRemmerswaal
Posts: 21
Joined: 06.06.2015, 12:37

Re: rfid2ln interface

Post by GRemmerswaal » 09.12.2015, 12:43

Hello Liviu,

I think too you can change the behavior of the RC522 by cutting a wire.
However the problem is that RC522 chip will only react as a slave, so you must constantly "ask" or there was a tag available.
The CAN bus concentrator only receives information and it will never ask for information.

Regards,

Gerard

Liviu M
Posts: 932
Joined: 03.12.2011, 20:44

Re: rfid2ln interface

Post by Liviu M » 09.12.2015, 13:12

Hello Gerard,
Thanks for clarifications, meantime I've also discovered I've misunderstood your original post.
Your Idea should work, but my idea (cutting a wire and connect the freed pin to gnd) can also work. Maybe I'll test it later, at home.

Regards,
Liviu
Attachments
mfrc522_uartMode.png
mfrc522_uartMode.png (122.44 KiB) Viewed 216 times

Liviu M
Posts: 932
Joined: 03.12.2011, 20:44

Re: rfid2ln interface

Post by Liviu M » 09.12.2015, 13:15

Hello Gerard,
GRemmerswaal wrote: However the problem is that RC522 chip will only react as a slave
Thanks for clarifying this for me. I never read that section in the data sheet. :oops:

Thanks,
Liviu

Liviu M
Posts: 932
Joined: 03.12.2011, 20:44

Re: rfid2ln interface

Post by Liviu M » 09.12.2015, 13:30

Hello Gerard,

returning to my program, in the last version I've reactivated the delay before sending a new ln message.
If you test the new version, please let me know how it behaves.

Thanks,
Liviu

PS The sketch should work with two readers. If not, please check if the pin defines (in the rfid2ln.h file) are corresponding to the pins you are using.

GRemmerswaal
Posts: 21
Joined: 06.06.2015, 12:37

Re: rfid2ln interface

Post by GRemmerswaal » 12.12.2015, 14:30

Hello Liviu,

As I told you we want to connect the RFID reader also to the CAN-bus.
For this purpose I removed all the code we need for communication with Loconet.
I also removed all delay activities in the software because I think we can do without.
The software checks the ID's coming from the reader before this information is sent to Loconet or the CAN-bus.

Suppose we have two tags with ID number A and B.
When the reader gives us tag A, A, A, A, then the serial output will give you only one time ID number A
When the reader gives us tag A, A, B, B, B, B then you will get Id Number A and B
With the cyclus A, A, B, B, B, A, A, A you will get A, B, A.
In this way the software generates the minimum of data trafic but with all the necessary information.
The software is really fast and more important until now I did not miss any tag information.
Here you will find the stripped software program :
rfid2_ser.zip
(1.78 KiB) Downloaded 6 times
Supported by this success I took a previous version of your software who already was able to communicate with Loconet with two readers.
I changed the software again a little bit as I did before and the result looks promising.
The software is still fast and feels reliable. this software, I'm going to test the way I have explained earlier.
Unfortunately I have some minor problems with programming the address of port 2. Maybe you can see what is wrong.
The sensor monitor however shows me the tag information of both readers so I can start with the tests.
Again, here is the software i use :
rfid2ln_gerard.zip
(7.9 KiB) Downloaded 7 times
I will keep you informed,

Gerard

Liviu M
Posts: 932
Joined: 03.12.2011, 20:44

Re: rfid2ln interface

Post by Liviu M » 12.12.2015, 17:09

Hello Gerard,

I was looking your sketch, but not found any problem. In my opinion, the programming of both ports should work (I had some eeprom addressing problems, but I've solved them and your sketch is using the corrected version). Right now I can't test it on my layout, because it is out of order, but I'll test it next days.
Regarding your sketch in the last .zip, I have only one comment - put the setMessageHeader(x); commands before transforming the UIDs in Ln messages, not after as it is now:

Code: Select all

          setMessageHeader(1);                          //   !!! the message header before building the message!!!
          SendPacketSensor.data[uiLnSendCheckSumIdx]= uiStartChkSen;                                       
          SendPacketSensor.data[uiLnSendMsbIdx]=0;                                                        
          for(i=0, j=5; i< UID_LEN; i++, j++)
          {
Regarding the Loconet messages transmission, when I've started playing with the MFRC522 I've had only one reader, one loco and one small circle layout (one track, no turnouts). I've done the first tests leaving the loco to "circle" continuously. With your method (that I also used at first) I had only one event after powering the system. All other messages were suppressed. With time inhibit, my loco had a chance to trigger more than one event.

Regards,
Liviu

PS I'll give a chance to (my) last version, though, the one with array of readers and the number of the port as index. Is easier to maintain.

Liviu M
Posts: 932
Joined: 03.12.2011, 20:44

Re: rfid2ln interface

Post by Liviu M » 12.12.2015, 17:15

Hello Gerard,

regarding your rfid2_ser sketch, are you using the hardware serial port (the one used normally for debug) to send the RS232 messages?
I was never sure if it works this way.
The sketch looks good. Very simple and effective. Nice job. :)

Regards,
Liviu

Liviu M
Posts: 932
Joined: 03.12.2011, 20:44

Re: rfid2ln interface

Post by Liviu M » 12.12.2015, 17:54

Hello Gerard,

I've tested your sketch and the programming (over loconet) is working for me for both ports.
Please, next time you test it, do an "eeprom erase" first (make EE_ERASE 1).
What is not working as expected is the reading of the tags. Once a tag is read on one reader it is inhibited on the other reader too. Still trying to understand why.

Regards,
Liviu

Liviu M
Posts: 932
Joined: 03.12.2011, 20:44

Re: rfid2ln interface

Post by Liviu M » 12.12.2015, 18:08

Hello Gerard,

I don't know what was wrong during the first test, now (after reprogramming) reading a tad on one reader do not inhibit the other reader. But reading again in reader 1 still does not work, and I think it should.
So, having one tag (t1) and two readers (r1 & r2), I think it should work each time when you pass the tag alternately over r1 & r2.
r1, r1, r1, r2, r2, r2, r2, r1, r1, r2, r1 should be transmitted as r1, r2, r1, r2, r1, but right now only r1, r2 is transmitted.

Regards,
Liviu

GRemmerswaal
Posts: 21
Joined: 06.06.2015, 12:37

Re: rfid2ln interface

Post by GRemmerswaal » 12.12.2015, 19:20

Hello Liviu,

Lots of good idea's from you, Thanks.
I will do the EEPROM erase, I have never done this before.
If you have only one tag then my solution is not working, you are right.
One tag used by 2 readers, I did not test it yet, but when the software is finished then it should work.
When I said serial Port I ment the serail monitor from Arduino.
However I think it is not a problem. On the Arduino I have the connection TX and RX.
Together with GND this is complete RS232 hardware.
To make a real connection to a RS232 port on a PC I use the MAX 232 chip to convert the voltages to plus and minus 12 Volt
I use the Putty program for the serial monitor on my PC and I have a plug-in card in my PC with two original RS232 ports.

Hopefully I have time this weekend to start the test with two readers and two "tag wheels"
Regards,

Gerard

Liviu M
Posts: 932
Joined: 03.12.2011, 20:44

Re: rfid2ln interface

Post by Liviu M » 12.12.2015, 20:13

Hello Gerard,
GRemmerswaal wrote: I will do the EEPROM erase, I have never done this before.
Is not a real EEPROM erase, I'm clearing just some addresses (revision area) to force the default programming of board address and ports data.

Code: Select all

#if EE_ERASE
  for (uint8_t i = 0; i < 11; i++) {
    EEPROM.write(255 - 11 + i, 0xff);
  }
#endif
Regards,
Liviu

Liviu M
Posts: 932
Joined: 03.12.2011, 20:44

Re: rfid2ln & rfid2wifi interfaces

Post by Liviu M » 12.12.2015, 21:03

Hello all,

I've just changed the name of this thread including the wifi version of my interface in this discussion.
First news regarding the wifi interface is that it is also working with two readers. It has a problem in loconet programming part - after some time it "looses the connection", but is not so bad - the addresses can be programmed using the web interface and the event reports are still working.
Should someone be interested in testing it, this version is found in the _multi branch of my wifi repo (see the signature).

Regards,
Liviu

PS The web interface is looking like in the attached screen-shot. Changing the IP from the web interface is not working. The IP is received through DHCP. Maybe I'll should implement fix IPs?.
Attachments
webServer_rfid2wifi.png

Liviu M
Posts: 932
Joined: 03.12.2011, 20:44

Re: rfid2ln & rfid2wifi interfaces

Post by Liviu M » 18.12.2015, 15:01

Hello all,

it looks like two or more rfid2ln boards in the same Loconet aren't working very well. I suppose it happens because the boards are "to identical".
I've uploaded a sketch version who use the board number to wait different amount of time before trying to access the bus. It can/should differentiate 10 boards.
Unfortunately I don't have (yet) two boards to test if it is working better, I need some more time to build the second one.
@Gerard: if you have time to test it and came to a result, please keep me informed. Thanks!

Best regards,
Liviu

GRemmerswaal
Posts: 21
Joined: 06.06.2015, 12:37

Re: rfid2ln & rfid2wifi interfaces

Post by GRemmerswaal » 23.12.2015, 10:28

Hello Liviu,

Strange behavior of those rfid2ln boards, usualy there are many identical boards in the same Loconet area :shock:
I have Arduino software from Daniel Guisado Serra. His program simulates a MGV50 board and this works fine. It is not completly finished but the software communicates pretty good with Loconet.
At this moment I try to mix the Arduino Loconet software with your rfid software.
It would be nice to have a MGV50 board where you can assign some inputs as RFID inputs.
Mixing the programs is not an easy job and it will take a while. I'll keep you informed.

Regards,
Gerard

Post Reply

Return to “DIY Hardware”