Rfid

hippy

Ex-Staff (retired)
The PICAXE range can interface with RFID readers which use a suitable serial or I2C protocol to deliver information. I'm not sure what "RFID reading capability" you would be looking for.
 
Thanks for this. I've taken the plunge and purchased a kit from Core RFID. It comprises a CORE-12 reader that reads a selection of 125kHz tags. The reader connects to a PC via an RS232 lead and the tags are read and displayed via the software which Core RFID have supplied.

Close inspection of the lead reveals that there are only two wires; one from pin 1 on the RFID reader (GND) and one from pin 8 on the RFID reader (Data Pin 1).

Through reading the posts on the PICAXE forum I have gathered that it is possible to connect the wire from pin 8 of the RFID reader to the input of a PICAXE chip and interpret the serial data from the reader.

Unfortunately (for me) the suggestions for programs are written in BASIC rather than Logicator. I'm guessing that I will need to use the SERIN command and loop it to read the string of data but I would welcome some suggestions as to how to structure my flow diagram.
 

BeanieBots

Moderator
The first thing to do is establish what data is sent and at what baud rate.
If the information is not available from the datasheet, then some experimentation will be required using something like a terminal program or better still, contact them and ask.
 
OK. This is what I have managed to establish so far. The Baud rate is 9600. The 'Read Encoding' is 'Manchester modulus 64'. The reader supports ASCII, Wiegand26 and Magnetic ABA Track2 data formats.

When I wave the RFID tags in front of the reader, the viewer software displays either a string of 6 digits (in 'Dec' mode) or a string of 10 characters, comprising a mix of digits and letters (in 'Hex' mode).

Does this help?
 

BeanieBots

Moderator
As it supports several formats, I'd suggest going for ASCII because that can be viewed using a terminal program.
How do you set it to ASCII?

Once set to ASCII, use a terminal program (set to 9600 baud) and see if you get any 'sensible' characters. (you may need to try inverting the signal).

Once you know the data that comes back, you can then start working out how to convert it into the data you want. There are probably extra bytes such as checksums which can use to varify valid data has been recieved.
 

Technical

Technical Support
Staff member
The datasheet here gives all the clues.

http://www.corerfid.co.uk/coreDocs/CoreIDSpecs.pdf

You need to use 9600. You don't need a max232 to work with a computer so that tells you it is N polarity - N9600_8. Electrical connection is module ASCII output direct to PICAXE input.

In ASCII mode you get $02, 10 data bytes and then some checksums, which can be ignored to start with, then added later if you feel like it! So a good starting point is

Code:
setfreq m8
main:
serin pin, N9600_8, ($02), b0,b1,b2,b3,b4,b5,b6,b7, b8, b9
debug
goto main
With luck you will get the same numbers in b0-b9 every time you use the same tag, and different numbers for a different tag. These numbers are the unique code of the tag.
 
Last edited:
Thanks for this, BeanieBots and Technical. Would I be able to use the 'Basic' command in Logicator to copy/paste the code that you have suggested? As far as I can tell the SERIN command in Logicator doesn't support 9600 baud.
 

Technical

Technical Support
Staff member
You can just open the BASIC viewer panel, cut and paste and download the BASIC without any flowchart involvement. You are stretching the limits of flowchart operation here, BASIC would be far simpler to use in this project.

(View > Show BASIC Panel menu), click paste icon, click download icon then (PIC>Debug menu).

Variables b0-b7 are called A to H in Logicator.
 
Hmmm. Thank you for your help with this but unfortunately, no joy at the mo.

Forgive my ignorance - I prefer the pretty pictures in Logicator as opposed to the soulless text in Basic - but presumably I substitute the word 'pin' after the expression 'serin' with the number of the input pin I am using (in my case '0')? I have connected a wire from pin 8 of the Core-12 reader to input pin 0 on a 14M circuit.

The program downloads quite happily but waving the tags in front of the reader elicits no response. Am I making a school-boy error somewhere?
 

hippy

Ex-Staff (retired)
Most readers of the forum probably don't generally use flowcharts and won't be familiar with the tools or know how to do what they could suggest. If you are prepared to use the Programming Editor and run some Basic programs you may be able to elicit help from a wider audience. Basic programs are far quicker to produce, more easier to communicate between people, and you never know, you may also find that Basic programs are less soulless than you have perceived :)

To answer the direct question, yes pin should be replaced by the input pin number you are using. So for input pin 0, "SerIn 0, N9600_8, ..."

To check if the PICAXE is actually receiving anything, I'd move through the sequence of programs below ...

