April 30, 2007

RFIDr at Max Ex.

April 24, 2007
April 13, 2007

Success!

We presented our project titled RFIDr to our peers and professor with great feedback from lots of people. We managed to speed up our basic stamp code, because at the last minute we had problems where our ruby on rails app was reading the basic stamp faster than it was outputing numbers so we were drawing blanks sometimes. Thankfully we got the problem solved. We did have one slight problem however in that we were unable to get the display to reset to the splash screen when a tag was removed. We will have pictures and video up soon.

April 9, 2007

Tag Love

We finally found the proper PBasic code to let us compare multiple RFID tags with a list. (http://parallax.com/dl/src/prod/rfid1.bs2). At first we were trying to assign the RFID tag (ex. 04129C1A1C) inside our program code but it wasn’t letting us store the required ten digits in a variable (limited to 16 bits). With this new code we declare our tag ids as data before we run our program code. The code then takes the RFID tag and assigns a number to it which is then passed to the Ruby program we have written. This coder here is an example but only reads up to three tags instead of ten:

’ =========================================================================

‘   File……. RFID.BS2
‘   Purpose…. RFID Tag Reader / Simple Security System
‘   Author….. (c) Parallax, Inc. — All Rights Reserved
‘   E-mail….. support@parallax.com
‘   Started….
‘   Updated…. 09 SEPT. 2005

‘   {$STAMP BS2}
‘   {$PBASIC 2.5}

’ =========================================================================


’ ——-[ Program Description ]——————————————————————-

’ Reads tags from a Parallax RFID reader and compares to known tags (stored
’ in EEPROM table).  If tag is found, the program will disable a lock.


’ ——-[ Revision History ]————————————————————————


’ ——-[ I/O Definitions ]————————————————————————-

Enable          PIN     0                       ’ low = reader on
RX              PIN     1                       ’ serial from reader
Spkr            PIN     2                       ’ speaker output
Latch           PIN     3                       ’ lock/latch control


’ ——-[ Constants ]———————————————————————————-

#SELECT $STAMP
  #CASE BS2, BS2E, BS2PE
    T1200       CON     813
    T2400       CON     396
    T4800       CON     188
    T9600       CON     84
    T19K2       CON     32
    TMidi       CON     12
    T38K4       CON     6
  #CASE BS2SX, BS2P
    T1200       CON     2063
    T2400       CON     1021
    T4800       CON     500
    T9600       CON     240
    T19K2       CON     110
    TMidi       CON     60
    T38K4       CON     45
  #CASE BS2PX
    T1200       CON     3313
    T2400       CON     1646
    T4800       CON     813
    T9600       CON     396
    T19K2       CON     188
    TMidi       CON     108
    T38K4       CON     84
#ENDSELECT

SevenBit        CON     $2000
Inverted        CON     $4000
Open            CON     $8000
Baud            CON     T2400


#SELECT $STAMP
  #CASE BS2, BS2E
    TmAdj       CON     $100                    ’ x 1.0 (time adjust)
    FrAdj       CON     $100                    ’ x 1.0 (freq adjust)
  #CASE BS2SX
    TmAdj       CON     $280                    ’ x 2.5
    FrAdj       CON     $066                    ’ x 0.4
  #CASE BS2P
    TmAdj       CON     $3C5                    ’ x 3.77
    FrAdj       CON     $044                    ’ x 0.265
  #CASE BS2PE
    TmAdj       CON     $100                    ’ x 1.0
    FrAdj       CON     $0AA                    ’ x 0.665
  #CASE BS2PX
    TmAdj       CON     $607                    ’ x 6.03
    FrAdj       CON     $2A                     ’ x 0.166
#ENDSELECT


LastTag         CON     3


#DEFINE __No_SPRAM = ($STAMP

’ ——-[ Variables ]———————————————————————————-

#IF __No_SPRAM #THEN
  buf           VAR     BYTE(10)                ’ RFID bytes buffer
#ELSE
  chkChar       VAR     BYTE                    ’ character to test
#ENDIF

tagNum          VAR     NIB                     ’ from EEPROM table
idx             VAR     BYTE                    ’ tag byte index
char            VAR     BYTE                    ’ character from table


’ ——-[ EEPROM Data ]——————————————————————————-

Tag1            DATA    “0101A625F5”            ’ valid tags
Tag2            DATA    “04129C1A1C”
Tag3            DATA    “041402CCD7”

Name0           DATA    “Unauthorized”, CR, 0
Name1           DATA    “Tag 1 (White Card)”, CR, 0
Name2           DATA    “Tag 2 (Oval)”, CR, 0
Name3           DATA    “Tag 3 (Small Round)”, CR, 0


’ ——-[ Initialization ]—————————————————————————

Reset:
  HIGH Enable                                   ’ turn of RFID reader
  LOW Latch                                     ’ lock the door!


’ ——-[ Program Code ]——————————————————————————

Main:
  LOW Enable                                    ’ activate the reader
  #IF __No_SPRAM #THEN
    SERIN RX, T2400, [WAIT($0A), STR buf\10]    ’ wait for hdr + ID
  #ELSE
    SERIN RX, T2400, [WAIT($0A), SPSTR 10]
  #ENDIF
  HIGH Enable                                   ’ deactivate reader

Check_List:
  FOR tagNum = 1 TO LastTag                     ’ scan through known tags
    FOR idx = 0 TO 9                            ’ scan bytes in tag
      READ (tagNum - 1 * 10 + idx), char        ’ get tag data from table
      #IF __No_SPRAM #THEN
        IF (char buf(idx)) THEN Bad_Char     ’ compare tag to table
      #ELSE
        GET idx, chkChar                        ’ read char from SPRAM
        IF (char chkChar) THEN Bad_Char      ’ compare to table
      #ENDIF
    NEXT
    GOTO Tag_Found                              ’ all bytes match!

Bad_Char:                                       ’ try next tag
  NEXT

Bad_Tag:
  tagNum = 0
  GOSUB Show_Name                               ’ print message
  FREQOUT Spkr, 1000 */ TmAdj, 115 */ FrAdj     ’ groan
  PAUSE 1000
  GOTO Main

Tag_Found:
  GOSUB Show_Name                               ’ print name
  HIGH Latch                                    ’ remove latch
  FREQOUT Spkr, 2000 */ TmAdj, 880 */ FrAdj     ’ beep
  LOW Latch                                     ’ restore latch
  GOTO Main

  END


’ ——-[ Subroutines ]——————————————————————————-

’ Prints name associated with RFID tag

Show_Name:
  DEBUG DEC tagNum, “: “
  LOOKUP tagNum,
         [Name0, Name1, Name2, Name3], idx      ’ point to first character
  DO
    READ idx, char                              ’ read character from name
    IF (char = 0) THEN EXIT                     ’ if 0, we’re done
    DEBUG char                                  ’ otherwise print it
    idx = idx + 1                               ’ point to next character
  LOOP
  RETURN

April 6, 2007

Auto updating from the txt file.

So….I guess they don’t hate us after all.

Flickr hates us now?

The code that we have been using to query flickr is only now starting to give us some problems.  Last night while we were testing out the app, we couldn’t load any images because it said that:

our API Key had expired.  However, when we logged into our flickr api account, it said that our key was still active:

Searching on the flickr API forums, people have had this problem before.  We actually had this problem when we were first making the app.  Someone posted a fix for this error, that needs to be put in the environment.rb file:

Just under the line that reads “require ‘flickr’ ” put in:

 MY_KEY=’ourkeyhere
class Flickr
alias old_initialize initialize
def initialize(api_key=MY_KEY, email=nil, password=nil)
old_initialize(api_key, email, password)
@host=”http://api.flickr.com”
@activity_file=’flickr_activity_cache.xml’
end
end

This code was working fine up until yesterday, when all of a sudden it told us that our active API key was expired.  We have posed a discussion topic in the flickr API group, and are hoping to receive a reply. 

April 5, 2007

Making our installation

We have constructed our installation and connected it to the basic stamp.  This basic stamp will be connected to the computer.

 


Front view

 

back view of wires going into basic stamp

close up of wires: black to ground, red to +5V, greens to pins 0/1

 

RFID, scanner mounted on ceiling of box, wires connected to it.

Thats all!