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

rfid kit problems

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








rfid kit problems
PostPosted: Thu Nov 02, 2006 12:50 pm     Reply with quote

Hi all,

I have problems to get the rfid example for the em4150 to work properly. The example should only check for the rfid chip and blink green if detected and red otherwise. The code below acts strange and little changes will have different effects on the behaviour. Right now the led blinks only red, but with different frequency dependend if a chip is near the antenna or not. err prints 1/0 so I think it recognizes the chip. But the led is red only?!
Maybe I am blind and doing something silly, but I can't see it.
I have the latest PCML (Linux version) of the compiler.

If it is not the silly me, could someone compile it with a recent windows version of the pcm compiler and send me the hex? Maybe it is a compiler issue or a driver problem.

my email is: caro33 at gmx dot net

Thanks a lot
Jens


Code:

#include <16f876a.h>
//#device *=16

#fuses HS, NOWDT, NOPROTECT, PUT, NOBROWNOUT, NOLVP
#use delay(clock=20000000)

#define RS485_ID            0x11
#define RS485_USE_EXT_INT   FALSE
#define ADAPTER_RS485_ID    0x7F
#define GREEN_LED           PIN_C3
#define YELLOW_LED          PIN_C4
#define RED_LED             PIN_C5

#include <rs485.c>
#include <em4095.c>
#include <em4150.c>
#include <stdlib.h>

int8 msg[32];
int32 rfid;
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;
    }
}

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);
    }
}

void main(void)
{
    int8 err;

    rs485_init();
    rf_init();
    output_low(GREEN_LED);

    sprintf(msg, "\r\n*** RFID-Reader V0.1 ***");
    RS485send(msg);

    for(;;) {
        err = read_4150((int32 *)&rfid, 32);
sprintf(msg, "\r\n***Err: %d", err);
RS485send(msg);
        switch(err) {
            case ERR_OK:
                twoColorLED(GREEN);
//sprintf(msg, "\r\n***Id: %lu (%d)", rfid, err);
//RS485send(msg);
                break;
            case ERR_LIW:
            case ERR_NAK:
            case ERR_PARITY:
            default:
                twoColorLED(RED);
        }
        delay_ms(250);
        twoColorLED(OFF);
        delay_ms(250);
    }
}


Guest








PostPosted: Thu Nov 02, 2006 12:52 pm     Reply with quote

the lst file would be helpful too

thnx
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