How to set up smartphones and PCs. Informational portal
  • home
  • Windows 10
  • RFID is easy. Implementation of our own RFID transponder and reader

RFID is easy. Implementation of our own RFID transponder and reader

The EM4100 label stores 64 bits of data, which means that the design must contain a 64-bit shift register made up of eight 8-bit 74HC165 registers. The register is reloaded after every 64 shifts to reset the data and start over. The register inputs are as follows:
  • Sync pattern: nine units
  • Vendor / Version ID: 2 blocks of 5 bits, of which 4 is data and the fifth is parity
  • Unique identifier: 8 blocks of 5 bits, of which 4 bits are data, and the fifth is parity
  • Checksum: 4 parity bits, counted column by column
  • Stop bit: "0"

Even encrypted tags are vulnerable to multiple attacks. In addition, it is becoming increasingly easy to emulate tags on NFC-enabled smartphones (which typically run at 13.56 MHz). Just write your field modulation application correctly and you can do whatever you want.

As a standard excuse, let me remind you that the author (And a translator! - Approx. transl.) assumes no responsibility for the consequences of using the information in this article. The reader must be responsible for all his actions.

Frame

Sometimes very lucky. A beautiful case would be great right now that the prototype is finished and the PCB has been ordered. And it was during this time that Fleming finished assembling and launching the OSAA PhotonSaw laser cutting machine. After a year of work on the project, the laser is ready to cut its first parts. Flemming and Rune make the final adjustments and replace the laser cabinet's aluminum lid. You can imagine how happy we all were to see this thing work.

With the machine running, we got the opportunity to test our project in real life. The housing for our RFID tag is made of 2mm glass. This corpus is the first object made with PhotonSaw, yes!

The idea was born to place the coil on the outside of the case. At first, it was decided to use half the height of the body, but this did not work in practice (additional holes in the long sides are thus not used). The coil was just superbly placed around the perimeter of the entire case, although I had doubts if the rectangular winding (105x55 mm) would be too large for normal electromagnetic coupling.

The test coil was wound, without any calculations, with a 0.4 mm wire, 66 turns. And, obviously, we were lucky again, because the coil turned out exactly as it should, with an inductance of 645 μH, with a tag connected, giving a resonant frequency of 125.2 kHz. The door reader test showed that the prototype works just fine with this coil.

With a coil on the outside of the case, the thickness of the latter can be reduced. The internal thickness now depends only on the height of the parts on the board, and taking into account the board thickness, it should be about 6 mm. Also, it would be nice to add engraving. Flemming suggested rounding the sides of the case for aesthetic and ergonomic reasons. The curved body will also better protect the sides of the coil, because where there is no strong tension, the turns of the wire tend to crawl out.

The PhotonSaw is still not quite up to par: the engraving on the top cover has slipped significantly. It is necessary to finalize it before making the final version of the case. Curved contours also suffered a calculation error in the software because the beam did not return to its original position after passing the closed path. But anyway, the curves look really smooth.

PCB assembly

The ordered payment arrived:

The assembly was not very difficult. Solder paste was stenciled onto the board, all the parts were placed, and then they were soldered in a homemade oven.

Through the blocking capacitance (47 pF have a resistance of about 27 kOhm at a frequency of 125 kHz) and the protective diodes, the current flows to the power rails. The energy supplied from the coil is enough to maintain the supply voltage of about 1 V. The current can reach 250-500 μA. Surprisingly, 74HCs seem to work with this kind of power supply. Unfortunately, with this kind of tension, strange things happen. The 74HC has an internal reset circuit and you need to make sure it works. Note that disabling the protective diodes does not help. At the inputs of the microcircuits there are internal protective diodes, which in this case open and do the same job.

A power reset is only triggered if the supply voltage drops below a certain level for a period of time. If the voltage remains too high, then the internal logic can become confused, because some parts of it may be in an indeterminate state, while others are working as expected. An internal reset is required to bring all chips to a consistent state. Thus, the circuit will be unstable at very low supply voltages.

The following symptoms were observed: the tag works for some time, while sending the correct data. If you remove the coil from the reader and then return it back, you can place bets whether the tag will turn off. Sometimes it works, sometimes it doesn't. Disabling the PLL makes the situation worse. Low power consumption leads to the fact that the reader will receive data from the switched off tag from time to time. This is what "energy efficient system" means.

There are two solutions: 1) reduce the capacitor in the clock recovery circuit to 15pF, and 2) insert a 22-100k resistor between the power supply and ground to discharge excess energy. The second method leads to an increase in leakage during operation and is not really required when the capacitor is reduced. However, it is provided as an option, and it is still better than the undefined state of the microcircuits.

Modulation by current or voltage

The modulator brought a fresh portion of the headache. Modulation completely disappeared when the coil was placed at a certain distance from the reader. It could also happen when moving the coil towards or away from the reader.

The reason turned out to be in the modulator circuit. MOSFETs connect the coil to a resistor of a certain resistance. However, if the power consumption from the loop is high, the resistance of the modulator is much higher than the resistance of the supply circuits. This leads to the fact that the modulation depth depends on the consumed current, which is not very good. The situation was worsened by the choice of a limiting Zener diode for a lower voltage than in the prototype.

