Results 1 to 7 of 7

Thread: RDM630 125khz RFID Card Reader CODE EXAMPLE

  1. #1

    Default RDM630 125khz RFID Card Reader CODE EXAMPLE

    This is a ruffy had to tryout the new forum,recently my car immobilizer packed up
    so it was time to look for a picaxe replacement which one lol 8m2 14m2 18m2 20m2 lol !

    The RDM630 has a uart output of 9600 bps TTL so we should interface it using T9600

    #picaxe 20X2    'version C.0 marks   
    #Terminal 38400
     EEPROM   0,(50,66,48,48,66,48,48,55,50,51,66,55)    'RFID TAG1
     EEPROM  12,(50,66,48,48,66,48,67,55,52,56,57,55)    'RFID TAG2
     SETFREQ M32
     	SYMBOL RDM630     = B.4         'TTL use T9600
     	SYMBOL BlueLED    = C.4
     	SYMBOL LatchRelay = C.0
     	SYMBOL ResetRelay = C.1
     	SYMBOL data1      = B1          'ManufacturersCode
     	SYMBOL data2      = B2          'ManufacturersCode
     	SYMBOL data3      = B3          'Byte 1 TAG number	
     	SYMBOL data4      = B4          'Byte 2 TAG number
     	SYMBOL data5      = B5          'Byte 3 TAG number	
     	SYMBOL data6      = B6          'Byte 4 TAG number	
     	SYMBOL data7      = B7          'Byte 5 TAG number
    	SYMBOL data8      = B8          'Byte 6 TAG number
     	SYMBOL data9      = B9          'Byte 7 TAG number
     	SYMBOL data10     = B10         'Byte 8 TAG number	
     	SYMBOL checksum1  = B11         'CheckSum   	
     	SYMBOL checksum2  = B12         'CheckSum	
     	SYMBOL Verify     = b13
     	SYMBOL Decimal    = b14 	
     	SYMBOL checkedData= b15	
     	SYMBOL tagData    = b16
     	SYMBOL RFIDtag    = b17
     PAUSE 2000 
          RFIDtag = 0                    'Start check from first Tag in EEprom
         SerIn RDM630,T9600_32,(2), data1 , data2 , data3 , data4 , data5 , data6 , data7 , data8 , data9 , data10  ,checksum1,checksum2 
          SerTxd(CR,LF," RFID TAG "  ,#b1,",",#b2,",",#b3,",",#b4,",",#b5,",",#b6,",",#b7,",",#b8,",",#b9,",",#b10,",",#b11 ,",",#b12,CR,LF)
          pulsout BlueLED,60000
         FOR Verify = 12 TO 1 STEP -1  'checking in reverse order usually meens less processing 
         tagData = Verify + RFIDtag -1
         READ tagData,Decimal
        SELECT CASE Verify                       
     case  1 :checkedData = data1
     case  2 :checkedData = data2
     case  3 :checkedData = data3
     case  4 :checkedData = data4
     case  5 :checkedData = data5
     case  6 :checkedData = data6
     case  7 :checkedData = data7
     case  8 :checkedData = data8
     case  9 :checkedData = data9
     case 10 :checkedData = data10
     case 11 :checkedData = checksum1
     case 12 :checkedData = checksum2
        END SELECT
         IF Decimal <> checkedData AND RFIDtag = 12 THEN scantag  ' Last RFID Tag in EEprom  checked no match(if we add another Tag it would become 24)
         IF Decimal <> checkedData THEN : RFIDtag = RFIDtag + 12 : GOTO checktag : ENDIF ' Check next RFID Tag in EEprom for a match
         NEXT Verify
          pulsout BlueLED,20000 
         SerTxd(CR,LF,"VERIFY OK",CR,LF) 'Once tag has been verified, because of the 20 secs delay below, you must wait before you can scan another tag
          pulsout BlueLED,20000
          pulsout LatchRelay,3000 ' latch relay on so I can start my car
          SwitchOn BlueLED 
          pause 60000 pause 60000 ' 20 second delay approx
          pulsout ResetRelay,3000 ' reset dissable crank
          SwitchOff BlueLED:
         GOTO ScanTag             ' probaly remove this line so process will only repeat when powered ON again from ignition.
    Used on my picaxe 20x2 driving a blueled and 5v latch relay with set and reset coil.
    Led will flash whenever card data is read.

    Scan your Tag - 12 decimal numbers should be displayed
    You can copy the 12 byte code from the Serial Terminal
    than just paste over the existing eeprom statement.

    When Tag is scanned and matches the eeprom statement VERIFY OK will be seen in the Terminal.
    Relay output and led remains on for a short period ( enough to start the car hopefully)
    could be used to arm and disarm an alarm system or unlock a door.
    then can just use the same keytag for everything lol!
    Last edited by marks; 20-10-2013 at 05:30. Reason: add info and change sum symbols for easier understanding

  2. #2
    Senior Member
    Join Date
    Aug 2010
    Behind your TV...
    Blog Entries


    Except by sharing your code we now know the RFID tags to your to buy a few hundred thousand RFID cards and hope we get the right code in at least 1!!!
    20X2 Games pointlessly white text
    Non Hid compliant mice

  3. #3


    Actually if any one is smart enough to work the checksum numbers out you'l find I already changed those numbers lol.
    and yes you only need one card a programmable one
    and they have modules around as well that can read your tag save it in eeprom and then be used as your card.
    Unfortunatedly i guess we can only try to make things a little harder.

  4. #4
    Senior Member
    Join Date
    Jan 1970
    Rangiora, New Zealand


    And that is what, ultimately, security is all about...... buying more time!
    In theory, there is no difference between theory and practice. In practice, there is...

  5. #5
    New Member
    Join Date
    Sep 2011
    Sligo, Ireland


    Thanks for this Marks.. I've just brought one of these ( promptly locked up my first 18m2 chip trying to interface with ) and you're code will make life a LOT easier ...Now to wire up the 20x2...:-) Cheers..


  6. #6


    I will have to blame neiltechspec for sparking interest in this when I should be doing my tax lol.

    I have written the new programs to work with the 18m2 and so hopefully should also work with a 08m2 .
    Once programmed the serial terminal will open, just scan all your cards.
    It should then display EEPROM data and the 10 digit RFID tag numbers ,just copy and paste into our next program.
    (Click & drag the left mouse button over all the text,while still holding down click and release the right mouse button
    then release the left button you should then be able to select copy from the menu).
    '#picaxe 08m2  'syntax only
    #picaxe 18m2    'version 2.D AXE132  marks
    #terminal 38400
    SETFREQ M32              'RMD630 sends 12 ASCII bytes  
    SYMBOL RDM630     = C.1  'TTL use T9600 
    SYMBOL BCD        = B0   :  SYMBOL DECimal  = B0 ' bit7: x : x : x | bit3 : x : x : x
    SYMBOL HEX        = B1
    SYMBOL data0      = B2
    SYMBOL data1      = B3
    SYMBOL data2      = B4	
    SYMBOL data3      = B5
    SYMBOL CarryBit   = b6
    SYMBOL BitCount   = b7
    SYMBOL Index      = b8	
    SYMBOL RFIDtag    = b9   :  RFIDtag = 0 'Change to your saved EEPROM start position.
    bptr = 28
    SERIN RDM630,T9600_32,(2),@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc
    DisplayTagIDdata:  'Display 4byte HEX
     SERTXD("EEPROM ",#RFIDtag," ,($",@bptrinc,@bptrinc,",$",@bptrinc,@bptrinc,",$",@bptrinc,@bptrinc,",$",@bptrinc,@bptr,") 'RFID TAG ")
    TagIDdata:'Convert ASCII to 4 dataBytes   
       FOR bptr = 30 TO 37   
         IF @bptr > "9" THEN : @bptr=@bptr-7 : ENDIF
         @bptr = @bptr * 16   
      bptr= 37
         data0 = @bptrdec / 16 + @bptrdec
         data1 = @bptrdec / 16 + @bptrdec
         data2 = @bptrdec / 16 + @bptrdec
         data3 = @bptrdec / 16 + @bptrdec 
    Covert32bitHEX:  'Convert 32bitHEX to BCD
    CarryBit = 0
    BitCount = 32
       FOR bptr = 2 TO 5 
          HEX = @bptr / 128 : @bptr = @bptr * 2 + CarryBit : CarryBit = HEX
        FOR bptr = 44 TO 40 STEP-1
           HEX = @bptr / 128 : @bptr = @bptr * 2 + CarryBit : CarryBit = HEX  
       DEC BitCount 
         IF BitCount  <> 0 THEN : bptr = 40
           FOR Index = 0 To 4
                 BCD = @bptr + 3
               IF Bit3 = 1 THEN : @bptr = BCD : ENDIF
                   BCD = @bptr + 48
                 IF Bit7 = 1 THEN : @bptr = BCD : ENDIF
               INC bptr
           NEXT index
    LOOP UNTIL BitCount = 0
    Display10DigitDecimal: 'Convert BCD to DEC 
          FOR bptr = 40 TO 44
             BCD = @bptr / 16 : SerTXD(#DECimal) : BCD = @bptr & $0F : SerTXD(#DECimal) :  @bptr = 0       
      RFIDtag = RFIDtag + 4 
    GOTO ScanTag
    I can now understand why they use to write equations in hex alot faster and less complex for a computer to process lol.
    With this newer program we take advantage of using a checksum and now only require 4 bytes of data to be saved in EEPROM
    for each RFID tag .Usually the first few numbers are the same on these cards so we check them in reverse order to speed things up.
    I'm finding using those bit pointers a real blessing no wonder they feature early in the picaxe manuals.
    At the moment just responds with some messages but this should be enough to get most started!
    Will add some funtion and a circuit when i get a chance.
    '#picaxe 08m2  'syntax only
    #picaxe 18m2    'version 2.D AXE132  marks
    #terminal 38400
    SETFREQ M32              'RMD630 sends 12 ASCII bytes 
    PAUSE 4000               'delay for terminal to open
    SYMBOL RDM630     = C.1  'TTL use T9600
    SYMBOL HEX        = B1
    SYMBOL data0      = B2
    SYMBOL data1      = B3
    SYMBOL data2      = B4	
    SYMBOL data3      = B5
    SYMBOL Index      = b8	
    SYMBOL RFIDtag    = b9   
    SYMBOL dataM      = B10    
    SYMBOL checksum   = B11 
    SYMBOL tagData    = B12
    EEPROM 0 ,($00,$8B,$07,$23) 'RFID TAG 0012060451 (example of valid tag)
    EEPROM 4 ,($04,$05,$06,$07) 'RFID TAG xxxxxxxxxx (last saved positon is 7)
    ScanTag: RFIDtag = 7  'Change this to your Last saved RFID TAG EEPROM position which will be the first to be checked.
             SERTXD (CR,LF,"....")  'Ready to scantag
             bptr = 28    'Serin 12 ASCII bytes     
       SERIN RDM630,T9600_32,(2),@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptr
    TagIDdata:  'Convert ASCII to 4 dataBytes and Check  
       FOR bptr = 28 TO 39   
         IF @bptr > "9" THEN : @bptr = @bptr - 7 : ENDIF
      bptr = 39
      checksum = @bptrdec / 16 + @bptrdec
         data0 = @bptrdec / 16 + @bptrdec
         data1 = @bptrdec / 16 + @bptrdec
         data2 = @bptrdec / 16 + @bptrdec
         data3 = @bptrdec / 16 + @bptrdec 
         datam = @bptrdec / 16 + @bptr  
         datam = datam Xor data3 Xor data2 Xor data1 Xor data0 'Checksum must be valid
      IF datam <> checksum THEN SERTXD (CR,LF,"CheckSum FAIL") : GOTO scantag : ENDIF
          tagData = RFIDtag : bptr = 2
         FOR index = 0 TO 3  
           READ tagData,HEX : DEC tagData : IF @bptrinc <> HEX THEN nexttag 
         RFIDtag = RFIDtag -3  'Display EEPROM location of a matched RFID TAG as programmed above
         SERTXD (CR,LF," Verify OK  EEPROM ",#RFIDtag)    
     GOTO ScanTag    
          NextTag:  IF RFIDtag = 3 THEN SERTXD (CR,LF," Access DENIED") : GOTO scantag : ENDIF 'last RFID TAG in EEPROM to be checked 
                    RFIDtag = RFIDtag - 4 : GOTO checktag  'Check next RFID TAG in EEPROM for match
    Attached Images Attached Images
    Last edited by marks; 20-10-2013 at 05:41.

  7. #7
    Senior Member
    Join Date
    Nov 2012


    That's a great demo code example, Marks. Works nicely on an 08M2 as you thought. I'm using the newer RDM6300. Thanks.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts