I was possible to get the RDM630 printing out the correct ID Numbers in the hex format. In the decimal format I am still struggling with some missing zeros now and then. It is my goal to have the IDs in decimal format, with all IDs having the same length. The wiring of the SM125 still has to be checked.

First of all the RDM630 uses the TTL Interface RS232 Data output format. The raw data has to be split and converted, to get the actual IDs. A look on the ASCII Table helps in the final conversion step:

Output date(HEX): 02 | 30 31 30 30 30 37 33 34 45 30 | 44 32 | 03
->Change to Decimal
CardNumber Decimal: 48 49 48 48 48 55 51 52 69 48
CheckSum Decimal: 68 50
->Refer to ASCII table,get Ascill value
CardNumber Ascill: 0 1 0 0 0 7 3 4 E 0
CheckSum Ascill : D 2
(01H) xor (00H) xor (07H) xor (34H) xor (E0H) = D2H

I found some more detailed information in the arduino forum, while searching for the hex dec conversion issue:

Two transmitted Bytes form one Hex ID block.
Hex ID blocks:      6   2    |    E   3    |  0     8    |  6     C   |  E     D
Received Bytes: 36H 32H | 45H 33H | 30H 38H | 36H 43H | 45H 44H

This is my code:

#include <SoftwareSerial.h>
#define rxPin 6
#define txPin 7

unsigned char hex_input;
int rx_bytes[] = {0,0,0,0,0,0,0,0,0,0,0,0};
String tag_nr;
String tag_nr_hex;
String checksum;
String checksum_hex;

//------------------------------------
//create a Serial object RFID
SoftwareSerial RFID= SoftwareSerial(rxPin, txPin);

void setup(){
Serial.begin(9600);
Serial.println("Serial Ready");
RFID.begin(9600);
Serial.println("RFID Ready");
pinMode(rxPin, INPUT);
pinMode(txPin, OUTPUT);
}

void loop(){
if (RFID.available()>0){
hex_input = RFID.read();

if (hex_input == 2){ //Start of TTL Interface RS232 Data output format
int i = 0;
while (hex_input != 3){ //If it is not the end of TTL Interface RS232 Data output format
delay(5);
hex_input = RFID.read();

if(hex_input != 3){//If it is not the end of TTL Interface RS232 Data output format
rx_bytes[i] = hex_dec_convert(hex_input);

if(i<=9){
tag_nr += rx_bytes[i]; //filling up a string with the card number
tag_nr_hex += hex_input;
} else {
checksum += rx_bytes[i]; //filling the checksum
checksum_hex += hex_input;
}
i++;
}
}
Serial.println(String("ID is --> decimal: " + tag_nr + " with checksum: " + checksum + ", hexadecimal: " + tag_nr_hex + " with checksum_hex: " + checksum_hex));
tag_nr = "";
tag_nr_hex = "";
checksum = "";
checksum_hex = "";
}
}
}

int hex_dec_convert(unsigned char hex_in){
unsigned char hexDigit = toupper(hex_in);
int digit = (hexDigit >= 'A') ? hexDigit - 'A' + 10 : hexDigit - '0';
return digit;
}

For the ‘hex_dec_convert’ method one more messageboard post helped me out. The consol output for reading four different RFID tags, looked like this:

Serial Ready
RFID Ready
ID is –> decimal: 45005214686 with checksum: 77, hexadecimal: 52534848535069545654 with checksum_hex: 5555
ID is –> decimal: 4500531325 with checksum: 20, hexadecimal: 52534848535149515053 with checksum_hex: 5048
ID is –> decimal: 1029102081218 with checksum: 812, hexadecimal: 65505765504856674956 with checksum_hex: 5667
ID is –> decimal: 4500530218 with checksum: 012, hexadecimal: 52534848535148504956 with checksum_hex: 4867

As I said, I want to get all IDs printed with the same length. Will post more updates, when I solved it!

Advertisements