It was decided to switch the modulator from voltage modulation to current modulation. For the first mode, the resistor was in the drain circuit, and now it is connected between the source and ground. The gate-source voltage will drop across this resistor until a value remains slightly above the transistor opening threshold (0.9-1.1 V), which will transfer the transistor to linear mode. Now the current through the transistor will be stable, regardless of the voltage at the drain.

Prototype testing has shown that current modulation works very well. A cheap, nameless reader no longer crashes (okay, maybe once in a hundred or so). It can be assumed that this change will work wonderfully on other readers as well, and the tag will now probably be able to work on most of them.

Completed version 1

You can see the changes made on the PCB. I didn't have a 15pF SMD capacitor, I had to solder a regular one with legs. The modulator is overgrown with additional resistors at the sources of the transistors. Generally acceptable for the first version.

(pictures are clickable)





Video demo

Conclusion

You might think that this 7400 logic design can be attributed to retro circuitry, but this is not entirely true. First, the 74HC family today is not that old. Secondly, low-power circuits are always relevant. Third, single gate ICs (such as the Schmitt trigger used) are often used in modern designs. It is often forgotten that the development of technology does not stop for older families of microcircuits. They just became less noticeable against the background of the general diversity.

The analog part turned out to be more difficult to design than the digital one. This is due in part to the lack of specifications, but mainly due to the many trade-offs required to meet parameters and unforeseen side effects. Digital designs have relatively few options, while analog designs usually require a balance between different (and often opposing) criteria.

I have to admit that the 74HC is made very, very well. The developers knew what they were doing and achieved very low power consumption. At first I had some doubts whether the tag could work from passive power supply, but after reading the specifications, it remained only a matter of correct circuitry. There is still room to optimize different parts of the label, though.

Now let's see how this project performs in the 2012 7400 competition. The submission of applications for the competition ends on November 31st. Let's wish the author good luck! - Approx. transl.

Tags:

  • RFID
  • 7400 Contest
  • overengineering
  • logic
  • rakes everywhere
Add tags

At some point I got bored again and I thought I came up with a good reason to buy a card reader. The concept was as follows: we glue the card to the bottom of the laptop, and put the reader in the place where the computer is usually charged.

Result: when we put the laptop on "charging", the socket with its charger is automatically turned on. And the rest of the time, the socket, of course, is off. Not to say that it is especially useful, but entertainment.

But, as usual, something went wrong. That is, instead of hard work in the field of outlets, I first of all for some reason learned to find out how many trips were left on my local metro ticket.

For understanding: this reader is not a complete device, but a peripheral for a controller or computer. For this reason, it will take some effort to use. There are no ready-made recipes "out of the box", but everything else depends on imagination and abilities.

What do they usually do? Most often - locks with opening by card, time tracking, access control systems for pets (admission to food, for example).

For experiments, I chose an inexpensive and more or less versatile reader. RFID in the name of this thing means radio identification technology, that is, it does not mean anything specifically. But from the specifications it follows that the piece of iron is compatible with common RFID cards with the MIFARE protocol.

Most likely, you have repeatedly met with such cards. Most often - in the form of an office pass. Another prime example is contactless metro tickets.

The basic principle of operation is quite simple to understand. There are antennas in the card and in the reader, while the signal of the reader (the essence of an electromagnetic field) simultaneously serves as a power source for the card. Those. both in terms of energy and in terms of data transmission, this is very similar to the super popular wireless chargers.

The cards themselves, depending on the modification, can carry from several tens of bytes to several kilobytes of data (including a unique serial number). Also, depending on the modification, the card can be equipped with cryptographic information protection.

There were two comb in the kit, but I, forgive me, already soldered one (angular). Therefore, there is no type of board without combs.

This kit includes a reader, a comb for simple prototyping and even mounting on a "motherboard" and two identifiers: a MIFARE 1K card and a key fob similar in capabilities. That is, quite enough for experimentation.

.

.

.

The reader board, as you can see, looks very neat. And, which is convenient, after installing the angled comb, the dimensions of the device do not increase, since the comb actually coincides in height with the tallest element on the board.

With AAA battery

Those. you do not have to torment yourself with a compromise between convenience and versatility (comb) and space saving per embedding (direct soldering of wires).

Among other things, the board also has a red LED, which, alas, is completely uninformative. The bottom line is that it burns even with a disconnected power supply - obviously, there are enough levels on the SPI interface. And he does not react to cards in any way.

In a word, it lights up when the reader is somehow connected to the Arduino, which does not guarantee its performance.

As for the response range, subjectively, the threshold is located at a distance of 2 cm from the board surface. Within 2 - 2.5 cm - the area of ​​uncertain response.

Features (from the seller):

Voltage: 3.3V

Active current consumption: 13-26 mA

Standby current consumption: 10-13mA

Sleep current: less than 80uA

Peak consumption: less than 30mA

Working frequency: 13.56 MHz

