Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

RFID & Data

Status
Not open for further replies.

AtomSoft

Well-Known Member
Hey all ive got my RFID from Parallax working fine. I can get data(keys) and it works well. My question is more on storing and testing data.

What would be the best way to store trusted "keys" so i can test them on user entered(waved) keys.

I was thinking eeprom but then i would have to make a routine just to store the data then what if there are doubles. How do i test? I manually entered 2 keys into eeprom of a 18F2525 and can turn on 2 LEDs depending on if i wave a card or keyring in front of module.

Or should i store it in seperate variables or 1 long variable. Since each key is 10 Bytes(12 if counting start and stop byte).

If i make a variable of 100 Bytes i can store 10 cards. which isnt a lot but will do for testing or home use i guess. But if its that small i can just make 10 separate variables.

Here is my current code im playing with:
Code:
#include <p18f2525.h>
#include <stdio.h>
#include <string.h>
#include <usart.h>
#include <eep.h>

#pragma config WDT = OFF, LVP = OFF, OSC = INTIO67
/************************************
Prototypes
*************************************/
void main(void);


char MyID;
char tmp;
char tmpID[10];
char inputID[10];
/************************************
Main
*************************************/
void main(void){
    char inputstr[12];
    char y = 0;
    char x = 0;

	OSCCON = 0x72;      			//8MHz clock
	while(!OSCCONbits.IOFS);		//wait for osc stable

    MyID = 0;
    TRISA = TRISB = TRISC = 0;


    TRISCbits.TRISC7 = 1;

    OpenUSART(  USART_TX_INT_OFF  &
                USART_RX_INT_OFF  &
                USART_ASYNCH_MODE &
                USART_EIGHT_BIT   &
                USART_CONT_RX     &
                USART_BRGH_LOW,51);
    
    while(1){
        while(!DataRdyUSART());
        getsUSART( inputstr, 12 );

        if(inputstr[0] == 0x0A){      

tryAgain:
            if(MyID > 1) 
                MyID = 0;

            x = MyID*10;

            for(y=0;y<10;y++){
                inputID[y] = inputstr[y+1];
                tmpID[y] = Read_b_eep (x+y);
                Busy_eep ();
            }       
  
            if(memcmp(inputID,tmpID,10)){
                if (MyID == 0) {
                    LATCbits.LATC2 = 0;
                    LATCbits.LATC3 = 1;
                }
                if (MyID == 1) {
                    LATCbits.LATC2 = 1;
                    LATCbits.LATC3 = 0;
                }
            } else {
                LATCbits.LATC3 = 0;
                LATCbits.LATC2 = 0;
                MyID++;
                goto tryAgain;
            }
        
        }
    }
}
EDIT:
I own 2 of these:
**broken link removed**

Its cool to see induction at work. I plugged one in and am using it. When i put the other one over the one thats powered the one thats not powered gets powered. And its awesome. Makes me want to make this for entry to my room. And if there is a blackout(no power in house) i can have a separate induction circuit to power the main one from a extrernal battery and use it to power/unlock the door in a "no power" situation.
 
Last edited:
Wow, thats a neat device, and reasonable also. We use RFID at work on one machine to keep track of operations done on a part,.The part is in a holder with a r/w tag, if you pull the part before it's done the tag gets written so it knows where to restart. the 'tools' also have an RFID tag to hold serial numbers and offsets. The only difference is the tags we use hold like 4k of data. Neat project, keep up the good work, it's fun reading your postings.
 
Thanks. I like posting here i get nice replies. And learn alot. I hope to get some writable tags and a tag writer. It would be a very fun idea. I think i would have tons of fun playing with it. I might get the range sensor from them soon. I have their PIR sensor.

EDIT

I just thought of something... Since i have the PIR sensor i might rig it to this so it enables the device when motion is sensed and disables it when no motion is sensed.
 
Last edited:
You could store your keys in a rom array. You would have to use the table write instructions to write the values. As long as you don't need to erase keys you could store many thousands this way. To invalidate keys you could write all zeros over them. Of course, too many invalidations and reentries will fill your rom space.

Mike.
 
Nice idea Mike... That would be close to my variable idea. But with ROM instead. I was thinking about a external memory. I have a 256 Byte Memory (EEprom) from dipMicro
"256x8 bit EEPROM w/ 2-wire interface."

Since they are about $0.25 Cent (USD) I have 2 and they are cheap. I can store about 25 Keys in 1. And if need be can make a tiny eeprom board with a few.I can have 8 max. But heh its cheap. 8 for $2 and can store about 200 off PIC. Can also just get a small SD card like 32 MB and go nuts by making it internal and soldering directly on it i can make it permanent storage.

So space isnt a issue it more of which is more logical choice to use.

Internal Memory (ROM,RAM, EEPROM)
Extrernal Memory (SD,xEEprom,I2C mem, SPI mem)

