Home > My 1976 Mazda RX-5 Cosmo Restoration > RFID Shaved Door Locks/Openers |
In episode 46 of my 1976 Mazda RX-5 Cosmo restoration I created a system of 125KHz RFID operated shaved door solenoid / opener actuation. Here for reference are the relevant schematics, printed circuit patterns and some Arduino code I used for testing.
|
|
Because presenting circuit diagrams and source code is, well, rather boring and difficult on video I've made this page for those who are curious of the details not given on camera.
The RFID reader system consists of an RDM6300 125Khz RFID reader board and antenna coil mounted within the door. The RDM6300 is a pretty handy little board. It's an 125KHz EM4100 compatible RFID reader typically sold with a coil antenna, powered by 5V, that simply spits out the ID of any recognized tag via 9600 baud TTL level serial. This makes them very easy to interface to anything capable of receiving a 9600 baud serial signal, such as any number of Atmel processors, thus Arduino. Ultimately on my Cosmo these receivers will talk to the body ECU, but for testing (as the body ECU has not yet been developed) a simple Arduino Uno receives the signal, compares it to a list of known tags and on a match, energizes a relay for 1 second. This actuates the door solenoid which unlatches the door. After 1 second, the relay is disengaged and the system waits for another tag to be read.
As you can see in the video above, I created a fiberglass mount for the coil. This assembly was the installed into a pocket that I welded into the door, occupying the same location the stock door handles would have. The reader board and associated support board, installed and potted into a sealed aluminium case, mounted inside the door below the reader pocket.
RDM6300 Power Supply / Support Board |
The only circuit needed to make all this work is a board to provide steady 5V power to the RDM6300. The car voltage can vary from 10V (or lower with a dead battery!) during cranking to 15V when the alternator is pounding current into a half depleted battery. As the RDM6300 is a 5V device, directly feeding it from a dirty car power source would be bad.
There's not a lot to the circuit and if you are familiar with the 78xx series linear voltage regulators you'll recognize the basic layout. The circuit takes a "dirty" 12V supply from the car. Two 1N4007 diodes at the input provide reverse polarity protection, preventing current from flowing the wrong way in the circuit. The reverse biased diode shorts any negative voltage spikes as well as hopefully blowing the fuse if the circuit is connected backwards. A 47uF filter capacitor at the input of the regulator assures a steady current flow to the regulator. The 78LO5 is a small TO-92 style linear regulator with a maximum output current of 100mA. Excellent for an application like this where the RDM6300 draws only a few mA. And finally, a small capacitor (0.1uF in this case, value isn't that important) at the output of the regulator stabilizes the output and provides some decoupling of high frequency noise.
Printed Circuit Board Patterns |
The power supply / support board PCB is designed to mount underneath the RDM6300 for a very compact installation. True, I could have made an even smaller board by using surface mount components but the size of the RDM6300 sets the minimum size of the package so there wasn't much benefit in using the harder to solder SMD parts.
The boards are designed in the excellent Robot Room Copper Connection software. Unfortunately, ExpressPCB bought Copper Connection and has renamed it to ExpressPCB Plus, at the same time removing the ability to easily print PCB patterns for toner transfer. This sort of behavior is rather disgusting. Thankfully the old version still works. So if you somehow found a zipped copy of it, it can be manually extracted into the Program Files directory and run without violating the license of the free version.
RFID Reader Module PCB Pattern |
Download (.ZIP, 4K) |
Source Code - 125KHz and 13.5MHz Tag Test |
In the episode I used a simple program to test the serial based 125KHz RDM6300 RFID reader and the SPI based 13.5MHz MFRC522 RFID reader modules. The purpose of this program was to read tags from each reader and dump the tag data to the serial port. This was done to measure the effective distance of the tag to determine which had the greater range. Turns out that both 125KHz and 13.5MHz have about the same range so I chose the 125KHz tags as they were more compact and the separate antenna coil was easier to integrate into my project.
/* Aaron Cake, 2018 Very simple program to test RDM6300 and MFRC522 RFID readers on Arduino UNO. Mostly a copy and paste from the MFRC522 example with added SoftwareSerial to read the RDM6300 MFRC522 Libtary: https://github.com/miguelbalboa/rfid * * * Typical pin layout used: * ----------------------------------------------------------------------------------------- * MFRC522 Arduino Arduino Arduino Arduino Arduino * Reader/PCD Uno/101 Mega Nano v3 Leonardo/Micro Pro Micro * Signal Pin Pin Pin Pin Pin Pin * ----------------------------------------------------------------------------------------- * RST/Reset RST 9 5 D9 RESET/ICSP-5 RST * SPI SS SDA(SS) 10 53 D10 10 10 * SPI MOSI MOSI 11 / ICSP-4 51 D11 ICSP-4 16 * SPI MISO MISO 12 / ICSP-1 50 D12 ICSP-1 14 * SPI SCK SCK 13 / ICSP-3 52 D13 ICSP-3 15 RDM6300 TX to Pin 2 (software serial RX) */ #include <SPI.h> #include <MFRC522.h> #include <SoftwareSerial.h> SoftwareSerial RFID(2, 3); // RX and TX int i; #define RST_PIN 9 // Configurable, see typical pin layout above #define SS_PIN 10 // Configurable, see typical pin layout above MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance void setup() { Serial.begin(9600); // Initialize serial communications with the PC RFID.begin(9600); // start SoftwareSerial to RDM6300 RFID reader while (!Serial); // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4) SPI.begin(); // Init SPI bus mfrc522.PCD_Init(); // Init MFRC522 mfrc522.PCD_DumpVersionToSerial(); // Show details of PCD - MFRC522 Card Reader details Serial.println(F("Ready.")); } void loop() { // Look for new cards on MFRC522 if (!mfrc522.PICC_IsNewCardPresent()) { return; } // Select one of the cards on MFRC522 if (!mfrc522.PICC_ReadCardSerial()) { return; } // Dump debug info about the card on MFRC522; PICC_HaltA() is automatically called, dump it to UART mfrc522.PICC_DumpToSerial(&(mfrc522.uid)); //check the softwareserial port RFID for data from the RDM6300 and print to hardware UART if (RFID.available() > 0) { i = RFID.read(); //Serial.print(i, DEC); Serial.print(i, HEX); Serial.print(" "); } } |
Source Code - RFID Activated Door Solenoid Test |
Once the system was completed, it was time to test it actually opening the doors. Ultimately the funcationality of comparing the read RFID tag to authorized tags will take place within the main body ECU of the car. For now, this test program was run on an Arduino Uno with a connected relay board to actuate the door solenoid. It waits for a recognized tag then when seen, activates the relay for 1 second. This relay supplied power to the door solenoid, thus opening the door.
/* Aaron Cake 2018 Simple RFID relay actuator. I did not code the majority of this, just got lazy and Googled for "rfid lock code" and did a copy paste because this is just for testing. So I don't claim this code. Software listens for a known RFID tag then activates a relay on pin 11 for 1 second. Prone to multiple reads. Don't care as for testing. Final code will reside in car body ECU and have a timeout value to prevent multiple reads. */ #include <SoftwareSerial.h> SoftwareSerial RFID(2, 3); // RX and TX int data1 = 0; int ok = -1; int yes = 11; int tag1[14] = { 2,1,2,3,4,5,6,7,8,9,1,2,3,3 }; //tag which activates relay tag int newtag[14] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0 }; // used for read comparisons void setup() { RFID.begin(9600); // start serial to RFID reader Serial.begin(9600); // start serial to PC pinMode(yes, OUTPUT); // for status LEDs Serial.println("Ready"); } boolean comparetag(int aa[14], int bb[14]) { boolean ff = false; int fg = 0; for (int cc = 0; cc < 14; cc++) { if (aa[cc] == bb[cc]) { fg++; } } if (fg == 14) { ff = true; } return ff; } void checkmytags() // compares each tag against the tag just read { ok = 0; // this variable helps decision-making, // if it is 1 we have a match, zero is a read but no match, // -1 is no read attempt made if (comparetag(newtag, tag1) == true) { ok++; } } void readTags() { ok = -1; if (RFID.available() > 0) { // read tag numbers delay(100); // needed to allow time for the data to come in from the serial buffer. for (int z = 0; z < 14; z++) // read the rest of the tag { data1 = RFID.read(); Serial.println(data1); newtag[z] = data1; } RFID.flush(); // stops multiple reads // do the tags match up? checkmytags(); } // now do something based on tag type if (ok > 0) // if we had a match { Serial.println("Accepted"); digitalWrite(yes, HIGH); delay(1000); digitalWrite(yes, LOW); ok = -1; RFID.flush(); } else if (ok == 0) // if we didn't have a match { Serial.println("Rejected"); ok = -1; } } void loop() { readTags(); } |
Back To Cosmo Page | Mail Me | Search |