Supported card types: MIFARE S50, MIFARE S70, MIFARE UltraLight, MIFARE Pro, MIFARE DESfire

Interface: SPI

Dimensions: 40x60 mm

From the above, you can see that I scored twice. First, I didn't look at the supply voltage. And 3.3V, by the way, means that it's easiest to use this board with Arduino Uno, Mega and other (or similar boards) equipped with voltage regulators and 3.3V output. Fortunately, the maximum current consumption does not go beyond the platform's capabilities.

Otherwise, you must either use a single 3.3V power supply, or an additional regulator / stabilizer / voltage converter.

Secondly, the SPI interface requires 5 (!) Wires for connection. Those. in total, a loop of 7 conductors is suitable for the reader, and this is quite wasteful. To save money, it made sense to focus on I2C, but where am I and where is this meaning ?!

Connection
I would like to divide the connection into soft and hard, but everything is so closely intertwined - and resulted in a not very interesting problem.

In short, everyone knows for the RC522. But for some reason no one asks the question why the readme attached to the library and the plate in one of its examples have completely different "pinout" of the reader connection.

I guess this is one of the reasons for the eternal problems with this library. The second reason is that the connection for the Arduino Uno and Mega is done on different pins. This is due to the peculiarity of the platforms.

Finally, the third reason is that two pins (SS and RST) allow arbitrary connection and are configured in the code. At the same time, by default, the configuration for the Arduino Uno is hammered in the example code, and if you have a Mega and you connected via agitation from the readme or the plate at the beginning of the example, then, of course, you will miss.

But the trick is that the third reason is quite obvious, and I more or less bypassed it by immediately setting my pins, because I had an Arduino Mega board at hand. Therefore, by the way, the second trouble bypassed me.

But the first one - connecting the SPI pins tormented me to my heart's content. I could not even imagine that a person who made a successful library could mess up in such a banal connection of three wires.

In other words, connecting according to either the first or the second option indicated in the library description did not help. At first I thought I had a "dead board". Therefore, despite the late time, I pulled myself together and unsoldered the comb to the second one (I am thrifty and bought three at once). The result turned out to be the same, despite the fact that I repeatedly checked the connection using the "pinouts" I had on hand.

Don't even ask why I didn't go to Arduino.cc to see how the SPI is wired on the Mega. In my opinion, it was some kind of turbidity.

But I googled and, which in a nutshell (and not like me) described the purchase and its connection with the library, as I understand it, from Chinese comrades. Hands were already lowered, and I could not sleep in this state, so I allowed myself another experiment with a freshly found pinout and a library.

And both fees have earned.

To clear my conscience - I downloaded an example with a "problem" library, and it turned out to be working too.

These are the cards I tortured the reader with. From left to right: card from the set, card with the letter N, MIFARE UltraLight metro ticket, Russian Railways card

And this is what a content dump looks like and, in general, recognition of cards with the RFID library and its example DumpInfo

Torment summary: the pinout from the aforementioned comrade coincides with and, surprisingly, coincides with the pinout in the RFID library readme. Considering the latter, I can assume that either I mixed up the pins at night and all my misfortunes began with this, or the native Chinese library somehow cleverly initializes the reader, after which it starts working.

Finally, the correct pinout for the Chinese library and the Mega I was connecting to:

Mega RC522
3.3V VCC
GND GND
RESET RST

50 MISO
51 MOSI
52 SCK
53 NSS

And for Uno (haven't tested it):

Uno RC522
3.3V VCC
GND GND
5 RST

12 MISO
11 MOSI
13 SCK
10 NSS

Together with big sister

.

.

As a result of simple tests, which I nevertheless performed, it also turned out that the reader normally writes (this is such a play on words) MIFARE 1K cards from those that came with it.

The second feature is that this thing reacts adequately if several cards are brought up to it at the same time. I presented two cards, again, from those that were in the kit. In doing so, the DumpInfo example from the RFID library outputs the contents of both cards in order. Those. first, the contents of one card, followed by the second.

And checkered, and ride
So, we connected it, admired the dump of the memory contents of MIFARE 1K cards. What's next? And then I was a little too lazy to tinker with the outlet, and I remembered that the metro cards seem to work according to the same protocol.

I went, took my own, put it on, admired its contents. As promised: MIFARE UltraLight, 64 bytes of memory and it's not very clear where the trips are, where the validity period is, and it's not very clear at all.

Googling about using the Arduino with these cards didn't come up with anything particularly useful. Most often, metro cards, as it turned out, are used as ultra-cheap (i.e. free) NFC tags in all kinds of self-made systems like locks, script execution and other things, where it is enough to know the serial number of the card for identification. But for some reason I did not find ready-made libraries and solutions for displaying information about trips: either I wanted to sleep so much, or they really didn’t exist (see the Elusive Joe syndrome).

But I found a wonderful and very romantic text by Alexander "Dark Simpson" Simonov under the heading "", published, apparently, in some of Hacker's issues. Despite the curious nature of the text, it contains a lot of useful information about the data storage structure, including on the tickets I'm interested in.

A significant part of the ticket - the number - visually checked

So the next day I tried to overcome my aversion to HEX and started to figure it out. Here is a ticket dump I received using the RFID library:

Card UID: 04 6F 25 62 04 33 82
PICC type: MIFARE Ultralight or Ultralight C

Page 0 1 2 3
0 04 6F 25 C6
1 62 04 33 82
2 D7 48 F0 00
3 00 07 FF FC
4 45 DA 21 06
5 D0 E5 3D 00
6 1F E8 00 00
7 1F E8 00 00
8 1F 8F 5A 00
9 40 19 2E D2
10 19 91 59 7C
11 1F AB 91 C8
12 1F 8F 5A 00
13 40 19 2E D2
14 19 91 59 7C
15 1F AB 91 C8

Here Card UID is the unique identifier of the card (which is the serial number), and the rest is 16 pages of memory, each of which contains 4 bytes. Together - 64 bytes.

From reading the text about metro tickets, I noted the most useful points:

1) The ticket number (which is printed on it) is hardwired in 32 bits, starting with 21 bits on page 4: 10 6D 0E 53;

