Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

RFID coding trouble. Please help

Status
Not open for further replies.

djinni

Newbie level 4
Joined
Mar 27, 2009
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Indonesia
Activity points
1,345
Hello, I am working on a project using atmega8535 involving the use of rfid. I want to display the rfid tag serial number on 16 x 2 lcd, but I am unable to accomplish it. I have even try to connect the rfid module with MAX 232, but it does not work. Can anyone please check for any errors I make in the programming?


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#define F_CPU 8000000UL
 
#define USART_BAUDRATE 9600
#define BAUD_PRESCALE (((F_CPU / (USART_BAUDRATE * 16UL))) - 1)
 
#include<avr/io.h>
#include<util/delay.h>
 
#define LCD_DATA PORTA                          // LCD data port
#define ctrl PORTB
#define en PB2                 // enable signal
#define rw PB1                 // read/write signal
#define rs PB0                   // register select signal
 
void LCD_cmd(unsigned char cmd);
void init_LCD(void);
void LCD_write(unsigned char data);
 
void usart_init();
unsigned int usart_getch();
 
unsigned char i, card[12];
void getcard_id(void);
void LCD_display(void);
 
int main(void)
{
                DDRA=0xff;                        //LCD_DATA port as output port
                DDRB=0x07;                       //ctrl as out put
                init_LCD();                           //initialization of LCD
                _delay_ms(50);                   // delay of 50 milliseconds 
                    UCSRA=0x00;                  // USART initialization
                    UCSRB=0x10; 
                    UCSRC=0x86; 
                    UBRRH=0x00; 
                    UBRRL=0x33; 
                LCD_write_string("Unique ID No.");        //Function to display string on LCD
                while(1)
                {
                                getcard_id();      // Function to get RFID card no. from serial port
                                LCD_cmd(0xC0);               // to go in second line and zeroth position on LCD
                                LCD_display();                   // a function to write RFID card no. on LCD
                }
                return 0;
}
 
void getcard_id(void)     //Function to get 12 byte ID no. from rfid card
{             
                for(i=0;i<12;i++)
                {
                                card[i]= usart_getch();  // receive card value byte by byte
                }
                return;
}
 
void LCD_display(void)  //Function for displaying ID no. on LCD
{
                for(i=0;i<12;i++)
                {
                                LCD_write(card[i]);         // display card value byte by byte
                }
                return;
}
 
void init_LCD(void)
{
                LCD_cmd(0x38);                               //initializtion of 16x2 LCD in 8bit mode
                _delay_ms(1);
 
                LCD_cmd(0x01);                               //clear LCD
                _delay_ms(1);
 
                LCD_cmd(0x0E);                               //cursor ON
                _delay_ms(1);
 
                LCD_cmd(0x80);                               // ---8 go to first line and --0 is for 0th position
                _delay_ms(1);
                return;
}
 
void LCD_cmd(unsigned char cmd)
{
                LCD_DATA=cmd;
                ctrl =(0<<rs)|(0<<rw)|(1<<en);
                _delay_ms(1);
                ctrl =(0<<rs)|(0<<rw)|(0<<en);
                _delay_ms(50);
                return;
}
 
void LCD_write(unsigned char data)
{
                LCD_DATA= data;
                ctrl = (1<<rs)|(0<<rw)|(1<<en);
                _delay_ms(1);
                ctrl = (1<<rs)|(0<<rw)|(0<<en);
                _delay_ms(50);                                               
                return ;
}
 
void usart_init()
{
                UCSRB |= (1 << RXEN) | (1 << TXEN);   // Turn on the transmission and reception circuitry
                UCSRC |= (1 << URSEL) | (1<<USBS) | (1 << UCSZ0) | (1 << UCSZ1);
                                                                                                                                                                                                                                                // Use 8-bit character sizes
 
                UBRRL = BAUD_PRESCALE;          // Load lower 8-bits of the baud rate value..
                                                                                                                // into the low byte of the UBRR register
                UBRRH = (BAUD_PRESCALE >> 8); // Load upper 8-bits of the baud rate value..
                                                                                                                                  // into the high byte of the UBRR register
}
 
