RFID Card Reader

For E-blocks user to discuss using E-blocks and programming for them.

Moderators: Benj, Mods

Post Reply
User avatar
JohnCrow
Valued Contributor
Valued Contributor
Posts: 1367
Joined: Wed Sep 19, 2007 1:21 pm
Location: Lincolnshire
Has thanked: 364 times
Been thanked: 716 times

RFID Card Reader

Post by JohnCrow »

I want to write a simple test routine in FC4 for RFID cards.
Is it possible to have the program select the card type rather than set it in the RFID macro's properties.

i.e. At the start of the program.

Press 1 For I-Code Card Press 2 For Mifare Card.
Then once selected the program branches to the test routine for that type of card.

Thanks
1 in 10 people understand binary, the other one doesn't !

Spanish_dude
Posts: 594
Joined: Thu Sep 17, 2009 7:52 am
Location: Belgium
Has thanked: 63 times
Been thanked: 102 times

Re: RFID Card Reader

Post by Spanish_dude »

Are you using switches or a keypad when you speek about "press 1, press 2"

If you are using switches then do something like this:

- read input of the first switch
- read input of the second switch
- if the first switch is pressed then ... I-Code Card
- if the second switch is pressed then ... Mifare Card

If you are using a keypad:

- loop until (key_pressed != 1) || ( key_pressed != 2 )
- read keypad and store value in key_pressed
- if key_pressed = 1 then ...I-Code Card
- Else Mifare Card

I hope I helped you a bit ^^

Nicolas

User avatar
JohnCrow
Valued Contributor
Valued Contributor
Posts: 1367
Joined: Wed Sep 19, 2007 1:21 pm
Location: Lincolnshire
Has thanked: 364 times
Been thanked: 716 times

Re: RFID Card Reader

Post by JohnCrow »

Thanks for the reply Nicolas
Though thats not quite what I mean.

If you put the RFID macro on the panel and examine the "ext properies" you have a set of check boxes to select the protocol it will use.ie Icode mifare etc
You can only select one.This is the type of card it will use once the flowcode is compiled to the pic
I want to be able to change the protocol while the program is running.
I imagine I will have to resort to embedding C code, which I dont have any knowledge of yet.
Thanks anyway
1 in 10 people understand binary, the other one doesn't !

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: RFID Card Reader

Post by Benj »

Hello John

You should be able to do something like this.

Firstly comment out this line in the RFID component C file, save the file and restart Flowcode.

Code: Select all

//#define MX_RFID_PRCOL	%a		//0 = MC; 1 = EM; 2 = HT1; 3 = HT2; 4 = Mifare; 5 = ICODE
Next in your Flowcode program choose which type of RFID you require using switches etc. When you know assign a value to the define using a C code block.

Code: Select all

#define MX_RFID_PRCOL	4        //Mifare
or

Code: Select all

#define MX_RFID_PRCOL	5        //ICODE
You can then call the Init_RFID component macro to setup the device you have selected.

If you then need to reset the protocol being used then you can use the following in a C code block.

Code: Select all

#undef MX_RFID_PRCOL
Hope this helps.

User avatar
Steve
Matrix Staff
Posts: 3434
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times

Re: RFID Card Reader

Post by Steve »

I'm not sure this will work because the "#define" and "#if" statements are only interpreted at compile time. The "fix" you require may be more extensive.

To get this to work, you'll probably need to change the "#define MX_RFID_PRCOL %a" to "#define MX_RFID_PRCOL FCV_RFID_PROTOCOL" and then create a variable "RFID_Protocol" within your program.

You will also need to search the C code for the RFID component and change all occurances of "#if (MX_RFID_PRCOL == 0)" to "if (MX_RFID_PRCOL == 0)" (also, you'll need to use and opening brace appropriately and change the #endif's to "}").

User avatar
JohnCrow
Valued Contributor
Valued Contributor
Posts: 1367
Joined: Wed Sep 19, 2007 1:21 pm
Location: Lincolnshire
Has thanked: 364 times
Been thanked: 716 times

Re: RFID Card Reader

Post by JohnCrow »

Thanks
Sounds a bit more complex than I imagined :shock:
1 in 10 people understand binary, the other one doesn't !

Post Reply