2) Date of issue of the ticket in days since 01.01.1992 - the first two bytes of page 8: 1F 8F;

3) Validity in days - third byte on page 8: 5A.

4) Finally, the number of rides remaining is the second byte on page 9: 19.

It was already possible to work with this.

I dig deeper into the DumpInfo example from the RFID library, in its own code, in order to understand what functions are responsible for what and how they can be useful, in the Arduino forums to see the implementation of calculating the date (in general, you can look in any language, but it was easier for me look closer to the target platform).

As a result, a monster was born. That is, the sketch is cut from rags, in some places the result is tailored to the answer, but on the whole everything is more or less consistent with reality. Therefore, there is nothing to shoot at a pianist who plays as best he can. There, by the way, even basic error handling is there: a sketch will warn about an unsupported card or about the impossibility of reading.

#include #include #define SS_PIN 53 #define RST_PIN 9 MFRC522 mfrc522 (SS_PIN, RST_PIN); // MFRC522 object unsigned long uidDec, uidDecTemp; // to display the card number in decimal format byte bCounter, readBit; unsigned long ticketNumber; void setup () (Serial.begin (9600); SPI.begin (); // SPI initialization mfrc522.PCD_Init (); // MFRC522 initialization Serial.println ("Waiting for card ...");) void loop ( ) (// Search for a new card if (! Mfrc522.PICC_IsNewCardPresent ()) (return;) // Select a card if (! Mfrc522.PICC_ReadCardSerial ()) (return;) uidDec = 0; // Issue the serial number of the card Serial.print ("Card UID:"); for (byte i = 0; i< mfrc522.uid.size; i++) { // Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "); // Serial.print(mfrc522.uid.uidByte[i], HEX); uidDecTemp=mfrc522.uid.uidByte[i]; uidDec=uidDec*256+uidDecTemp; } Serial.println(uidDec); Serial.println(); // Выдача типа карты byte piccType = mfrc522.PICC_GetType(mfrc522.uid.sak); // запрос типа Serial.print("Card type: "); Serial.println(mfrc522.PICC_GetTypeName(piccType)); // трансляция типа в читаемый вид if (piccType != MFRC522::PICC_TYPE_MIFARE_UL) { // если не билетная карта Serial.print("Not a valid card: "); // так и говорим Serial.println(piccType); // Halt PICC mfrc522.PICC_HaltA(); // остановка чипа return; } // сюда мы приедем, если чип правильный byte status; byte byteCount; byte buffer; // длина массива (16 байт + 2 байта контрольная сумма) byte pages={4, 8}; // страницы с данными byte pageByte; // счетчик байтов страницы byteCount = sizeof(buffer); byte bCount=0; for (byte i=0; i<2; i++) { // начинаем читать страницы status = mfrc522.MIFARE_Read(pages[i], buffer, &byteCount); if (status != MFRC522::STATUS_OK) { Serial.print("Read error: "); Serial.println(mfrc522.GetStatusCodeName(status));} else { if (pages[i] == 4) { bCounter = 0; // 32-битный счетчик для номера // биты 0-3 for (bCount=0; bCount<4; bCount++) { readBit = bitRead(buffer, (bCount+4)); setBitsForGood(readBit); } // биты 4 - 27 for (pageByte=5; pageByte >2; pageByte--) (for (bCount = 0; bCount<8; bCount++) { readBit = bitRead(buffer, bCount); setBitsForGood(readBit); } } // биты 28-31 for (bCount=0; bCount<4; bCount++) { readBit = bitRead(buffer, bCount); setBitsForGood(readBit); } Serial.print("Ticket number: "); Serial.println(ticketNumber, DEC); } if (pages[i] == 8) { // читаем дату выдачи Serial.print("Issued: "); unsigned int issueDate = buffer * 256 + buffer; // количество дней с 01.01.1992 в десятичном формате, 256 - сдвиг на 8 бит printIssueDate(issueDate); Serial.print("Good for (days): "); // срок действия Serial.print(buffer, DEC); Serial.println(); Serial.print("Trip reminder: "); // количество оставшихся поездок Serial.print(buffer, DEC); Serial.println(); } } } // Halt PICC mfrc522.PICC_HaltA(); } void printIssueDate(unsigned int incoming) { boolean isLeap = true; // признак високосного года int days={0,31,59,90,120,151,181,212,243,273,304,334}; // последний по порядку день месяца для обычного года byte dayOfMonth, monthCounter; unsigned int yearCount; incoming = incoming+1; // подогнал под ответ, но возможно это как раз необходимая коррекция, потому что начало отсчета - 01.01.1992, а не 00.01.1992 for (yearCount = 1992; incoming >366; yearCount ++) (// count the year and the number of days that have passed since the ticket was issued if ((yearCount% 4 == 0 && yearCount% 100! = 0) || yearCount% 400 == 0) (incoming = incoming - 366; isLeap = true;) else (incoming = incoming - 365; isLeap = false;)) for (monthCounter = 0; incoming> days; monthCounter ++) (// find out the month number) // count the day of the month if (isLeap == true) (/ / if a leap year if (days> 31) (// if not the first month, then add units dayOfMonth = incoming - (days + 1);) else (dayOfMonth = incoming - (days); // if the first - add nothing, because the shift starts from February)) else (dayOfMonth = incoming - (days); // if not a leap year) Serial.print (dayOfMonth); Serial.print ("."); Serial.print (monthCounter); Serial.print ("."); Serial.print (yearCount); Serial.println (); ) void setBitsForGood (byte daBeat) (if (daBeat == 1) (bitSet (ticketNumber, bCounter); bCounter = bCounter + 1;) else (bitClear (ticketNumber, bCounter); bCounter = bCounter + 1;))

What does this sketch give me? Well, firstly, a little head training - you know, I had to think when I dealt with the reader and the code. Secondly, I can always find out how many trips are left and when the card will end. Taking into account the fact that I do not have NFC in my smartphone, it turns out quite conveniently.

The result of the monster's work

Of course, in this case we are not even talking about making a "copy" of the ticket. This is a purely informational function that duplicates the terminal in the metro lobby.

In general, after such success, it was possible to take on the second proposed task, which, in theory, should have been the first due to its simple implementation.

So, an outlet that turns on when you need it. Here, the card (any supported by the reader and suitable for placement in the target device) is used exclusively as a pass, that is, only its serial number is of interest.

The logic is simple: if the reader sees a card with a specific number, it turns on the socket. If he doesn’t see it, he turns it off.

SOCKET MONSTER

#include #include #define SS_PIN 53 #define RST_PIN 9 MFRC522 mfrc522 (SS_PIN, RST_PIN); // Create MFRC522 instance. unsigned long uidDec, uidDecTemp; #include RCSwitch mySwitch = RCSwitch (); boolean switchOn = false; boolean cardRead = false; void setup () (Serial.begin (9600); // Initialize serial communications with the PC SPI.begin (); // Init SPI bus mfrc522.PCD_Init (); // Init MFRC522 card mySwitch.enableTransmit (8); Serial .println ("Waiting for card ...");) void loop () (byte status; byte byteCount; byte buffer; // array length (16 bytes + 2 bytes checksum) byteCount = sizeof (buffer); uidDec = 0; status = mfrc522.PICC_RequestA (buffer, & byteCount); if (mfrc522.PICC_ReadCardSerial ()) (for (byte i = 0; i< mfrc522.uid.size; i++) { uidDecTemp=mfrc522.uid.uidByte[i]; uidDec=uidDec*256+uidDecTemp; } if ((uidDec==2218415941) && (switchOn == false)) { mySwitch.sendTriState("00110000F000"); switchOn = true; // Serial.println("Switched On"); } mfrc522.PICC_ReadCardSerial(); } else { if (switchOn == true) { mySwitch.sendTriState("001100000000"); // Serial.println("Switched Off"); switchOn = false; } } }

Likewise, using the map as a trigger, you can execute various home automation scenarios. For example, put a card in an e-book, and place a reader on the bedside table.

When we put the book on the curbstone, the house thinks that we have decided to go to the kingdom of Morpheus, and turns off the lighting. And if we take a book from the curbstone, then it is assumed that we want to read, and then, on the contrary, the background light is turned on so that the electronic ink can be seen, and so that the eyes do not break.

This is how the socket monster works

To summarize: Inexpensive, simple, quite convenient and imaginative.

Ps. I'm sure you can do better and that I don't understand anything about Arduino and programming.

All sorts of links
I liked the review +67 +173

The EM4100 label stores 64 bits of data, which means that the design must contain a 64-bit shift register made up of eight 8-bit 74HC165 registers. The register is reloaded after every 64 shifts to reset the data and start over. The register inputs are as follows:
  • Sync pattern: nine units
  • Vendor / Version ID: 2 blocks of 5 bits, of which 4 is data and the fifth is parity
  • Unique identifier: 8 blocks of 5 bits, of which 4 bits are data, and the fifth is parity
  • Checksum: 4 parity bits, counted column by column
  • Stop bit: "0"

Even encrypted tags are vulnerable to multiple attacks. In addition, it is becoming increasingly easy to emulate tags on NFC-enabled smartphones (which typically run at 13.56 MHz). Just write your field modulation application correctly and you can do whatever you want.

As a standard excuse, let me remind you that the author (And a translator! - Approx. transl.) assumes no responsibility for the consequences of using the information in this article. The reader must be responsible for all his actions.

Frame

Sometimes very lucky. A beautiful case would be great right now that the prototype is finished and the PCB has been ordered. And it was during this time that Fleming finished assembling and launching the OSAA PhotonSaw laser cutting machine. After a year of work on the project, the laser is ready to cut its first parts. Flemming and Rune make the final adjustments and replace the laser cabinet's aluminum lid. You can imagine how happy we all were to see this thing work.

With the machine running, we got the opportunity to test our project in real life. The housing for our RFID tag is made of 2mm glass. This corpus is the first object made with PhotonSaw, yes!

The idea was born to place the coil on the outside of the case. At first, it was decided to use half the height of the body, but this did not work in practice (additional holes in the long sides are thus not used). The coil was just superbly placed around the perimeter of the entire case, although I had doubts if the rectangular winding (105x55 mm) would be too large for normal electromagnetic coupling.

The test coil was wound, without any calculations, with a 0.4 mm wire, 66 turns. And, obviously, we were lucky again, because the coil turned out exactly as it should, with an inductance of 645 μH, with a tag connected, giving a resonant frequency of 125.2 kHz. The door reader test showed that the prototype works just fine with this coil.

With a coil on the outside of the case, the thickness of the latter can be reduced. The internal thickness now depends only on the height of the parts on the board, and taking into account the board thickness, it should be about 6 mm. Also, it would be nice to add engraving. Flemming suggested rounding the sides of the case for aesthetic and ergonomic reasons. The curved body will also better protect the sides of the coil, because where there is no strong tension, the turns of the wire tend to crawl out.

The PhotonSaw is still not quite up to par: the engraving on the top cover has slipped significantly. It is necessary to finalize it before making the final version of the case. Curved contours also suffered a calculation error in the software because the beam did not return to its original position after passing the closed path. But anyway, the curves look really smooth.

PCB assembly

The ordered payment arrived:

The assembly was not very difficult. Solder paste was stenciled onto the board, all the parts were placed, and then they were soldered in a homemade oven.

Through the blocking capacitance (47 pF have a resistance of about 27 kOhm at a frequency of 125 kHz) and the protective diodes, the current flows to the power rails. The energy supplied from the coil is enough to maintain the supply voltage of about 1 V. The current can reach 250-500 μA. Surprisingly, 74HCs seem to work with this kind of power supply. Unfortunately, with this kind of tension, strange things happen. The 74HC has an internal reset circuit and you need to make sure it works. Note that disabling the protective diodes does not help. At the inputs of the microcircuits there are internal protective diodes, which in this case open and do the same job.

A power reset is only triggered if the supply voltage drops below a certain level for a period of time. If the voltage remains too high, then the internal logic can become confused, because some parts of it may be in an indeterminate state, while others are working as expected. An internal reset is required to bring all chips to a consistent state. Thus, the circuit will be unstable at very low supply voltages.

The following symptoms were observed: the tag works for some time, while sending the correct data. If you remove the coil from the reader and then return it back, you can place bets whether the tag will turn off. Sometimes it works, sometimes it doesn't. Disabling the PLL makes the situation worse. Low power consumption leads to the fact that the reader will receive data from the switched off tag from time to time. This is what "energy efficient system" means.

There are two solutions: 1) reduce the capacitor in the clock recovery circuit to 15pF, and 2) insert a 22-100k resistor between the power supply and ground to discharge excess energy. The second method leads to an increase in leakage during operation and is not really required when the capacitor is reduced. However, it is provided as an option, and it is still better than the undefined state of the microcircuits.

Modulation by current or voltage

The modulator brought a fresh portion of the headache. Modulation completely disappeared when the coil was placed at a certain distance from the reader. It could also happen when moving the coil towards or away from the reader.

The reason turned out to be in the modulator circuit. MOSFETs connect the coil to a resistor of a certain resistance. However, if the power consumption from the loop is high, the resistance of the modulator is much higher than the resistance of the supply circuits. This leads to the fact that the modulation depth depends on the consumed current, which is not very good. The situation was worsened by the choice of a limiting Zener diode for a lower voltage than in the prototype.

It was decided to switch the modulator from voltage modulation to current modulation. For the first mode, the resistor was in the drain circuit, and now it is connected between the source and ground. The gate-source voltage will drop across this resistor until a value remains slightly above the transistor opening threshold (0.9-1.1 V), which will transfer the transistor to linear mode. Now the current through the transistor will be stable, regardless of the voltage at the drain.

Prototype testing has shown that current modulation works very well. A cheap, nameless reader no longer crashes (okay, maybe once in a hundred or so). It can be assumed that this change will work wonderfully on other readers as well, and the tag will now probably be able to work on most of them.

Completed version 1

