|
|
View previous topic :: View next topic |
Author |
Message |
muiratinas
Joined: 13 Oct 2010 Posts: 16
|
RFID Development Kit Can't Read RFID Data |
Posted: Wed Oct 13, 2010 5:40 am |
|
|
I just bought the development kit of the ccs. I read the RFID exercise book and write the codes from it. First examples worked fine (no RFID related examples) but RFID examples didn't.
When I looked up the 4095's demod out pin with an oscilloscope, it seems ok, with sending data to mc.
Could you look the code and say me whats wrong?
Thanks
main code:
Code: |
#include <16F876A.h>
#fuses HS, NOWDT, NOPROTECT, NOLVP, NOBROWNOUT, PUT
#use delay(clock=20000000)
#define GREEN_LED PIN_C3
#define YELLOW_LED PIN_C4
#define RED_LED PIN_C5
#define RS485_ID 0x11
#define RS485_USE_EXT_INT FALSE
#define ADAPTER_RS485_ID 0x7F
#include <em4095.c>
#include <em4102.c>
#include <rs485.c>
#INCLUDE <stdlib.h>
int8 msg[32];
#include "utilities.c"
void main()
{
int8 customerCode;
int32 tagNum;
rf_init();
rf_powerDown();
rs485_init();
output_low(GREEN_LED);
sprintf(msg, "\ntest");
RS485send(msg);
for(;;)
{
if(read_4102(msg))
{
customerCode = msg[0];
tagNum = make32(msg[1], msg[2], msg[3], msg[4]);
sprintf(msg, "Customer Code: %u\n\r", customerCode);
RS485send(msg);
sprintf(msg, "Tag Number: %lu\n\n\r", tagNum);
RS485send(msg);
}
}
}
|
utility code:
Code: |
void RS485send(char* s)
{
int8 size;
for(size=0; s[size]!='\0'; ++size);
rs485_wait_for_bus(FALSE);
while(!rs485_send_message(ADAPTER_RS485_ID, size, s))
{
delay_ms(RS485_ID);
}
}
char RS485getc()
{
rs485_get_message(msg, TRUE);
return msg[2];
}
int8 RS485getInt()
{
int8 i=0, s[5];
while(i < 5)
{
s[i] = RS485getc();
if(s[i] == '\r')
{
i=5;
}
else
{
++i;
}
}
return atoi(s);
}
int32 RS485getI32()
{
int8 i = 0, s[11];
while(i<11)
{
s[i] = RS485getc();
if(s[i]== '\r')
{
i=11;
}
else
{
++i;
}
}
return atoi32(s);
}
typedef enum{OFF, GREEN, RED} LEDcolor;
void twoColorLED(LEDcolor color)
{
switch(color)
{
case OFF:
output_low(PIN_A3);
output_low(PIN_A5);
break;
case GREEN:
output_high(PIN_A3);
output_low(PIN_A5);
break;
case RED:
output_low(PIN_A3);
output_high(PIN_A5);
break;
}
}
|
|
|
|
muiratinas
Joined: 13 Oct 2010 Posts: 16
|
|
Posted: Thu Oct 14, 2010 4:38 am |
|
|
My kit revision is the revision 2, do i need to change something? |
|
|
muiratinas
Joined: 13 Oct 2010 Posts: 16
|
|
Posted: Tue Oct 19, 2010 1:13 am |
|
|
when debugging it, it seems getting out of the command of em4095.c's 303th row;
Code: | while(dataTransferred < numBits && timer0_overflows < 15); |
what could be the problem? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Oct 19, 2010 1:20 pm |
|
|
I don't have the RFID kit, and I don't know much about it, but my advice
is to use the CCS examples. Make those work first. Then try your own
code. Here's the example file:
Quote: | c:\program files\picc\examples\ex_rfid.c |
I do notice that you are doing strange things in your program.
For example, you want to use the RFID device. But then you
turn it off, as shown in bold below. Why ? To use a device,
you normally would turn it on.
Quote: | void main()
{
int8 customerCode;
int32 tagNum;
rf_init();
rf_powerDown();
rs485_init();
output_low(GREEN_LED);
sprintf(msg, "\ntest");
RS485send(msg);
|
The CCS example code (directory given above) does turn on the device.
It calls the rf_powerUp() routine, as shown below. You should do this.
Try using the CCS code first.
Quote: |
void main(void) {
int8 wrong_attemps;
int32 tagNum;
int8 customerCode;
rf_init(); //initialization
rf_powerUp();
// green LED on
output_low(GREEN_LED);
twoColorLED(OFF); |
|
|
|
muiratinas
Joined: 13 Oct 2010 Posts: 16
|
|
Posted: Tue Oct 19, 2010 3:11 pm |
|
|
Thanks for your reply,
The code I wrote is the CCS's example already (from given example book)
and yes you are right, it must be Up and I already tried it, but just making small changes to make it work, I changed it to Down and forget.
Thanks for your advice but problem still not solved with Up... |
|
|
muiratinas
Joined: 13 Oct 2010 Posts: 16
|
|
Posted: Wed Nov 03, 2010 2:42 am |
|
|
I don't want to copy and paste the ex_rfid.c, em4095.c and em4102.c from the ccs but, when i use them without changes and rfid kit, still there is no response...
When i turned the debug mode, run a bit then halt the program,
it always in
Code: | while(dataTransferred < numBits && timer0_overflows < 15); |
with scope, from reader to 16f876a signals seems okay. i think i'll give up... |
|
|
f0raster0
Joined: 05 Nov 2010 Posts: 22
|
|
Posted: Fri Nov 05, 2010 9:28 am |
|
|
hi.. first my English is mm regular.. and I'm learning CCS and C for PIC.
ok... My "hi word" activate a led this very good, now I have a reader RFID, ID20 and I want to send the ID to PIC 16F887 and led activate if read a character, then all the string.
My codigo is:
Code: |
#include <16F887.h>
#FUSES XT,NOWDT
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=pin_c6, rcv=pin_c7, bits=8, parity=N)
#BYTE TRISB = 0X86
#BYTE PORTB = 0X06
#BYTE OPTION_REG = 0X81
int16 a;
char value[12];//12 values of tag ID
void main()
{
output_low(PIN_D7); //Set enable to low
bit_clear(OPTION_REG,7);
bit_set(TRISB,0);
bit_clear(TRISB,1);
bit_clear(PORTB,1);
for (a=1; a<12; a++)
{
value[a]=getc();
}
{
// ID of my tag Hex: tag1: x2400CC392AFBxxx; tag2: x2400CC572897xxx
if (value[2]="2") //si valor 2 es 2, apaga led
{
output_high(PIN_B0);
delay_ms(1000);
}else
{
output_low(PIN_B0);
}
}
}
|
In CCS compile:
Warning 201 "rfid_1.1.c" Line 31(1,1): Assignment inside relational expression
Memory usage:ROM=1% RAM=7%-7%
0 Errors, 1 warnings
line 31 is: {
output_high(PIN_B0);
delay_ms(1000);
}else
Thanks for your time and help. |
|
|
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Fri Nov 05, 2010 1:07 pm |
|
|
The compiler spot you WHAT and WHERE the error is:
if (value[2]="2") //si valor 2 es 2, apaga led
if (value[2]=="2") //si valor 2 es 2, apaga led
Saludos |
|
|
|
|
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
|