unsigned int usart_getch()
{
                while ((UCSRA & (1 << RXC)) == 0); // Do nothing until data have been received..
                                                                                   // and is ready to be read from UDR
                return(UDR); // return the byte
}
 
void LCD_write_string(unsigned char *str)           // take address value of the string in pointer *str
{
                int i=0;
                while(str[i]!='\0')                             // loop will go on till the NULL characters is soon in string
                {
                                LCD_write(str[i]);             // sending data on LCD byte by byte
                                i++;
                }
                return;
}

 
Last edited by a moderator:

You're apparently referring to a specific RFID module. But you forgot to tell the type.
 

Many RFID readers utilize the Wiegand Protocol rather than a TTL UART interface.

As FvM indicated, stating the specific model of RFID reader is required before meaningful advice can be offered.


BigDog
 

First of all thanks everyone for the reply. The RFID module that I am using is CR003T. From what I read from the datasheet the output is TTL. What is the difference between the weigand protocol and the TTL data output? Every website that I open regarding RFID reader says that the output data is TTL.
 

Weigand can also be TTL. It uses three wires, ground and a data line for the '0' bits and a data line for the '1' bits. The idea is that if you gate together the two data lines it gives you a clock signal to drive the serial shift register. It can work over long wire lengths and by virtue of carrying it's own clock information within the data bits is relatively immune to cable distortions.

Brian.
 

Reference the attached datasheet.

The 'T' in the CR003T indicates the reader module interface is a TTL UART.

However, this specific reader does not have an built-in antenna, therefore you will need to furnish an appropriate external antenna.

Another common issue is ensuring the RFID tag is compatible with the RFID reader module.

The RFID tag must be 125kHz and utilize an EM4001 compatible transponder.

Not all RFID tags are created equal. :wink:

Before connecting the RFID module to the microcontroller, ensure both the antenna and RFID tag are functional by checking the output of pin 28 as per the datasheet.

One of the most straight forward ways would be to construct a similar circuit to that given in the datasheet:



If the antenna, RFID tag and RFID reader module are functioning as expected, the LED will indicate a successful read.

Once this has been determined, then concern yourself with properly interfacing the RFID reader module to the microcontroller.


BigDog
 

Attachments

  • CR003Series.pdf
    127.6 KB · Views: 121

i have a " RDM6300 RF ID " .... datasheet says interfacing is : " Weigang26 Or TTL Electricity Level RS232 format "....
what is the difference between " Weigang26 Or TTL Electricity Level RS232 format " UART communication ?????
i just know UART communication using MICROC compiler ... how can i do uart via Weigang16 or TTL RS232 formate
?????????
anyone please help !!!!!!!!!!!!
 

They are two entirely different protocols by which the data is conveyed.

Only the TTL RS-232 interface is compatible with a UART interface.

As the interface is at TTL levels, it can be connected directly to a microcontroller UART without the need of a RS-232 transceiver like the MAX232, although depending on the voltage level requirements of the microcontroller it may require some method of level shifting.

If you are attempting to interface the device to a PC's RS-232 interface a RS-232 transceiver like the MAX232 will be required at the device end.

The Wiegand interface is usually accomplished by some method of voltage level change detection via firmware.

Wiegand Protocol




BigDog
 
why my code is not workingg ???????????????????????

code >>>>>

Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// LCD module connections
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;
 
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
// End LCD module connections
 
 int i;
 char outt[18];
void main() {
uart1_init(9600);
delay_ms(100);
lcd_Init();
Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF);
 while(1)
 {
  if(uart1_data_ready())
   {
     for(i=0;i<15;i++)
      {
       outt[i]=uart1_read(); 
       
      }
      outt[i]='\0';
      lcd_out(2,1,outt);
         
   }
 }
}

 
Last edited by a moderator:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top