Sportiduino - the system of electronic mark for sports, part 3

    Part 1 , Part 2

    A year has passed since the last publication, and I often get asked what has changed since then. In short, the transition to Ntag chips was made, small changes were made in the circuit to ensure better sensitivity, loudness of the signal and the correct course of the clock, software was created to work with the system. In general, the system has stabilized and is ready for reproduction and use. More detail below.

    First of all, let me tell you about the RFID chips, why the transition was made in the direction of Ntag. I recall that the memory Mifare Classic 1K contains 1024 bytes, of which 752 bytes are available to store information. The memory structure is divided into 16 blocks, which contain 4 pages of 16 bytes, one of which is reserved for encryption. If we used one page as a service, there were still 46 pages left to record the marks.

    At the beginning of development, I used the memory at ease - one page of 16 bytes per mark, which limits the use of small starts. And for rogaining, tourist orienteering, or adventure racing, 46 stations are few. Therefore, the idea of ​​compaction was implemented: two marks were written on each page. At the same time, there is a risk of data loss, because the recording unit is one page, and when you re-write, you have to read the half already written to write it again. Actually, I came to this rake when I was holding rogaining last November, a small part of the data was lost, I had to edit a lot manually. And, although the error in the code was identified, I decided to switch to more capacious chips without the risk of losing data during the rewriting.

    One of the possible options is to use Mifare 4K chips, whose structure differs from 1K only in four times more memory. But such chips are both more expensive and the duration of cleaning, the marks with their use would increase. Another option is to use Ntag series chips (213/215/216). The memory structure of Ntag chips is quite simple - the memory is paginated by 4 bytes, the first 4 and the last 5 pages are reserved for storing service information, the rest can be used. Ntag series chips differ in memory size, Ntag213 is free to use 36 pages (144 bytes), Ntag215 - 126 pages (504 bytes), Ntag216 - 222 pages (888 bytes). As a result, I implemented the support of all the chips of this series, although Ntag215 can be considered optimal, the memory of which is enough for 120 marks, and the price is quite low (about 0). $ 2 for a chip in the form of a sticker or $ 0.4 in the form of a keychain). Also on the advice of the SFR decided to abandon the storage of critical information - the number of the last free page in favor of its binary search. This increased time stamping, but increased reliability.

    The Ntag memory page contains 4 bytes, in which the station number needs to be placed - 1 byte and the time stamp is 4 bytes. The problem was solved by the fact that the full initialization (cleaning) time of the chip is written into a separate page, and with the mark only the lower 3 bytes from the time. Then, when reading, the time stamps are fully restored based on the initialization time. Another page in the chip is occupied by the chip number and two are left in reserve. The resulting structure is presented below:



    The use of Ntag allowed us to resolve the issue of safely recording a large number of marks on the chip, but another problem arose. Ntag chips require more transmitter power than Mifare with the same antenna area, and keychain chips, in which an antenna is about 2 cm ^ 2, may not work well on the RC522 module as standard. The solution to the problem turned out to be the soldering of inductances on the module to more powerful ones. At the same time, the range of operation has increased significantly, for Ntag chips up to 2 cm, and for Mifare up to 3 cm. But some modules because of this soldering began to work poorly: recording chips occurred only at a certain and rather unpredictable distance from the transmitting antenna. I had to get into the RC522 Arduin library and find the gain parameter, which is responsible for the antenna power, his edit for individual stations solved the problem. He also mastered the manual manufacture of chips on a bracelet from stickers. They are already ready and beautiful for sale on the Alibaba, but their antenna area is almost two times smaller, the mark is less stable. I also note that I left the support for Mifare 1K chips, you can work with them, but for this you need to use separate firmware, and the capacity of the chips is limited to 42 marks, but they come bundled with RC522 modules.



    Another problem that had to be solved during the development was the incorrect clock run. In part of the station, the clock began to lag or hurry up to 5 minutes per day. I couldn’t understand the reason for a long time, then I found out that only stations with a printed circuit board made at the factory were buggy, while everything worked fine on hand-etched ones. I wondered what it could be connected with. On hand-etched rather thick tracks, due to their copious tinning, there is less resistance. It turned out that the condenser at the output from the stabilizer is not enough for decoupling the power of the clock on thin factory tracks. Put another capacitor close to the clock, and the problem, for the most part, was resolved. A small part of the clock is still failing, but I already associate it with the marriage of cheap hours with Ali, you need to look for reliable suppliers.

    Well, the last change in the scheme - amplification of the audio signal. Previously, the control and power supply of the tweeter in the circuit was carried out from the foot of the microcontroller, so it was quite limited in power. Now the power comes directly from the batteries, and the control through the transistor, which significantly increased the volume of the signal. All these changes are now taken into account and made in the Gerber files, and I manually reworked about 40 stations, I had to unzip the compound, cut the tracks, hang the transistor on the wires, it was not without broken stations.



    Because of the transition to other chips, the firmware of the base stations had to be significantly changed, but the principle and logic of the work, for the most part, remained the same. The same modes of energy saving, sleep, work, setting up with the help of master chips. But the firmware of the gateway station was completely reworked. The previous communication protocol, when data flowed into the COM port as a continuous stream, seemed vulnerable: a missing byte and all the data turned into a pumpkin. Adapting to the already existing data transfer protocols seemed boring, so I invented my bicycle.

    The transmission and receipt of information occurs sequentially using packet transmission up to 32 bytes. If the transmitted data does not fit into the packet, the transfer is performed by sequential forwarding of the packets. The packet starts with the start byte 0xFE, followed by the command number, packet length, data, and at the end a checksum. Commands pass only if the checksum value and start bytes are correct. Pretty simple and fairly reliable.



    The connection was established, but it was necessary to write normal software for the computer, my crafts on Processing were not suitable for this. It was taken by Semyon Yakimov, who created the modulein Python to work with the system, for which he is very grateful. The module allows you to communicate with the gateway station, send and receive data in a convenient format. Already after I learned Python in the first approximation and, on the basis of this module and PyQt, I wrote a simple GUI application that can be used to configure the system, as well as to collect data from the chips in the form of a JSON file. Well, then the data can be processed using small scripts for competitions with a variety of conditions and rules, to issue in a convenient form ( tourist orientation , rogain ). But, anyway, this implies some skills, and happiness would be incomplete if it were not for the developers of the program SportOrgwhich added support for Sportiduino (besides Sportident and SFR). The program is actively developing and a lot of things that can referee orienteering starts.

    Conclusion


    Thus, at the moment there is a stable working hardware and software. I believe that the aim of the venture has been achieved: a cheap electronic mark system has appeared. I am not going to change something within the framework of this scheme, unless, if there is any bug. The mark system has been developed and tested in a large number of different competitions: orienteering, rogain, march, trail, tourist stages. In addition to me, it is used by several people in different places. Someone reproduced the system, someone made additions there, for example, a radio module or the use of lithium batteries and Mifare chips as the main ones.

    Development is open and non-commercial, under the GNU GPLv3 license. Anyone can freely copy, reproduce, modify and use it. Over the last year I received a lot of questions if I was selling the station. No, I do not want to do this. On the other hand, I do not mind if someone fills this niche. I'm just ready to give advice on the assembly and use, the benefit there everything is quite simple.

    The project is available on github , there are also diagrams, instructions and other useful material. Thank you for attention.

    Also popular now: