CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Problems between RFID and PIC

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
GabrielVinicios



Joined: 27 May 2011
Posts: 2

View user's profile Send private message MSN Messenger

Problems between RFID and PIC
PostPosted: Fri May 27, 2011 3:13 pm     Reply with quote

I bought a RFID-12 and i´ve looking for a solution to communicate it with uC PIC16F628A. I found two ways to follow:

- Using RS232 protocol;
- Using the example in the file ex_rfid.c, that exists in the folder examples.

I´ve tried to communicate it with RS232 and it doesn´t work. Look at my code:

Code:

#include "C:\Users\Thiago\Desktop\eletronica\PIC1\rfid.h"
#use rs232(baud=2400,parity=N,xmit=PIN_a2,rcv=PIN_a1,bits=8,stream=ID12)
   #define LCD_DATA_PORT getenv("SFR:PORTB")

   #define LCD_ENABLE_PIN  PIN_b0
   #define LCD_RS_PIN      PIN_b2
   #define LCD_RW_PIN      PIN_b1

   #define LCD_DATA4       PIN_B4
   #define LCD_DATA5       PIN_B5
   #define LCD_DATA6       PIN_B6
   #define LCD_DATA7       PIN_B7

   #define LCD_TYPE 2
   #include <lcd.c>

void main()
{
   
   char valor[12];
   int aux;
   char c;
   lcd_init();

 
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);
   disable_interrupts(INT_RDA);
   disable_interrupts(GLOBAL);
   output_high(pin_a7);

lcd_putc("teste...");


while(TRUE) {


 for (aux=0;aux<12;aux++){
 valor[aux]=getc();
printf (lcd_putc,"%d",valor[aux]);
 }
delay_ms(2000);
lcd_putc("\f");

 
}


}


The LCD Display showed just it: -1 -1 -1 -1 -1 -1 -1

I tried also several bauds, like 9600, 2400, etc.

I found out another code in this forum, and it doesn´t work too. See:

Code:
#define RFID_START_BYTE 0x0A
#define RFID_END_BYTE   0x0D

void get_rfid_string()
{
int8 s[12];
unsigned int8 max=20;
  unsigned int8 len;
  char c;
 
  // Wait for start byte
  do
  {
    c = fgetc(ID12);
  } while (c != RFID_START_BYTE);
 
  // Receive data until END byte is received or buffer full
            // correct for terminating zero
  len=0;
s=0;
  while ((c != RFID_END_BYTE) && (len < max))
  {
 
    c = fgetc(ID12);
    s[len++] = c;
 
  };
 // fprintf(CPU, "%s\n", s);
printf(lcd_putc,"\f%s\n",s);
}

     
//3. Main program

VOID main()
{
  printf(lcd_putc,"\f");
   
         DO {         
       
                get_rfid_string();         
            } WHILE(TRUE);
 }


But in this case, nothing appears on the LCD.

What am I doing wrong?

I tried it with several tags...

Thank you so far.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri May 27, 2011 4:50 pm     Reply with quote

Post a list of your connections between the PIC and the ID-12. Post the
pin numbers that have the connections on them.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group