Code:
#Picaxe14M
#Terminal 9600
Pause 2000
SetFreq M8
SerTxd( "Starting", CR, LF )
b1 = $FF
Do
  b0 = pin0 
  If b0 <> b1 Then
    b1 = b0
    SerTxd( #b0 )
  End If
Loop
Code:
#Picaxe14M
#Terminal 9600
Pause 2000
SetFreq M8
SerTxd( "Starting", CR, LF )
Do
  SerIn 0, N9600_8, b0
  SerTxd( "Got Something = ", #b0, CR, LF )
Loop
Code:
#Picaxe14M
#Terminal 9600
Pause 2000
SetFreq M8
SerTxd( "Starting", CR, LF )
Do
  SerIn 0, N9600_8, ( $02 )
  SerTxd( "Got STX", CR, LF )
 Loop
 
Last edited:
Thanks for this, Hippy. Success of sorts. I tried pasting the programs into the Basic window in Logicator but with no apparent response.

I downloaded 'Programming Editor' and each of the programs produced results when I waved my assortment of RFID tags in front of the reader.
1. Produced a string of 0s and 1s in the Serial Terminal window
2. Produced 'Got Something = 2' for each tag in the Serial Terminal window
3. Produced 'Got STX' for each tag in the Serial Terminal window

I understand your comments with regards to the more widespread help available from other Basic users on this forum but, as a teacher, I find the ability to drag and drop commands into a flow diagram so much easier for students to understand. Horses for courses I guess.

Now that we (you!) have established that the RFID reader and the PICAXE are on speaking terms, do you think there is a possibility of getting it to work in Logicator?
 

hippy

Ex-Staff (retired)
One final program, for Programming Editor I'm afraid, but worth trying as we are on a roll ...

#Picaxe14M
#Terminal 9600
Pause 2000
SetFreq M8
SerTxd( "Starting", CR, LF )
Do
SerIn 0, N9600_8, ( $02 ), b0, b1, b2, b3, b4, b5, b6, b7, b8, b9
SerTxd( "Tag = ", #b0, " ", #b1, " ", #b2, " ", #b3, " ", #b4, " " )
SerTxd( #b5, " ", #b6, " ", #b7, " ", #b8, " ", #b9, CR, LF )
Loop

With a fair wind, that should show different values for each tag

As to getting it to work with Logicator, that should be possible. It's just a matter of creating one flowchart block per command and it should 'just work'. You can "Convert to Basic" and the program generated should be similar.

Because the programs use SETFREQ, a SETFREQ modified baud rate, more variables than Logicator presents it may be necessary to use "Basic" flowchart blocks which will make the flowchart less understandable.

I appreciate all the arguments in favour of flowcharts and are often the best way to introduce programming and control flow ( it was "Sausage Charts" when I was taught at school, well before computer programming became a mainstream notion ), but, for advanced programming, flowchart tools are not always ideal for doing that.

We know the hardware works and hopefully that last program will too, so it's just a matter of converting to a flowchart. Off-hand I can't say how to, but if the last program does work, we'll do our best to advise and help.
 

hippy

Ex-Staff (retired)
Yay ! We seem to be homeward bound

Yes, each command in its own Basic block. Here's a version I created for Logicator for PICmicro and PICAXE. Hopefully that will work, or at least give you an idea of what I was trying to do ...
 

Attachments

Thanks, Hippy. I tried this program out, adding a 'Debug' cell into the loop after the 'Display Barcode' Basic cell. Unfortunatley nothing appeared in the Debug window. However, I then modified the flow diagram adding in a 'Compare' cell after the 'Display Barcode' Basic cell and getting the PIC to flash an LED a certain number of times if the value of one of variables exactly matched the known variable value of a particular tag. (I established these values from the Programming Editor program that you wrote). It worked! So the flow diagram that you sent me obviously (and not surprisingly) does work.
I tried connecting up an LCD screen (an AXE033) and including a cell to display the value of one of the variables but got nonsense. Is this because when initialising the chip we have altered the clock? If so, can it be momentarily restored so that it can send a signal to the LCD screen?
 

hippy

Ex-Staff (retired)
Yes, using SETFREQ will mess up other baud rates, LCD control and DEBUG. It will be easier to change up frequency while reading the RFID data then drop back down. Delete the Init Chip block, change the Read RFID code to ...

SetFreq M8
SerIn ...
SetFreq M4
 
Thank you Hippy, you're a legend!

I've now reached the happy stage that I was hoping for at the beginning of this thread. I have programmed a PIC chip, in Logicator, with a flow diagram which allows me to wave RFID tags in front of a reader and then extract the unique code and use it to perform another task.

Now to find a use for it!..
 

Technical

Technical Support
Staff member
Thanks, Hippy. I tried this program out, adding a 'Debug' cell into the loop after the 'Display Barcode' Basic cell. Unfortunatley nothing appeared in the Debug window.
Also because the default clock speed was changed and so the debug data was at the wrong speed. Change as Hippy suggests (so that only serin runs at double speed) and debug should also start working.
 
Top