jm rfid demo
mikea
Posts: 283
in Propeller 1
Hi, im not clear on how to set up the display with this object and what to do with pins 28 through 31. Does full duplex serial need to be used through an lcd display, or is it something on the computer like the p.s.t.? Also is there something i need to set up for i2c or is that taken care of through com lines built in. Im using the professional dev. board. For the enable on the rfid reader and serial out i have 3.9k resistor to deal with the 5v and 3.3 volt difference. Thanks for the help!
'' ================================================================================================= '' '' File....... jm_rfid_demo__2015.spin '' Purpose.... Identifies RFID tags while displaying a running timer '' Author..... Jon "JonnyMac" McPhalen '' Copyright (c) 2015 Jon McPhalen '' -- see below for terms of use '' E-mail..... jon@jonmcphalen.com '' Started.... '' Updated.... 13 APR 2015 '' '' ================================================================================================= con { timing } _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 ' use 5MHz crystal CLK_FREQ = (_clkmode >> 6) * _xinfreq ' system freq as a constant MS_001 = CLK_FREQ / 1_000 ' ticks in 1ms US_001 = CLK_FREQ / 1_000_000 ' ticks in 1us DISPLAY_MS = 4_000 con { io pins } RX1 = 31 ' programming / terminal TX1 = 30 SDA = 29 ' eeprom / i2c SCL = 28 RFID_RX = 17 ' RFID on PAB RFID_EN = 16 obj io : "jm_io" ' basic io control time : "jm_time" ' timing and delays rfid : "jm_rfid" ' * RFID input term : "jm_fullduplexserial" ' * serial io for terminal str : "jm_strings" ' string methods var long showtag ' true when data data displayed dat lastsecs long -1 ' for clock updates timestr byte "00:00:00", 0 pub main setup ' start program objects term.tx(term#CLS) repeat show_clock(0, 0) ' show running clock check_tag pub show_clock(x, y) | s, m, h s := time.seconds ' get seconds from timer if (s == lastsecs) return lastsecs := s ' save for next check h := (s / 3600) // 24 ' extract hours (keep 0..23) m := (s // 3600) / 60 ' extract minutes s //= 60 ' extract seconds timestr[0] := h / 10 + "0" ' format time timestr[1] := h // 10 + "0" timestr[3] := m / 10 + "0" timestr[4] := m // 10 + "0" timestr[6] := s / 10 + "0" timestr[7] := s // 10 + "0" cursor_xy(x, y) ' move cursor term.str(@timestr) ' print time pub cursor_xy(x, y) term.tx(term#GOTOXY) term.tx(x) term.tx(y) pub check_tag | state, tidx, t1 state := rfid.check ' check on rfid tage ifnot (showtag) ' if no tag showing if (state == rfid#READY) ' has tag been presented? tidx := rfid.tag_index(@Tags, LAST_TAG) ' validate the tag if (tidx => 0) ' if valid display_tag(tidx) ' show the tag info showtag := true ' enable timing of display time.start ' restart timer (optional) t1 := time.millis ' mark display sync point lastsecs := -1 else rfid.enable ' re-enable after unknown tag else if ((time.millis - t1) => DISPLAY_MS) ' time to clear last tag? clear_tag ' clear previous tag info showtag := false ' mark cleared rfid.enable ' re-enable rfid pub display_tag(tidx) '' Displays tag information if tidx in valid range if ((tidx < 0) or (tidx > LAST_TAG)) return cursor_xy(0, 2) term.str(string("Tag.... ")) term.str(rfid.address) term.tx(term#CR) term.str(string("ID..... ")) term.dec(tidx) term.tx(term#CR) term.str(string("Name... ")) term.str(str.pntr(tidx, @Names)) term.tx(term#CR) pub clear_tag '' Clears onscreen tag information cursor_xy(0, 2) term.tx(term#CLRDN) ' clear screen from here showtag := false pub setup '' Setup IO and objects for application time.start ' start/sync time rfid.start(RFID_EN, RFID_RX) ' start RFID term.start(RX1, TX1, %0000, 115_200) ' terminal via programming port dat { tags data } Tags Tag0 byte "0415148F26", 0 Tag1 byte "0415148E0C", 0 Tag2 byte "041514AEA3", 0 Tag3 byte "041514A076", 0 Tag4 byte "04129C1B43", 0 LAST_TAG byte 4 Names Name0 byte "Luke Skywalker", 0 Name1 byte "Princess Leia", 0 Name2 byte "Darth Vader", 0 Name3 byte "Obi Wan Kenobi", 0 Name4 byte "Yoda", 0 dat { license } {{ Terms of Use: MIT License Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Comments
There is no setup needed beyond what is already done in the program. The enable is an output from the propeller and an input on the rfid so it does not need a resistor, but the serial output from the rfid is an input to the propeller and does require the resistor.
Post (or link) the code which is working well. I'll see if I can modify to display the ID numbers of unrecognized tags.
Edit: Is this the code you're using? I'll see if I can modify it to display unrecognized ID numbers.
I used the code attached to the posted I linked to earlier. I've attached the modified version with the name "rfid_demo160910a".
The code you embedded above looks like it displays the number of the card or the tag already?
Do you not see this information?
I modified the code you just posted to include an extra display of the serial number of the card just read but I doubt it will make much of a difference to you. This second program is named "rfid_demo2_160910a"
I've read posts from JonnyMac where he stated his wish for modified code not to include the prefix "jm". I made minor changes but I still removed the "jm" prefix as JonnyMac has asked.
Let me know if the attached code works okay. It compiles but I haven't tested it with an RFID reader. I don't have a Parallax RFID reader.
Are you sure all the tags and cards you have are intended to be used with the Parallax reader?
rfid_demo160910a i cant get to compile. Even though the sub folder objects are open it will show error message that the objects are not in the library or open folder. I've tried saving the objects also.
Having objects open wont allow the top object to find them. This is an error in the Propeller Tool's instructions. You need to have the child objects either in the same folder as the top object of the child objects have to be in the Propeller Tool's library folder.
I've attached an archive of "rfid_demo160910a".
I don't know what would cause the other problems you're describing.
, but no tag i.d. . I found a couple programs and tried it with bs2 and having the same issue. one bs2 is specifically for showing the id, but it wont read at all. The other bs2 code says id is unidentified, but it will acknowledge its been read. i wonder if there's a problem with the cards/fob, and if its possible to buy some that show their id's?
I've only used the inexpensive MRFC522 RFID readers like those found on ebay. These readers use 13.56MHz cards and tags which are also very inexpensive.
I've posted Propeller code in this thread which will read the serial numbers from the 13.56MHz cards and tags.
I think I was able to write data to the cards and read data from the card but I don't think I got all the password features working correctly with the Propeller.
I don't know enough about RFID to know how these cheap cards and readers compare with the Parallax reader but I thought the cheap reader worked well.
I tend to write product demos that run via PST so that there is nothing else to connect. This is not a full-blown app, it's a demo so that you can learn to integrate the Parallax RFID reader into your own projects.
As others have pointed out, there is nothing to do with pins 28..31. I put them into the listing as a reminder that they do serve a purpose and should not be used in your app without careful consideration.
Pin 1 - P0 - rx1, data in from the rfid (needs 3.9 - 10K current limiting resistor)
Pin 2 - P1 - tx1, data out from propeller - not used
Pin 3 - P2 - rfid enable - enables rfid reader when low
I tend to use the four port serial object with port 0 for debugging with pst and the rest as comms for whatever else I need.