Parallex RFID_PIC16f877a_LCD_Hi Tech C

Discussion in 'Embedded Systems and Microcontrollers' started by Jaden5165, Sep 27, 2011.

  1. Jaden5165

    Thread Starter Member

    Sep 9, 2011
    69
    0
    Hi guys,
    I need your help to provide me a HTC code that can relate the RFID to my LCD.i want the RFID reader to read the RFID tag's code and send it to my lcd to display out the code.
    I have uploaded the picture of my RFID

    RFID model:parallex RFID
    http://www.trossenrobotics.com/store/p/5378-Parallax-RFID-Card-Reader-Serial-.aspx
    RFID datasheet:
    http://www.parallax.com/dl/docs/prod/audiovis/RFID-Reader-v1.1.pdf

    this is my simple code to show character in display but how to do to make the lcd show out the code when RFID tag is sensed by RFID reader.

    Code ( (Unknown Language)):
    1.  
    2. /*-------------------------- BEGIN ----------------------------*/
    3. #include<htc.h>
    4. __CONFIG(0x3F39);
    5. #define _XTAL_FREQ 4e6
    6. #define RS RC4
    7. #define EN RC5
    8. #define databits PORTB
    9.  
    10. /*----------------PORT SETTINGS-------------------*/
    11. void pic_init()
    12.     {
    13.      TRISC4=0;
    14.      TRISC5=0;
    15.      TRISB=0;
    16.     }
    17.  
    18. /*-----------------LCD FUNCTIONS ----------------------*/
    19. void LCD_STROBE(void)
    20.     {
    21.     EN = 1;
    22.     __delay_us(0.5);
    23.     EN = 0;
    24.     }
    25. void data(unsigned char c)
    26.     {
    27.     RS=1;
    28.     __delay_us(40);
    29.      databits = ( c >> 4 );
    30.     LCD_STROBE();
    31.     databits = ( c );
    32.     LCD_STROBE();
    33.     }
    34. void cmd(unsigned char c)
    35.     {
    36.      RS=0;
    37.     __delay_us(40);
    38.     databits = ( c >> 4 );
    39.     LCD_STROBE();
    40.     databits = ( c  );
    41.     LCD_STROBE();
    42.   __delay_ms(2);
    43.     }
    44. void clear(void)
    45.     {
    46.      cmd(0x01);
    47.     __delay_ms(2);
    48.     }
    49. void lcd_init()
    50.     {
    51.     __delay_ms(20);
    52.     cmd(0x28 );
    53.     __delay_ms(1);
    54.     cmd(0x28 );
    55.     __delay_ms(1);
    56.     cmd(0x28 );
    57.     cmd(0x28 ); // Function set (4-bit interface, 2 lines, 5*7Pixels)
    58.     cmd(0x0c); // Make cursorinvisible
    59.     clear(); // Clear screen
    60.     cmd(0b00000110); // Set entry Mode(auto increment of cursor)
    61.     }
    62. void string(const char *q)
    63.     {
    64.     while(*q)
    65.   {
    66.  
    67.    data(*q++);
    68.   }
    69.     }
    70.  
    71. /*------------------MAIN FUNCTION-----------------------*/
    72. main()
    73.     {
    74.     __delay_ms(50);
    75.     pic_init();
    76.     lcd_init();
    77.     while(1)
    78.         {
    79.         cmd(0x83);
    80.         string("Blind Audio");
    81.         cmd(0xc0);
    82.         string("Guidance System");
    83.         while(1);
    84.         }
    85.     }
    86.  /*---------------- END --------------------------*/
    87.  
     
  2. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    The output is in a standard serial format. your PIC and the RFID unit must have a common ground. Then you can receive data from from the SOUT pin. Given correct setup. The data is received on the RC7/RX/DT pin on the PIC. You can connect the SOUT and the latter pin directly given that both units run on 5 volt
    Take a look here http://www.microchipc.com/sourcecode/ in the RS232 Serial port section. And also in section 10 of the datasheet
     
    Jaden5165 likes this.
  3. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    Just one thing. To avoid uneeded error. I hope for your own shake that you program your PIC in circuit. No need to move it in and out for programming.
     
    Jaden5165 likes this.
  4. Jaden5165

    Thread Starter Member

    Sep 9, 2011
    69
    0
    Do i need the 9-pins RS232 connector and also the MAX232 IC ?coz i dont hv to go through pc just want my rfid tag's code send show in LCD.
     
  5. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    No you do not any max232 or 9 pin connector. In the RFID to PIC setup
     
  6. Jaden5165

    Thread Starter Member

    Sep 9, 2011
    69
    0
    Code ( (Unknown Language)):
    1.  
    2. #include<htc.h>
    3. #define _XTAL_FREQ 4e6
    4. __CONFIG(0x3F39);
    5. #define RS RC4
    6. #define EN RC5
    7. #define databits PORTB
    8. unsigned char i=0;
    9. unsigned char data[]="Blind ID No.";
    10. unsigned char tag_id[12];
    11.  
    12. void usrt_init()
    13. {
    14. TXEN=1;
    15. SYNC=0;
    16. BRGH=0; // low baud rate
    17. SPBRG=25; //baud rate 2400
    18. TRMT=1;
    19. SPEN=1;
    20. CREN=1;
    21. }
    22. void interrupt_enable()
    23. {
    24. GIE=1;
    25. PEIE=1;
    26. RCIE=1;
    27. }
    28. void interrupt UART() //interrupt service routine
    29. {
    30.  tag_id[i]=RCREG;
    31.  i++;
    32. }
    33.  
    34. void LCD_STROBE(void)
    35. {
    36. EN = 1;
    37. __delay_us(2);
    38. EN = 0;
    39. }
    40. void lcddata(unsigned char c)
    41. {
    42. RS = 1;
    43. __delay_us(50);
    44. databits = (c >> 4);
    45. LCD_STROBE();
    46. databits = (c);
    47. LCD_STROBE();
    48. }
    49. void cmd(unsigned char c)
    50. {
    51. RS = 0;
    52. __delay_us(50);
    53. databits = (c >> 4);
    54. LCD_STROBE();
    55. databits = (c);
    56. LCD_STROBE();
    57. }
    58. void clear(void)
    59. {
    60. cmd(0x01);
    61. __delay_ms(2);
    62. }
    63. void lcd_init()
    64. {
    65. __delay_ms(15);
    66. cmd(0x28);
    67. __delay_ms(1);
    68. cmd(0x28);
    69. __delay_us(100);
    70. cmd(0x28);
    71. cmd(0x28); // Function set (4-bit interface, 2 lines, 5*7Pixels)
    72. cmd(0x28); // Function set (4-bit interface, 2 lines, 5*7Pixels)
    73. cmd(0x0c); // Make cursorinvisible
    74. clear(); // Clear screen
    75. cmd(0x6); // Set entry Mode(auto increment of cursor)
    76. }
    77.  
    78. void main()
    79. {
    80. TRISB=0;
    81. TRISC4 = 0;
    82. TRISC5 = 0;
    83. usrt_init();
    84. interrupt_enable();
    85. lcd_init();
    86. while(data[i]!='\0')
    87. {
    88.  lcddata(data[i]);
    89.  i++;
    90. }
    91. while(1)
    92. {
    93.  i=0;
    94.  while(i<12);
    95.  cmd(0xc0);
    96.  i=0;
    97.  while(i<12)
    98.  {
    99.    lcddata(tag_id[i]);
    100.    i++;
    101.  }
    102. }
    103. }
    104. [/i][/i][/i][/i]



    This is the code to make my rfid tag's code show using lcd.but the problem is some weird characters occured.what is the problem?
    I have posted the picture as well.
     
Loading...