PDA

View Full Version : RFID Voter please help!



philosofa
- 1st December 2014, 20:46
This is quite urgent,
i have a project that i will be defending on Friday (5th December ), I am new to programming and have really done some work coding in PICBasic.

I have to code a PIC18F4550 micro controller for ELECTRONIC VOTING SYSTEM using RFID Identification system, but i need the code to accept four (4) digit verification code before allowing voting to continue but i don't know how to go about it...
The code can only ID the tags but I cannot take it further than than due to my limited knowledge of PICBasic programming.Ii need the code to request for a four-digit pin that will be assigned to each tag number in order to verify after system ID tags. please I need urgent help as the defense date is so close. below is the code so far.......




'@ DEVICE PIC16F628A
INCLUDE "modedefs.bas"
CMCON = 7
DEFINE OSC 4 'Set oscillator in MHz
TRISA=%11100
TRISB=%00000010

DEFINE LCD_DREG PORTB 'define port to LCD
DEFINE LCD_DBIT 4 'RB4 RB5 RB6 RB7 to D4 D5 D6 D7 display
DEFINE LCD_RSREG PORTA 'RS on porta
DEFINE LCD_RSBIT 0 'RS on porta.0
DEFINE LCD_EREG PORTA 'Enable on porta
DEFINE LCD_EBIT 1 'Numero Enable porta.1
DEFINE LCD_BITS 4 '
DEFINE LCD_LINES 2 'lines 2
PAUSE 200 ' Stop 200ms
LCDOUT $FE,1 ' power lcd
'Lcdout $FE,1,4
lcdout $FE, 1," Copyright 2014"
lcdout $FE, $C0," ELECTRONIC "
lcdout $FE, $90," VOTING SYSTEM "
lcdout $FE, $D0," TECHNOLOGIES "
pause 5000
lcdout $FE,1
' -----[ Variables ]-------------------------------------------------------
buf VAR byte [10]' RFID bytes buffer
tagNum VAR Byte ' from EEPROM table
idx VAR Byte ' tag byte index
char VAR Byte ' character from table
MEK VAR BYTE
IFE VAR BYTE
' -----[ EEPROM Data ]-----------------------------------------------------
Tag1 DATA "0002864330"
Tag2 DATA "450052F2EB"

' -----[ Initialization ]--------------------------------------------------
'high portb.1 ' turn off RFID reader portb.1 is the reciever port
LOW portb.2 ' lock the door! Low portb.3 ' Turn off LED
' -----[ Program Code ]----------------------------------------------------
MEK=0
IFE=0

Main:
lcdout $FE,1," PLEASE USE YOUR"
lcdout $FE, $C0," TAG FOR ID "
pause 500
high portb.3
low portb.1 ' activate the reader
pause 500
SERIN2 portb.1,84,[WAIT($02),STR buf\10]
pause 500
high portb.1 ' deactivate reader


Check_List:
FOR tagNum = 1 to 2 ' scan through known tags
FOR idx = 0 TO 9 ' scan bytes in tag
READ (((tagNum-1)*10) + idx), char ' get tag data from table
IF (char <> buf(idx)) THEN Tag_Found'Bad_Char ' compare tag to table
NEXT
'GOTO Tag_Found ' all bytes match!

Bad_Char: ' try next tag
NEXT

Bad_Tag:
tagNum = 0
FREQOUT porta.3, 1000 */ $100, 115 */ $100 ' groan
lcdout $FE, 1," invalid TAG"
lcdout $FE, $C0," try again"
pause 1000
lcdout $FE,1
GOTO Main

Tag_Found:

'IF tagNum = 1 then displayName1
'IF tagNum = 2 then displayName2
lcdout $FE, 1,"WELCOME YOU CAN "
LCDout $FE, $C0," NOW VOTE "
pause 4000 'Pause ,5 sec then clear display
lcdout $FE, 1,"PRESS A FOR PDP "
LCDout $FE, $C0,"PRESS B FOR ACN "
lcdout $FE, $90,"PRESS C FOR APGA "
lcdout $FE, $D0,"PRESS D FOR APP "
pause 4000 'Pause ,5 sec then clear display


GOSUB VOTE

GOTO Main

VOTE:
IF PORTA.2=0 THEN CAND1
PAUSE 10
IF PORTA.3=0 THEN CAND2
PAUSE 10
GOTO VOTE


CAND1:
IF PORTA.2=0 THEN CAND1
MEK=MEK+1
lcdout $FE, 1,"PDP =",#MEK
LCDout $FE, $C0," ACCESS GRANTED"
pause 4000
GOTO Main

CAND2:
IF PORTA.3=0 THEN CAND2
IFE=IFE+1
lcdout $FE, 1,"ACN =",#IFE
LCDout $FE, $C0," ACCESS GRANDED"
pause 4000
GOTO Main
'displayName2:
'lcdout $FE, 1," UGOCHUKWU "
'LCDout $FE, $C0," ACCESS GRANDED"
'pause 3000 'Pause ,5 sec then clear display
'goto open_door

'displayName1:
'lcdout $FE, 1," EMEKA "
'lcdout $FE, $C0, "ACCESS GRANDED"
'pause 3000 'Pause ,5 sec then clear display
'goto open_door



'open_door:
'HIGH portb.2 ' remove latch
'pause 500
'LOW portb.2 ' restore latch
'Low portb.3 ' LED OFF GOTO Main
goto Main
End

please house , I need this, and will appreciate your your assistance
thank you!

Demon
- 2nd December 2014, 00:56
Looks like you used code from another PIC but didn't change the settings. You only have CMCOM, are you sure about this?

I'm not sure about how you use port A for the LCD. Does it work right?

Robert

philosofa
- 2nd December 2014, 01:43
yes, i was testing code on PIC16F628A mostly for hardware "handshaking" , worked on it, so i think it'll work on the PIC18F4550. i just want the code modified to "ask" for a (4-digit ) pin number for every tag that will be registered. before voting continues

philosofa
- 2nd December 2014, 02:06
ok, can anyone help on how to input value (for comparison) in EEPROM table

richard
- 2nd December 2014, 03:06
how many rfid tags do you expect to process ,you realise of couse that that chip has only 256 bytes of eprom (ie 25 tags)
where does the pin value come from and how is linked to the rfid tag?
and surely once a tag has "voted" it needs to be removed from the active list ?????
for 25 tags its hardly worth the effort except maybe as an educational exercise


LABOR RATES
Normal………………………………$12.50
If you wait…………………………..$15.00 per hour
If you watch………………………..$20.00 per hour
If you help………………………….$30.00 per hour
If you worked on it first………..$50.00 per hour

Deposit $1 x 2^(32-days to deadline)

Demon
- 2nd December 2014, 03:30
ok, can anyone help on how to input value (for comparison) in EEPROM table

DATA to store, READ to retrieve.

Robert

Archangel
- 2nd December 2014, 03:52
. . . and surely once a tag has "voted" it needs to be removed from the active list ?????

WHAT ? ? ? No Vote for me, and vote often?

richard
- 2nd December 2014, 05:14
No Vote for me, and vote often

the special tag costs extra

philosofa
- 3rd December 2014, 04:25
how many rfid tags do you expect to process ,you realise of couse that that chip has only 256 bytes of eprom (ie 25 tags)
where does the pin value come from and how is linked to the rfid tag?
and surely once a tag has "voted" it needs to be removed from the active list ?????
for 25 tags its hardly worth the effort except maybe as an educational exercise

Just for educational purpose, it's a mini school project.......the pin value is randomly selected for each tag and must not be changeable.