Page 1 of 1
RFID Card Reader
Posted: Sat Sep 26, 2009 8:14 am
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
Re: RFID Card Reader
Posted: Sat Sep 26, 2009 4:35 pm
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
Re: RFID Card Reader
Posted: Sun Sep 27, 2009 9:28 am
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
Re: RFID Card Reader
Posted: Mon Sep 28, 2009 8:17 am
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.
or
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.
Hope this helps.
Re: RFID Card Reader
Posted: Mon Sep 28, 2009 8:34 am
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 "}").
Re: RFID Card Reader
Posted: Tue Sep 29, 2009 6:24 am
by JohnCrow
Thanks
Sounds a bit more complex than I imagined
