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
RFID Card Reader
-
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
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
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
- JohnCrow
- 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
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
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 !
- 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
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.
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.
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 = ICODECode: Select all
#define MX_RFID_PRCOL 4 //MifareCode: Select all
#define MX_RFID_PRCOL 5 //ICODEIf 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_PRCOLRegards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- 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
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 "}").
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 "}").