You can see the changes made on the PCB. I didn't have a 15pF SMD capacitor, I had to solder a regular one with legs. The modulator is overgrown with additional resistors at the sources of the transistors. Generally acceptable for the first version.

(pictures are clickable)





Video demo

Conclusion

You might think that this 7400 logic design can be attributed to retro circuitry, but this is not entirely true. First, the 74HC family today is not that old. Secondly, low-power circuits are always relevant. Third, single gate ICs (such as the Schmitt trigger used) are often used in modern designs. It is often forgotten that the development of technology does not stop for older families of microcircuits. They just became less noticeable against the background of the general diversity.

The analog part turned out to be more difficult to design than the digital one. This is due in part to the lack of specifications, but mainly due to the many trade-offs required to meet parameters and unforeseen side effects. Digital designs have relatively few options, while analog designs usually require a balance between different (and often opposing) criteria.

I have to admit that the 74HC is made very, very well. The developers knew what they were doing and achieved very low power consumption. At first I had some doubts whether the tag could work from passive power supply, but after reading the specifications, it remained only a matter of correct circuitry. There is still room to optimize different parts of the label, though.

Now let's see how this project performs in the 2012 7400 competition. The submission of applications for the competition ends on November 31st. Let's wish the author good luck! - Approx. transl.

Tags: Add Tags

RFID reader - cards and key fobs
on the ATtiny13 microcontroller

A source: www.serasidis.gr
Vassilis serasidis

Translation: Vadim commissioned by RadioLocman

Recently, various projects based on RFID keys have gained wide popularity, which are used in security systems, security and access control systems. At some enterprises and organizations, such systems, supplemented with specialized software, are used for recording working hours, accounting for material values, etc.

Any radio frequency identification (RFID) system consists of a reader (reader, reader or interrogator) and a transponder (aka RFID tag, sometimes the term RFID tag is also used). In this article, we will look at a simple device for reading RFID keys that support the EM4100 protocol and operate at a frequency of 125 kHz. This type of RFID key can be in the form of a key fob or a credit card (Figure below).

The main component of the reader is a microcontroller Atmel AVR ATtiny13 , which reads the 10-digit unique key identification number and transmits it in ASCII encoding over the serial interface (UART) at 2400 bps to the Host device. In other words, the reader is a separate module that connects to the main processor or microcontroller of the system (Figure 2).

The schematic diagram of the RFID reader is shown in the Figure below:

Let's consider the main features of the circuit. The microcontroller uses a built-in PWM modulator to generate 125 kHz square-wave pulses at the PB0 output. If at the output PB0 log. 0 (falling edge of the pulse), the transistor T1 is in the off state, and the supply voltage of +5 V is applied to the coil L1 through the resistor R1. The rising edge at the output PB0 (log. 1) opens the transistor T1, and the top of the circuit, the output of the coil is connected to ground. At this moment, the coil is connected in parallel with the capacitor C2, forming an LC generator (oscillatory circuit). The transistor switches 125,000 times per second (125 kHz).). As a result, the coil generates a sinusoidal signal with a frequency of 125 kHz.

The reader module generates an electromagnetic field, the energy of which is used to power the RFID key. The transmission of energy between the RFID key and the reader is based on the principle of operation of a conventional transformer: the primary winding of the transformer creates an EMF of induction in all other windings. For our case, the primary coil is the reader coil, and the secondary coil is the RFID key coil. Elements D1, C3 and R5 form an amplitude modulated signal demodulator.

Data exchange between the key and the reader

The process of exchanging data between an RFID key and a reader is very simple, but thought out to the smallest detail. If the RFID key should transmit a log. 0, then it connects a certain "load" to its power source, which requires more energy transmitted by the reader. This will cause a slight voltage drop on the reader side; it is this level that is perceived by the reader as a log. 0

An RFID key generally transmits 64 bits of data in the following sequence (Figure 6):

  1. The first 9 bits (always log. 1) are start bits indicating the start of data exchange.
  2. 4 bits are the least significant bits of the user identification number (D00 - D03).
  3. 1 bit (P0) - the parity bit of the previous 4 bits.
  4. 4 bits - most significant bits of the user identification number (D04 - D07).
  5. Bit 1 (P1) is the parity bit of the previous 4 bits.
  6. 4 bits - the first part of the 32-bit serial number of the RFID key (D08 - D11).
  7. 1 bit (P2) - the parity bit of the previous 4 bits.
  8. Next, the following groups of 4 bits of the key serial number are transmitted, each with a parity bit.
  9. Then 4 bits of the parity of the bit columns are transmitted. For example, the PC0 parity bit for bits D00, D04, D08, D12, D16, D20, D24, D28, D32, and D36.
  10. 1 stop bit.

Data (64-bit sequence) transmitted by the RFID key.

Data integrity is checked by the microcontroller by calculating parity bits for each row and column and comparing with the received data from the RFID key.

Coil design.

A frameless inductor in a reading device with a diameter of 120 mm is wound with a wire with a diameter of 0.5 mm and has 58 turns, however, the author recommends adding 2 - 3 more turns when winding. In order to improve the efficiency of the coil and increase the reading distance of the RFID-key data, it is necessary to calibrate the oscillatory circuit. If, by connecting the oscilloscope to the connection point of R1 and L1, you see distorted peaks on the device screen (Figure 7), then this indicates the need to calibrate the L1 coil.

