RFID RDM6300 Code.. Sample ?? Anyone ??


+ Reply to Thread
Results 1 to 9 of 9
  1. #1
    Join Date
    May 2012
    Location
    Merseyside, UK
    Posts
    237

    Exclamation RFID RDM6300 Code.. Sample ?? Anyone ??

    Hi Thank you for reading….

    I have recently got my self some of these to play with.. RDM630(0) Em4100 Serial Output


    http://imall.iteadstudio.com/im120618002.html

    Question :-

    There seems to be a lack of example code around the internet…. Has anybody used these with PBP?

    Am I right in just reading what the serial is squirting out somehow ??

    Is there any samples to look at ?

    BR and Thank you.

    Andy

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    1,812

    Default Re: RFID RDM6300 Code.. Sample ?? Anyone ??


  3. #3
    Join Date
    Jun 2009
    Location
    Sc*nthorpe, UK
    Posts
    333

    Default Re: RFID RDM6300 Code.. Sample ?? Anyone ??

    Here is a RFID example which uses serin to read 10 characters from a RFID reader.

    RFID by Ecoli-557

    Have a read and as usual if you need more help just ask.

  4. #4
    Join Date
    Jun 2009
    Location
    Sc*nthorpe, UK
    Posts
    333

    Default Re: RFID RDM6300 Code.. Sample ?? Anyone ??

    This is the example from the site in your original post it reads 14 tag IDs using I will look into converting this to PBP 2.5c for you.

    Code:
    #include <p18lf26j11.h>
    #include <delays.h>
    #include <usart.h>
    #include <string.h>
    
    #pragma config OSC = HS //High speed crystal
    #pragma config WDTEN = OFF //Disable watchdog timer
    #pragma config XINST = OFF //Disable Extended CPU mode
    
    //LED Pin Configuration
    #define LED1Pin LATAbits.LATA0
    #define LED1Tris TRISAbits.TRISA0
    #define LED2Pin LATAbits.LATA1
    #define LED2Tris TRISAbits.TRISA1
    #define LED3Pin LATAbits.LATA2
    #define LED3Tris TRISAbits.TRISA2
    
    #define RFIDVCCPin LATBbits.LATB4 //Define RFIDVCCPin as PORT B Pin 4
    #define RFIDVCCTris TRISBbits.TRISB4 //Define RFIDVCCTris as TRISB Pin 4
    
    //Flags & Data Reception Variables
    volatile char tagRecdFlag;
    volatile char tagComingFlag;
    volatile char tagCounter;
    volatile char tagRX[14] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
    
    //RFID Tag IDs
    char rfidTag1[14] = {0x02, 0x30, 0x35, 0x30, 0x30, 0x41, 0x44, 0x44, 0x38, 0x46, 0x46, 0x43, 0x3f, 0x03};
    char rfidTag2[14] = {0x02, 0x30, 0x35, 0x30, 0x30, 0x41, 0x44, 0x42, 0x46, 0x35, 0x37, 0x36, 0x30, 0x03};
    char rfidTag3[14] = {0x02, 0x30, 0x35, 0x30, 0x30, 0x41, 0x45, 0x33, 0x46, 0x36, 0x35, 0x44, 0x33, 0x03};
    
    //Function Prototypes
    void rx_handler(void);
    //Function Prototypes
    
    #pragma code rx_interrupt = 0x8
    void rx_int(void)
    {
        _asm goto rx_handler _endasm
    }
    #pragma code
    
    #pragma interrupt rx_handler
    void rx_handler(void)
    {
        unsigned char rxByte;
        rxByte = RCREG1; //Read character received from USART
    
        if (tagComingFlag == 0 && rxByte == 0x02)
        {
            tagRX[tagCounter] = rxByte;
            tagComingFlag = 1;
            tagCounter++;
        }   else if (tagComingFlag == 1)
            {
                tagRX[tagCounter] = rxByte;
                tagCounter++;
                if (tagCounter == 14)
                {
                    tagCounter = 0;
                    tagComingFlag = 0;
                    tagRecdFlag = 1;
                }
            }   else
                {
                    tagComingFlag = 0;
                    tagCounter = 0;
                }
        PIR1bits.RCIF = 0; //Clear interrupt flag
    }
    
    void main()
    {
            //Set LED Pins data direction to OUTPUT
            LED1Tris = 0;
            LED2Tris = 0;
            LED3Tris = 0;
            //Set LED Pins to OFF
            LED1Pin = 0;
            LED2Pin = 0;
            LED3Pin = 0;
    
            tagRecdFlag = 0; //Set in ISR if new RFID tag has been read
            tagComingFlag = 0; //Indicates if a tag is partially received
            tagCounter = 0; //Counts byte index
            
            //USART1 Initialization
            Open1USART(USART_TX_INT_OFF & USART_RX_INT_ON & USART_ASYNCH_MODE & USART_EIGHT_BIT & USART_CONT_RX & USART_BRGH_LOW, 25);
    
            //Interrupts
            RCONbits.IPEN = 1;  //Enable interrupt priority
            IPR1bits.RC1IP = 1;  //Make receive interrupt high priority
            INTCONbits.GIEH = 1; //Enable all high priority interrupts
            
            //Turn on RFID Module
            RFIDVCCTris = 0; //Set to output
            RFIDVCCPin = 1; //Turn on RFID Module
    
            while(1)
            {
                if (tagRecdFlag)
                {                 
                    //Toggle LED corresponding to which card was read
                    if (memcmp(tagRX, rfidTag1, 14) == 0)
                    {
                        LED1Pin = ~LED1Pin;
                    }
                    if (memcmp(tagRX, rfidTag2, 14) == 0)
                    {
                        LED2Pin = ~LED2Pin;
                    }
                    if (memcmp(tagRX, rfidTag3, 14) == 0)
                    {
                        LED3Pin = ~LED3Pin;
                    }
    
                    //Delay 1/2 sec & clear flags to prevent repeated card read
                    Delay10KTCYx(200);
                    tagRecdFlag = 0; 
                    tagComingFlag = 0; 
                    tagCounter = 0; 
                    }
            }
    }

  5. #5
    Join Date
    Jun 2009
    Location
    Sc*nthorpe, UK
    Posts
    333

    Default Re: RFID RDM6300 Code.. Sample ?? Anyone ??

    After a bit more reading.

    14 bytes because the output includes

    a start byte - 02
    10 tag characters
    2 CRC bytes
    an end byte - 03

    so with serin2 wait for 02 character and then read 10 characters into tag buffer like this

    SERIN2 rfid_data, 396, [WAIT($02),STR buf\10]

  6. #6
    Join Date
    May 2012
    Location
    Merseyside, UK
    Posts
    237

    Default Re: RFID RDM6300 Code.. Sample ?? Anyone ??

    Hi..
    Thank you all for help..... I have just got something working ....

    Not quite sure how the number on the card relates to the hex number embeded in the card...Had to get that out via clever use of a MAX232 chip, hyperterminal and a few caps on the bench...!!

    Thank you all again...

  7. #7
    Join Date
    Jun 2009
    Location
    Sc*nthorpe, UK
    Posts
    333

    Default Re: RFID RDM6300 Code.. Sample ?? Anyone ??

    Quote Originally Posted by andybarrett1 View Post

    Not quite sure how the number on the card relates to the hex number embeded in the card...
    There is no relation except for the CRC. My understanding is that you have to swipe the cards and capture the embedded numbers (Tag) which you can then use in your code. The output from the RFID is TTL level and using a MAX232 is one way forward.

    I have read some posts that suggest the CRC is used to catch bad data but the datasheet says the CRC is calculated using the card number. Examples I have seen ignore the CRC and end byte. I guess the cards are reasonably reliable and do not need CRC checking or end byte detection, who knows?

  8. #8
    Join Date
    May 2012
    Location
    Merseyside, UK
    Posts
    237

    Default Re: RFID RDM6300 Code.. Sample ?? Anyone ??

    Quote Originally Posted by EarlyBird2 View Post
    There is no relation except for the CRC. My understanding is that you have to swipe the cards and capture the embedded numbers (Tag) which you can then use in your code.
    That is what I will do…. Seems to be others have same issue..

    Thanks again for help

    Andy

  9. #9
    Join Date
    Mar 2016
    Posts
    91

    Default Re: RFID RDM6300 Code.. Sample ?? Anyone ??

    Hi Folks,
    I started to play with this RFID reader. For beginning I try to create a simple TAG reader and show the tag number on NOKIA LCD. I can read the tag and display it, but I can't extract the decimal value from readed HEX string. For example: TAG number written on tag is 0008201470 (dec) readed as 34007D24FE (HEX).
    My question is how to convert this HEX to DEC?
    Reading the TAG as HEX string:
    Code:
    '****************************************************************
    '*  Name    : RDM6300 RFID Reader, nokia LCD                    *
    '*  Notes   : PIC16F1829                                        *
    '****************************************************************
    ;@ errorlevel -306  
    #CONFIG
      __config  _CONFIG1, _FOSC_INTOSC & _WDTE_OFF & _PWRTE_OFF & _MCLRE_OFF & _CP_OFF & _CPD_OFF & _BOREN_ON & _CLKOUTEN_OFF & _IESO_ON & _FCMEN_OFF
      __config  _CONFIG2, _WRT_OFF & _PLLEN_OFF & _STVREN_ON & _BORV_19 & _LVP_OFF
    #ENDCONFIG
    
    DEFINE OSC 16     ; Use a 16 MHZ internal clock 
    OSCCON = %01111010
    OSCTUNE = %111111
    CLKRCON = 0
    APFCON0 = 0   
    APFCON1 = 0
    CM1CON0 = 0
    FVRCON = %11000011
    ADCON1 = %00010000
    ADCON0 = %00000000
    
    CCP1CON = %00000000
    CCP2CON = %00000000
    ANSELA = %00000000 
    ANSELB = %00000000
    ANSELC = %00000000
    TRISA =  %00100000
    TRISB =  %00100000     
    TRISC =  %00000000
    CM1CON0 = 0       ; Disable comparator 1
    CM2CON0 = 0       ; Disable comparator 2 
    OPTION_REG.6=0
    OPTION_REG.7=1    ;  weak pull ups 
    
    clear
    
    DEFINE HSER_RCSTA 90h       ; Set receive register to receiver enabled
    DEFINE HSER_TXSTA 24h       ; Set transmit register to transmitter enabled 
    DEFINE HSER_CLROERR 1 ' Clear overflow automatically                          
    DEFINE HSER_BAUD 9600 
    
    BUFF VAR BYTE [11] bank1
    #DEFINE PIC16 1            
    lcdheight  con 5                  ; 6 PAGES   
    lcdwidth  con 83                  ; 84 PIXELS WIDE
    LCD_CLK     var     portC.0       
    LCD_DIN     var     portC.1       
    LCD_RST     var     portC.2 
    LCD_DC      var     portC.3
    LCD_CE      var     portC.4
    LCD_LIGHT   var     portC.5
    sw1         var     porta.5
    
    buf	        VAR	    byte [10]
    
    include "nokia_ds2.INC"  
    include "font7x5_16.bas"
    
    gosub lcd_init
    pause 100  
    LCDCLR
    pause 100
     
    Main: 
    ;TAG No. Decimal: 0008201470
    hserin 100,main,[wait ($02), STR buf\10] ;wait for $02, then read 10 bytes ascii hex
    
    ;Reading in HEX: 34007D24FE  
    bigtxt = 0
    ARRAYWRITE BUFF,[str buf] ;display on NOKIA LCD
    LCDSTR  0,0,BUFF 
    goto main
    Reading the TAG as five individual HEX byte:
    Code:
    '****************************************************************
    '*  Name    : RDM6300 RFID Reader, nokia LCD                    *
    '*  Notes   : PIC16F1829                                        *
    '****************************************************************
    ;@ errorlevel -306  
    #CONFIG
      __config  _CONFIG1, _FOSC_INTOSC & _WDTE_OFF & _PWRTE_OFF & _MCLRE_OFF & _CP_OFF & _CPD_OFF & _BOREN_ON & _CLKOUTEN_OFF & _IESO_ON & _FCMEN_OFF
      __config  _CONFIG2, _WRT_OFF & _PLLEN_OFF & _STVREN_ON & _BORV_19 & _LVP_OFF
    #ENDCONFIG
    
    DEFINE OSC 16     ; Use a 16 MHZ internal clock 
    OSCCON = %01111010
    OSCTUNE = %111111
    CLKRCON = 0
    APFCON0 = 0   
    APFCON1 = 0
    CM1CON0 = 0
    FVRCON = %11000011
    ADCON1 = %00010000
    ADCON0 = %00000000
    
    CCP1CON = %00000000
    CCP2CON = %00000000
    ANSELA = %00000000 
    ANSELB = %00000000
    ANSELC = %00000000
    TRISA =  %00100000
    TRISB =  %00100000     
    TRISC =  %00000000
    CM1CON0 = 0       ; Disable comparator 1
    CM2CON0 = 0       ; Disable comparator 2 
    OPTION_REG.6=0
    OPTION_REG.7=1    ;  weak pull ups 
    
    clear
    
    DEFINE HSER_RCSTA 90h       ; Set receive register to receiver enabled
    DEFINE HSER_TXSTA 24h       ; Set transmit register to transmitter enabled 
    DEFINE HSER_CLROERR 1 ' Clear overflow automatically                          
    DEFINE HSER_BAUD 9600 
    
    BUFF VAR BYTE [10] bank1
    #DEFINE PIC16 1            
    lcdheight  con 5                  ; 6 PAGES   
    lcdwidth  con 83                  ; 84 PIXELS WIDE
    LCD_CLK     var     portC.0       
    LCD_DIN     var     portC.1       
    LCD_RST     var     portC.2 
    LCD_DC      var     portC.3
    LCD_CE      var     portC.4
    LCD_LIGHT   var     portC.5
    sw1         var     porta.5
    
    b0 var byte 
    b1 var byte
    b2 var byte
    b3 var byte
    b4 var byte
    
    include "nokia_ds2.INC"  
    include "font7x5_16.bas"
    
    gosub lcd_init
    pause 100  
    LCDCLR
    pause 100
    
    Main:
    ;TAG No. Decimal: 0008201470                                  
    hSERIN 100,main,[wait ($02),hex2 b0, hex2 b1, hex2 b2, hex2 b3, hex2 b4] ; ;wait for $02, then read 10 bytes ascii hex
    
    ;Reading in HEX: 34007D24FE
    ARRAYWRITE BUFF,[hex2 b0, hex2 b1,hex2 b2, hex2 b3,hex2 b4] ;display on NOKIA LCD
    LCDSTR  0,0,BUFF 
    
    gOTO main

Similar Threads

  1. Please help with sample code on 12f675
    By critix in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 18th June 2013, 04:08
  2. please who can help me for sample code
    By jasem700 in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 22nd February 2009, 21:41
  3. 18F8722 sample code
    By George in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 19th June 2008, 14:42
  4. Sample code for pwm
    By Md.Shah in forum mel PIC BASIC
    Replies: 1
    Last Post: - 10th October 2006, 17:59
  5. 12F675 code sample
    By marad73 in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 23rd May 2006, 14:53

Tags for this Thread

Posting Permissions

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