Parallex RFID_PIC16f877a_LCD_Hi Tech C

Thread Starter

Jaden5165

Joined Sep 9, 2011
69
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.

Rich (BB code):
/*-------------------------- BEGIN ----------------------------*/
#include<htc.h>
__CONFIG(0x3F39); 
#define _XTAL_FREQ 4e6
#define RS RC4
#define EN RC5
#define databits PORTB
 
/*----------------PORT SETTINGS-------------------*/
void pic_init()
    {
     TRISC4=0;
     TRISC5=0;
     TRISB=0;
    }
 
/*-----------------LCD FUNCTIONS ----------------------*/
void LCD_STROBE(void)
    {
    EN = 1;
    __delay_us(0.5);
    EN = 0;
    }
void data(unsigned char c)
    { 
    RS=1;
    __delay_us(40);
     databits = ( c >> 4 );
    LCD_STROBE();
    databits = ( c );
    LCD_STROBE(); 
    }
void cmd(unsigned char c)
    {
     RS=0;
    __delay_us(40); 
    databits = ( c >> 4 );
    LCD_STROBE();
    databits = ( c  );
    LCD_STROBE();
  __delay_ms(2);
    }
void clear(void)
    {
     cmd(0x01);
    __delay_ms(2);
    }
void lcd_init()
    { 
    __delay_ms(20);
    cmd(0x28 );
    __delay_ms(1);
    cmd(0x28 );
    __delay_ms(1);
    cmd(0x28 );
    cmd(0x28 ); // Function set (4-bit interface, 2 lines, 5*7Pixels)
    cmd(0x0c); // Make cursorinvisible
    clear(); // Clear screen 
    cmd(0b00000110); // Set entry Mode(auto increment of cursor)
    }
void string(const char *q)
    {
    while(*q) 
  {
 
   data(*q++);
  }
    }
 
/*------------------MAIN FUNCTION-----------------------*/
main()
    {
    __delay_ms(50);
    pic_init();
    lcd_init();
    while(1)
        {
        cmd(0x83);
        string("Blind Audio");
        cmd(0xc0);
        string("Guidance System");
        while(1);
        }
    } 
 /*---------------- END --------------------------*/
 

Attachments

t06afre

Joined May 11, 2009
5,934
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
 

t06afre

Joined May 11, 2009
5,934
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.
 

Thread Starter

Jaden5165

Joined Sep 9, 2011
69
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.
 

Thread Starter

Jaden5165

Joined Sep 9, 2011
69
Rich (BB code):
#include<htc.h>
#define _XTAL_FREQ 4e6
__CONFIG(0x3F39);
#define RS RC4
#define EN RC5
#define databits PORTB
unsigned char i=0;
unsigned char data[]="Blind ID No.";
unsigned char tag_id[12];
 
void usrt_init()
{
TXEN=1;
SYNC=0;
BRGH=0; // low baud rate
SPBRG=25; //baud rate 2400
TRMT=1;
SPEN=1;
CREN=1;
}
void interrupt_enable()
{
GIE=1;
PEIE=1;
RCIE=1;
}
void interrupt UART() //interrupt service routine
{
 tag_id=RCREG;
 i++;
}
 
void LCD_STROBE(void)
{
EN = 1;
__delay_us(2);
EN = 0;
}
void lcddata(unsigned char c)
{
RS = 1;
__delay_us(50);
databits = (c >> 4);
LCD_STROBE();
databits = (c);
LCD_STROBE();
}
void cmd(unsigned char c)
{
RS = 0;
__delay_us(50);
databits = (c >> 4);
LCD_STROBE();
databits = (c);
LCD_STROBE();
}
void clear(void)
{
cmd(0x01);
__delay_ms(2);
}
void lcd_init()
{
__delay_ms(15);
cmd(0x28);
__delay_ms(1);
cmd(0x28);
__delay_us(100);
cmd(0x28);
cmd(0x28); // Function set (4-bit interface, 2 lines, 5*7Pixels)
cmd(0x28); // Function set (4-bit interface, 2 lines, 5*7Pixels)
cmd(0x0c); // Make cursorinvisible
clear(); // Clear screen
cmd(0x6); // Set entry Mode(auto increment of cursor)
}
 
void main()
{
TRISB=0;
TRISC4 = 0;
TRISC5 = 0;
usrt_init();
interrupt_enable();
lcd_init();
while(data!='\0')
{
 lcddata(data);
 i++;
}
while(1)
{
 i=0;
 while(i<12);
 cmd(0xc0);
 i=0;
 while(i<12)
 {
   lcddata(tag_id);
   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.
 

Attachments

Top