Distortion of the signal generated by coil L1 indicates the need for calibration.

Calibration can be performed in two ways after applying power to the module.

  1. Connect the oscilloscope probes to the junction of R1 and L1 and, by increasing or decreasing the number of turns of the coil L1, achieve elimination of signal distortion.
  2. If you do not have an oscilloscope, then slowly bring the RFID key to the coil until the key is recognized, which is indicated by a beep. If the key is determined from a distance of 2 cm, then it is necessary to add / delete several turns and then again check the distance from which the key can be read with confidence. With the help of calibration, the author of the scheme achieved a confident reading of the RFID key from 3 cm.

When programming the microcontroller, it is necessary to set the following configuration of Fuse-bits: low byte 0x7A and high byte 0x1F (the microcontroller operates from the built-in 9.6 MHz clock generator, the clock frequency divider by 8 is disabled). The program code occupies 1024 Bytes in the microcontroller memory - all available memory of the ATtiny13 microcontroller is used. Therefore, in the future, when expanding the functionality of the reader, it is better to use another 8-pin AVR microcontroller, for example, ATtiny85.

Downloads:

Microcontroller program source code (AVRStudio 6), firmware (.hex) and circuit diagram -

There has been a lot of talk lately around the use of RFID tags, with discussions even suggesting that, if desired, people with certain computer skills can hack into your home system and get complete information about your belongings.

I decided to figure out this technology myself. To do this, I ordered the necessary components and assembled an RFID reader with my own hands.

In this article, I will show you how to assemble a working RFID reader.

Step 1


In one of the articles I read, the author said that his mobile RFID reader worked only at 13.56 MHz (short wave), but did not work at 1.25 kHz (wavelength below the AM band). I made a reader that works at the industry standard 125 kHz frequency. This means that my reader needs a different combination of antenna and capacitor. The basic diagram and the basic formula illustrate this. To get the value you want, select the appropriate formula, plug in your values ​​and use the calculator to get the result.

List of components:

  • About 12m thin wire, 22 to 30 gauge (I used 30 gauge).
  • Any diode (I used red).
  • One 0.005 μF capacitor or two 0.01 μF disc capacitors in series.
  • 2-5 disc capacitors 100 pF.
  • Coil base (any base, coil diameter must be 10 cm).
  • Printed circuit board for prototyping, for trial assemblies.
  • Printed circuit board for neat and precise assembly.
  • The ability to access the reader to take readings from the receiver.
  • No batteries are required as the receiver is powered wirelessly from the reader.

Step 2



First, I wound the wire on a base about 10 cm in diameter (I'm more than sure that a couple of centimeters, plus or minus, will not play a role).

With the wire wound around the base, I compared the coil to other coils I already had. So I roughly estimated the inductance of the new coil - I got about 330 μH.

I substituted 330 μH into the formula and the result obtained meant that this coil needed a 0.005 μF capacitor for the coil-capacitor pair to "resonate" at 125 kHz, and there was enough current to power the diode.

Before proceeding with the soldering, I made a preliminary assembly on a breadboard.

Step 3


On the breadboard, first we connect the coil, diode and two disk 0.01 μF capacitors (connected in series with each other, and then in parallel with the diode, which gives a total capacitance of 0.005 μF (5000 pF)), then turn on the RFID reader. When the reader is positioned at a distance of about 10 cm from the coil, the diode is on. The diode burns very brightly at a distance of about 1.5 cm.

Then I added a 100pF (0.0001uF) capacitor across the circuitry, which increased the range of the reader. Then I found out that by adding a second capacitor of the same kind in parallel to the whole circuit, I would further increase the range of the reader. By contrast, the addition of a third capacitor reduced this radius. Thus, I have established that 5200pF is optimal for my coil (illustration of the third attempt).

My receiver would have triggered 10cm using a 0.005uF capacitor in parallel with the coil and diode, but the breadboard allowed additional capacitors and thus increased the distance to 12.5cm.

Step 4




The photographs clearly show how the brightness of the diode glow increases as the coil approaches the reader.
This small device operates at 125 kHz. It is quite simple to assemble it using more or less suitable materials.

Step 5

All the components used in the prototype assembly on the breadboard were assembled on a printed circuit board and soldered. Then I glued the circuit to the coil so that the entire device could be moved from place to place just in the hand, without unnecessary wires or connections. The device is working properly. I expected it to respond to all RFID readers within 7-12 cm and operating at 125 kHz.

Step 6

Since I know that the maximum luminescence of the diode at a given distance is achieved with a capacitance of 0.0052 μF, I inserted this value along with the 125 kHz wavelength into the corresponding formula and obtained an inductance value of 312 μH, instead of the 330 μH I expected.

Mathematical calculations do not play a huge role here, although it was thanks to them that I calculated the capacitance of the capacitors suitable for my coil. This, of course, could be figured out by trial and error, but it would take a long time.

Top related articles