So many choices. Then after making this choice i would have to code a way to save the data into the choice and read data from choice into a temp buffer and compare the buffer to the user data.

It seems easy just which is the best for this type of work. Since i will be reading the data from storage alot and checking against new user data. I think i should make some type of arrangement or hierarchy for the data. So i can organize it better and determine access for users and such. I will ultimately tie this into a LCD.
 
Thanks. I like posting here i get nice replies. And learn alot. I hope to get some writable tags and a tag writer. It would be a very fun idea. I think i would have tons of fun playing with it. I might get the range sensor from them soon. I have their PIR sensor.
EDIT
I just thought of something... Since i have the PIR sensor i might rig it to this so it enables the device when motion is sensed and disables it when no motion is sensed.

The tag system we use at work is made by BALLUFF and I am sure the tag cost more than everything you just bought, but it's an industrial application (High Speed EDM Machine), the controller is waterproof. With this job I get to learn about some neat new stuff and a lot of the newer machines are using modular microcontroller interfaces usually to a PC.

Sounds like a nifty project, again good luck..
 
Just thought id post some crapy videos lol

The 1st video is the RFID in action.
The 2nd video is the RFID acting as a inductor.
The 3rd video is a LCD widget(module) i just made for this project. It has a 74LS164 on it and has a 5 wire interface.(1=5v,2=GND,3=data,4=clock,5=E(toggle))


Video 1:
[embed]http://www.youtube.com/v/O9mId3pFhUA[/embed]
Video 2:
[embed]http://www.youtube.com/v/8OAIAguB8kY[/embed]
Video 3:
[embed]http://www.youtube.com/v/G23Lq09zpD4[/embed]
 
heh i have a messed up voice. Its scratchy today. So i doubt you would understand me talking anyway. Every since i took my tooth out i cought a fever and cold and felt like i almost died so .. im just waiting to fully heal :D Voice comes when i get a new camera.:)
 
Some new code. It can determine if a card is new and then add it to a available slot if any space is left. And can notify if no space in variable for new card or if card is old or already in system.

Code:
#include <p18f2525.h>
#include <stdio.h>
#include <string.h>
#include <delays.h>
#include <usart.h>


#pragma config WDT = OFF, LVP = OFF, OSC = INTIO67
/************************************
Prototypes
*************************************/
void main(void);
void delay_ms(int mS);
void delay_us(int uS);
void delay_s(int S);
char IsNew(char TheID);
char getSlot(void);
/************************************
Variables AND Defines
*************************************/
char MyID;
char tmp;

unsigned char sPosition;

unsigned char cards[100];
unsigned char tmpID[10];
unsigned char inputID[10];

#define RX_TRIS TRISCbits.TRISC7
#define BadLED LATCbits.LATC2
#define GoodLED LATCbits.LATC3
/************************************
Main
*************************************/
void main(void){
    char inputstr[12];
    char y,x;

	OSCCON = 0x72;      			//8MHz clock
	while(!OSCCONbits.IOFS);		//wait for osc stable

    y = x = 0;
    sPosition = 0;
 
    TRISA = TRISB = TRISC = 0;
    RX_TRIS = 1;

    OpenUSART(  USART_TX_INT_OFF  &
                USART_RX_INT_OFF  &
                USART_ASYNCH_MODE &
                USART_EIGHT_BIT   &
                USART_CONT_RX     &
                USART_BRGH_LOW,51);

    //Blank out variable
    for(y=0;y<100;y++){
        cards[y] = 0;
    }       

while(1){
loopit:
    getsUSART( inputstr, 12 );
    if(inputstr[0] != 0x0A) goto loopit;

    for(y=0;y<10;y++)
        inputID[y] = inputstr[y+1];

    for(y=0;y<12;y++)
        inputstr[y] = 0;

    if(IsNew(inputID) == 1){        //Card exist
        BadLED = 1;
        GoodLED = 0;
    } else {                        //Card is new
        BadLED = 0;
        GoodLED = 1;
        sPosition = getSlot();           
        if(sPosition == 0xFF){
            //No Slots Available for new data
        } else {
            for(x=0;x<10;x++)
                cards[sPosition + x] = inputID[x];
        }
    }
   
}
}

char IsNew(char TheID){
    char cCount,cPos;
    char x,y;

    for(cCount=0;cCount<10;cCount++){
        cPos = cCount * 10;
    
        for(x=0;x<10;x++){ 
            tmpID[x] = cards[cPos + x];
        }

        if(memcmp(tmpID,TheID,10) == 0)
            return 1;
    }

    return 0;
}

char getSlot(void){
    char cCount, cPos;

    for(cCount=0;cCount<10;cCount++){
        cPos = cCount * 10;
        if(cards[cPos] == 0) 
            return cPos;
    }
    return 0xFF;
}
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top