Need help on serial rfid receive


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    May 2007
    Location
    Area 71
    Posts
    52

    Default Need help on serial rfid receive

    I am experimenting with id12 rfid reader with PIC18f2550, but I can not get consistent reading. id12 has a leading character ( 02h) , how to read the data after this leading character?
    I tried with WAIT modifier, but it did not gave any result
    HSERIN [ wait ($02), b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13 ]


    Code:
    ASM
            __CONFIG    _CONFIG1L, _PLLDIV_10_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_1_1L
            __CONFIG    _CONFIG1H, _FOSC_HSPLL_HS_1H
            __CONFIG    _CONFIG2L, _PWRT_ON_2L & _BOR_ON_2L & _VREGEN_OFF_2L
            __CONFIG    _CONFIG2H, _WDT_OFF_2H & _WDTPS_512_2H
            __CONFIG    _CONFIG3H, _PBADEN_OFF_3H & _MCLRE_ON_3H  & _CCP2MX_ON_3H
            __CONFIG    _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L  & _DEBUG_OFF_4L
               
    ENDASM
    
    define osc 40
    DEFINE LCD_DREG PORTB     ' LCD data port
    DEFINE LCD_DBIT 0         ' LCD data starting bit
    DEFINE LCD_RSREG PORTB    ' LCD register select port
    DEFINE LCD_RSBIT 4        ' LCD register select bit
    DEFINE LCD_EREG PORTB     ' LCD enable port
    DEFINE LCD_EBIT 5        ' LCD enable bit
    DEFINE LCD_BITS 4         ' LCD data bus size
    DEFINE LCD_LINES 2        ' Number lines on LCD
    DEFINE LCD_COMMANDUS 1500 ' Command delay time in us
    DEFINE LCD_DATAUS 44      ' Data delay time in us
    define HSER_RCSTA 90h
    DEFINE HSER_TXSTA 20h
    DEFINE HSER_BAUD 9600
    DEFINE HSER_SPBRG 25
    define HSER_CLROERR
    b1 var byte
    b2 var byte
    b3 var byte
    b4 var byte
    b5 var byte
    b6 var byte
    b7 var byte
    b8 var byte
    b9 var byte
    b10 var byte
    b11 var byte
    b12 var byte
    b13 var byte
    
    clear
    porta = 0
    portb = 0
    portc = 0
    TRISA = %00000000               ' Set PORTA to all input
    TRISB = %00000000               ' Set PORTB to all output
    TRISC = %10000000               ' Set PORTC to all input
    
    
    LCDOUT $FE, 1   'clear lcd
    pause 100
    
    main:
    HSERIN [ wait ($02), b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13 ]      ' the data sequence is STX(02h), data ( 10 ASCII ),checksum (2 ASCII ),CR, LF, ETX(03h)
    
    LCDOUT $FE,1 , b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13
    pause 500
    
    goto main
    Last edited by luminas; - 8th August 2008 at 08:40.

  2. #2
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Have a look at the code posted in this thread, in particular post #16 I think there might be something you can use in there, a tidy little ring buffer perhaps.
    http://www.picbasic.co.uk/forum/showthread.php?t=4972
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  3. #3
    Join Date
    May 2007
    Location
    Area 71
    Posts
    52


    Did you find this post helpful? Yes | No

    Default

    Thanks Joe,

    I have got "rather" consistent reading with HSERIN command
    For example I got @123456789 , then 89 @12345 then 3@ 234 789

    How to "filter" or how to put a qualifier so I can get numbers after @ sign ?

  4. #4
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    You see it is looping and catching data mid stream, look at the manual under herserin, and serin2 for instructions re: wait . If your data is a fixed length packet you can tell herserin how many units to receive before proceeding to the next operation.
    http://www.picbasic.co.uk/forum/showthread.php?t=4047
    http://www.picbasic.co.uk/forum/showthread.php?t=3751
    http://www.picbasic.co.uk/forum/showthread.php?t=6963
    Last edited by Archangel; - 10th August 2008 at 20:20.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  5. #5
    Join Date
    May 2007
    Location
    Area 71
    Posts
    52


    Did you find this post helpful? Yes | No

    Default

    Thanks Joe, it works now.
    The problem was the unshielded cable . I changed the cable to shielded, and ground it, the readings are now consistent

Similar Threads

  1. Receive serial data
    By ruijc in forum mel PIC BASIC Pro
    Replies: 18
    Last Post: - 7th August 2008, 22:52
  2. Free Web based RFID Online Courses
    By Thirumoorthy in forum General
    Replies: 0
    Last Post: - 19th November 2007, 13:38
  3. Free web based RFID online Course
    By Lesikar in forum GPS
    Replies: 0
    Last Post: - 19th October 2007, 22:28
  4. Serial interface with RFID reader
    By brid0030 in forum Serial
    Replies: 8
    Last Post: - 23rd January 2007, 06:23
  5. PIC16F877 to RFID Module Serial Interface
    By koossa in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 17th May 2005, 06:03

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

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