Go Down

Topic: NEW to RFID? where to start? (Read 36086 times) previous topic - next topic

Grumpy_Mike

Quote
guess its not 'good' cause its a 'slave'?

Well you have to pole a slave. That is you have to ask a slave if it has seen a card and it answers you. If it were a master then it would send you data when it sees a card. This is more convenient but tricky to implement because you either have to pole the clock to see if data is being sent or arrange an interrupt to be generated and let an ISR do the receiving.
I suppose either way your code ends up polling something so I suppose it doesn't matter.

Thanks for the link to that reader, it looks good and they ship to the UK (via UK eBay) so I might get one myself as I haven't got a 13MHz reader at the moment.

xl97

ok thanks!.

I ordered one right now.. figure it will be nice to have and play with for now.  (if your saying dont matter its a 'slave' device).

who knows when it'll arrive now! =)

xl97

#17
Feb 28, 2012, 05:29 pm Last Edit: Oct 04, 2012, 07:07 pm by xl97 Reason: 1
update:

got my kit yesterday.

I have it hooked-up per the diagram:  (it says UNO or 2560..does it matter that I have a Duemilanove?)

RFID:                    ARDUINO Duemilanove:

1(MISO)       >>>       12  
2(SCK)        >>>       13  
3(SS)          >>>       10  
4(MOSI)       >>>       11  

GND           >>>       GND  
3.3v           >>>       3.3v  
RST            >>>       5              

I have also attached whatever documentation and sample .pde they supplied.

(.pde to long to post here..its in the attachment)


It seems to compile.. and load on my Arduino.. but outside of that. it does nothing.  (Im not even sure what the sample is SUPPOSED to do? I thought just wait/poll for a card in the proximity an display the cards details/info?)

I check serial monitor.. and nothing is printed..but it is 'scrolling' like a blank line/carriage return is being printed..

green light on tx is always going too..

maybe search for another sketch to try?.

thanks


     

d0ugparker

This looks promising. I figured if I subscribed to the thread
and waited long enough, someone would post something
helpful.

I'm in the same boat you are, but I've DLed the code and
now I have something to look through.

One thing I noticed is that there's a disjointed instructions
in where to connect from the Arduino shield to the RFID
card--in one case I noted it needed to go to pins 50-53 (or
thereabouts) and in other sources it mentioned connecting
from the RFID card to the shield's pins 10-13 (or
thereabouts). Maybe these are internally identical, I don't
know.

I'm still learning. :thumbs up:

Doug P
Orlando, FL
Doug
-----
Be positive-in 100 years we're all going to be dead. :wink:

xl97

I believe those two different pin 'sets' are for two different Arduino boards.


2560 Arduino..  and the Uno

the Uno doesnt have that many I/O pins.. I need to follow the pinout I posted

But still dont have a clue on where to start debugging yet..  (at work.. havent had much time to surf around yet)

Brad Burleson


update:

got my kit yesterday.

I have it hooked-up per the diagram:  (it says UNO or 2560..does it matter that I have a Duemilanove?)

RFID:                    ARDUINO Duemilanove:

1(MISO)       >>>       12  
2(SCK)        >>>       13  
3(SS)          >>>       10  
4(MOSI)       >>>       12  


Probably just a typo, but MOSI should be 11, not 12.

Brad.

xl97

oops.. yeah it was a typo (what I get for copy/paste each line over and over real quick)

still cant get ANYTHING to show up?

Is there a simple test? (anything) to even check to see if this is not DOA??

thanks!

xl97

update:

since you posted.. I gave things another try.. but was thinking...  I hope its not these damn 'quick jumper wires' I got..

it was a problem on this MATRIX LED STRIP project for me as well..

so I took them out.. and used the solid core type jumpers you get form RadioShack.. and BAM!..   it works.. as least the default program des.. for reading card and spitting out some info.

So Im happy and content with this purchase.

The rest is up to me to rip into the code..  (the set-up seems to be ALOT of work/code??).. Im gonna focus on some of the functions and work form there I guess..


first thing I dont understand is the instructions telling me to set a new password??

but so far, so good.

