RFID 125Khz serial TTL- 232 Level Module (Engraved Tag Number Calculation)

jackberg

New Member
Hello to All,

I'm confused about ASCII or hex calculations, after trying to get some info's from David Lincoln book "Picaxe" second edition, and from reading post at this forum.

Does anyone had any experiences about Tag number calculation ?

I'm currently using the windows calculator to convert Hex to get the engraved tag number, but looking for help or sample code to add calculation to my program.

From the RFID module, I'm able to send the data to the terminal window as Hex or Dec format

Engraved Tag number = 0002050430
Hex = 0C001F497E$


------ STX ------------ASCII Data----------------Checksum-- ETX -----
Dec --- (2) ------- 48 67 48 48 49 70 52 57 55 69------36---- (3)


Code:
#picaxe 08m2
#no_data
setfreq m16
#terminal 19200
LET dirs = %00000111 ;0=input 1=output

;serial in
serin c.3,T9600_16,b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12

;HEX serial out
sertxd(b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12)

;Decimal serial out
sertxd(40,#b0,41,32,#b1,32,#b2,32,#b3,32,#b4,32,#b5,32,#b6,32,#b7,32,#b8,32,#b9,32,#b10,32,#b11,32,40,#b12,41)

Thank's for any help.


RFID 125kHz ID card reader

25401 25402
 
Last edited:

PhilHornby

Senior Member
Does anyone had any experiences about Tag number calculation ?
No... ;)
I'm not quite following this ...
Engraved Tag number = 0002050430
Hex = 0C001F497E$


------ STX ------------ASCII Data----------------Checksum-- ETX -----
Dec --- (2) ------- 48 67 48 48 49 70 52 57 55 69------36---- (3)

Hex: 0C001F497E = 51,541,657,982, not 2050430 (which is 1F497E hex). Does the card actually have that engraved/written on it? If so, it doesn't quite match the spec. you've given...

I'm assuming this RFID card/tag is very simple and just presents a fixed serial number that you would like to recognise ❓ (Or do you want to create a general purpose routine that prints the RFID tag as a large decimal number ❓)

Assuming the former ...

On a more capable microcontroller, you might convert the incoming ASCII data to a decimal quadword and compare it with a list of quadwords for known cards. However, on a Picaxe, I would probably just store the 10 ascii bytes, for each of the 'cards/tags' in EEPROM and compare them directly, with whatever has just been read.

(I have done something very similar for DS18B20 serial numbers - 8 identical heater controllers recognise their 'node number' from the DS18B20 serial no., so they can all run identical code. The code would be easy to modify).
 

inglewoodpete

Senior Member
I worked with RFID tags back in the 1980s. The excrypted numbers is those tags were in two major groups - once the checksum had been confirmed, the first was the group ID, (We used that as our Company ID), while the second number was a serial ID (We used that as a staff ID, where tags were allocated to individuals).

I'm not about to undertake the exercise but if the binary for 2050430 (decimal?) can be aligned with a binary sequence in 0C001F497E (Hexadecimal) which then matches, you could be closer to resolving your riddle.
 

papaof2

Senior Member
Hex = 0C001F497E$

Dec --- (2) ------- 48 67 48 48 49 70 52 57 55 69------36---- (3)

(2) STX Start of Text
48 0 zero
67 C
48 0
48 0
49 1
70 F
52 4
57 9
55 7
69 E

36 $

(3) ETX End of Text

What you see is the ASCII representation of the hex characters.
The decimal value of the hex string 0C001F497E is the tag number of 2050430. Try it in a scientific calculator (even Windows XP has that ;-) Someone probably has code for a hex to decimal converter.

Sending hex data in ASCII with a STX. ETX and checksum is simply error protection and the STX may be used as a "wake up" signal to the decoding hardware.
 

jackberg

New Member
WOW, quite quick....
Thank's to all PhilHornby, inglewoodpete, papaof2

To PhilHornby :
Actually the decimal code on the key tag is as is : 0002050430, and looking
to create a general purpose routine that convert the received HEX or ASCII data to a decimal number.
the goal is this:
1: scan the key fob (tag or card) using RFID module + 08m2
2: re-create or generate the large decimal number from the received data (in this case 1F497E )
3: saving to EEPROM

(it's easy to save the HEX or ASCII Data and use it later to compare)
but looking "if possible" to generate a decimal number, also easier to compare with the physical tag.

Thank's again to all.

Here's the key fob:
25406
 

jackberg

New Member
Hi, marks,
concerning my question the relation of the line: Data0,Data1...
I think I figure it out, since you use @bptrdec , Data0 are use as temporary storage.
(my best guess.)

Thank again.
 

hippy

Technical Support
Staff member
I'm not about to undertake the exercise but if the binary for 2050430 (decimal?) can be aligned with a binary sequence in 0C001F497E (Hexadecimal) which then matches, you could be closer to resolving your riddle.
Yes, that "1F497E" hex part is "2050430" decimal.

The largest "FFFFFF" value would be "16777215" so it's tricky to turn the hex bytes or digits into decimal at run-time but it can be done.

The code below uses three word variables to hold 0-999 which represent an 'xxxyyyzzz' decimal. The 'ShowDecimal' routine could be improved upon to remove leading zeroes.
Code:
Symbol reserveW0 = w0 ; b1:b0

Symbol digit1    = b11
Symbol digit2    = b12
Symbol digit3    = b13

Symbol msd       = w10 ; b21:b20
Symbol mid       = w11 ; b23:b22
Symbol lsd       = w12 ; b25:b24

Test1F497E:
  Gosub ClearDecimal
  b0 = $1F : Gosub AddHexByteInB0
  b0 = $49 : Gosub AddHexByteInB0
  b0 = $7E : Gosub AddHexByteInB0
  Gosub ShowDecimal

TestFFFFFF:
  Gosub ClearDecimal
  b0 = $FF : Gosub AddHexByteInB0
  b0 = $FF : Gosub AddHexByteInB0
  b0 = $FF : Gosub AddHexByteInB0
  Gosub ShowDecimal

  End

ClearDecimal:
  msd = 0
  mid = 0
  lsd = 0
  Return

AddHexByteInB0:
  b1 = b0 / 16 : Gosub AddHexNibbleInB1
  b1 = b0
AddHexNibbleInB1:
  lsd = lsd * 16 : lsd = b1  & $0F  + lsd
  mid = mid * 16 : mid = lsd / 1000 + mid
  msd = msd * 16 : msd = mid / 1000 + msd
  lsd = lsd // 1000
  mid = mid // 1000
  Return

ShowDecimal:
  BinToAscii msd, digit1, digit2, digit3 :  SerTxd(digit1, digit2, digit3)
  BinToAscii mid, digit1, digit2, digit3 :  SerTxd(digit1, digit2, digit3)
  BinToAscii lsd, digit1, digit2, digit3 :  SerTxd(digit1, digit2, digit3, CR, LF)
  Return
 
Top