I'll post back bit more when I get home from work and actually play more.

thanks!


GoForSmoke

When RFID first caught my eye it was the active as much as the passive that appealed to me. I am pretty sure that some RFID modules are supposed to be able to send live data like temperature but I never see that in kits. Some apps were supposed to be cheap home control but I think some people were talking up what could be especially as to prices.

1) http://gammon.com.au/blink  <-- tasking Arduino 1-2-3
2) http://gammon.com.au/serial <-- techniques howto
3) http://gammon.com.au/interrupts
Your sketch can sense ongoing process events in time.
Your sketch can make events to control it over time.

xl97

hey everyone..

to keep this thread going.. and provide something useful for those that come after us..

I'll be posting/dissecting the code provided..  and walk my way through things.. 'out loud' here..   posting questions..etc.

Im new to C coding in general.. so some of these practices are new to me in general..

looking at beginning of the code..

looks to just import/use the SPI lib:
#include <SPI.h>

and defince a few vars.. (what does UNSIGNED mean?)
#define   uchar   unsigned char
#define   uint   unsigned int


then defining another var? (is that correct?  just declaring the var: "MAX_LEN" to be 16?)
#define MAX_LEN 16


The declaring a few pin names/pointers: (one for chip select and other for reset)
const int chipSelectPin = 10;
const int NRSTPD = 5;


Here is where I get confused a bit....

I see a BUNCH of code 'blocks'...

like so:
Code: [Select]

//MF522
#define PCD_IDLE              0x00               //NO action
#define PCD_AUTHENT           0x0E               
#define PCD_RECEIVE           0x08               
#define PCD_TRANSMIT          0x04             
#define PCD_TRANSCEIVE        0x0C               
#define PCD_RESETPHASE        0x0F               
#define PCD_CALCCRC           0x03               //CRC

//Mifare_One
#define PICC_REQIDL           0x26               
#define PICC_REQALL           0x52               
#define PICC_ANTICOLL         0x93             
#define PICC_SElECTTAG        0x93               
#define PICC_AUTHENT1A        0x60               //A
#define PICC_AUTHENT1B        0x61               //B
#define PICC_READ             0x30               
#define PICC_WRITE            0xA0               
#define PICC_DECREMENT        0xC0               
#define PICC_INCREMENT        0xC1             
#define PICC_RESTORE          0xC2             
#define PICC_TRANSFER         0xB0             
#define PICC_HALT             0x50               


//MF522
#define MI_OK                 0
#define MI_NOTAGERR           1
#define MI_ERR                2



my best guess is that were defining a bunch of vars to have 'instructions' as their value.. (for quick use/identifying)
and thats how the RFID card/system sorta works..

you use a read/write function and then send an instruction/op-code as a parameter to that function to do a specific 'task/event'..

Is this correct?  (in a general, overview sorta way?) lol


What I dont understand are these:
//MF522
//Mifare_One
//MF522

breaking up the code chunks??


moving along.. there is another (longer) set up defined vars (instructions)  (*** I'll only post the first couple entries in each block..otherwise its too much text)


Code: [Select]
//------------------MFRC522---------------//
//Page 0:Command and Status
#define     Reserved00            0x00   
#define     CommandReg            0x01   
#define     CommIEnReg            0x02 
........


//Page 1:Command     
#define     Reserved10            0x10
#define     ModeReg               0x11
#define     TxModeReg             0x12
.........

//Page 2:CFG   
#define     Reserved20            0x20 
#define     CRCResultRegM         0x21
#define     CRCResultRegL         0x22
..............


//Page 3:TestRegister     
#define     Reserved30            0x30
#define     TestSel1Reg           0x31
#define     TestSel2Reg           0x32
..........




moving back to flow...

we get this:
uchar serNum[5];


which looks like we are assigning the unsigned var 'uchar' a value of serNum[5]  (which means we are making it an array with 5 values/indices???)    is this correct so far?


I get confused.. because it seems we are doing alot with uchar  (over and over)

Code: [Select]

uchar  writeData[16]={0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100};  //100
uchar  moneyConsume = 18 ;  //18
uchar  moneyAdd = 10 ;  //10


is uchar more like a 'datatype'?  (Im confused on how we keep using it over and over like this?)

Im not even going to start on the set password stuff yet..

(and were not even to the MAIN loop yet!!!)


any feedback, help , suggestions, questions is welcomed..

this is like the title says.. beginners, those who are NEW TO RFID stuff...


thanks








GoForSmoke

http://arduino.cc/en/Reference/Define

Quote
Define

#define is a useful C component that allows the programmer to give a name to a constant value before the program is compiled. Defined constants in arduino don't take up any program memory space on the chip. The compiler will replace references to these constants with the defined value at compile time.


You might want to read up a bit on Data Types here:
http://arduino.cc/en/Reference/HomePage

uchar is unsigned char which is the same as byte which is the same as at least 2 other names that somebody liked better enough to jam into the spec.

And did I mention that the Arduino Reference page doesn't tell everything? Here's the home of AVR LibcL
http://www.nongnu.org/avr-libc/

Don't expect to learn it all in a week, use what you can and learn more as you go. You'll get things done that way.



1) http://gammon.com.au/blink  <-- tasking Arduino 1-2-3
2) http://gammon.com.au/serial <-- techniques howto
3) http://gammon.com.au/interrupts
Your sketch can sense ongoing process events in time.
Your sketch can make events to control it over time.

xl97

Thanks..

so its basically as I thought?.. or as Im used to.. just like defining a variable.

I have somewhat of a programming background.. just not in C or low level languages..

I am used to doing things more like this:

var varName:dataType = value;

var someText:String = "Hello World";

arrays are handled a bit different too I think.. which should be....um....fun!?  :smiley-roll-blue:  LOL


Still not really clear on how/why they keep re-using the uchar var over and over for different equations/events (but I dont see the output saved/updated anywhere.. like its just overwritten on the next line??)



GoForSmoke

When you define a variable it uses space in memory. If the variable is not a constant, you can change it.
#define is not that and it can be so much more. Think of #defines as more like macros.

That's the problem with starting out on complex code, you are really taking on extra learning curve. As in so many other aspects of life the full lesson takes more than a glance or single example to become apparent. You want to go the route then for -every- last character in the syntax you don't know why it's there or what it does you need to find out or at some point in time it will probably hit you with bug(s) you don't even know how to troubleshoot.

Whatever you coded in before did a great job of insulating you from how it actually works. Even in Basic I worked with bits, bytes and words.

1) http://gammon.com.au/blink  <-- tasking Arduino 1-2-3
2) http://gammon.com.au/serial <-- techniques howto
3) http://gammon.com.au/interrupts
Your sketch can sense ongoing process events in time.
Your sketch can make events to control it over time.

xl97

Everyone learns heir owns ways I guess.

I didnt buy this with a specific purpose or project in mind. I bought it to learn and play with. (period)

Yes whatever I coded in before was pretty forgiving...  it also had nothing to do with hardware, more web based.

There are a few people in here new to RFID.. so we talk and explore together.  Post back results of our 'journey' and others can benefit from it.

More advanced members can chime in and help out of answer questions.. (or ignore it all together if this thread and its approach to learning doesnt identify with them)

I appreciate your explanations as well. :)

Just tearing things apart little by little and function by function to see results and plug-into the learning curve.

If there is 'easier' code pertaining to this RFID card/reader/writer.. Id be happier to look/play/study that... but unfortunately..this is all I have currently.


Thanks


GoForSmoke

I'd like to see you able to read the code you have easier because I know that would help. But wow it's a lot of explanation, a lot of typing material that's already available on the web -- but the lessons are 99.9% suited for PC's with, compared to Arduino, vastly more RAM. My UNO has only 2k SRAM to run on, including for the stack. Yet with care one can do serious work with it since there's no resource-hogging OS getting in the way. We have to write our own bugs!

1) http://gammon.com.au/blink  <-- tasking Arduino 1-2-3
2) http://gammon.com.au/serial <-- techniques howto
3) http://gammon.com.au/interrupts
Your sketch can sense ongoing process events in time.
Your sketch can make events to control it over time.

Go Up