View previous topic :: View next topic |
Author |
Message |
Delfy_Coltech
Joined: 25 Nov 2009 Posts: 27 Location: Vietnam
|
RFID Reader using ID20- Help with reading tags? |
Posted: Wed Nov 25, 2009 9:13 pm |
|
|
Hello everybody!
I am designing an Access Control using RFID technology.
I use ID20 chip to read tags.
When I tested with tags using terminal. I received a string of data like:
\OA1900BA7FA37F\OD
I understand that "\OA" is start byte, "\OD" is stop byte.
And the real data is "1900BA7FA37F"
Now, I want to convert this data into Decimal data.
How do I get it???
Thanks for reading! _________________ -------------------------------------------------
Mechatronics Department, Coltech, VNUH
Hanoi, Vietnam.
------------------------------------------------- |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Nov 26, 2009 12:55 pm |
|
|
That's a 12-digit number in ASCII hex format. Why do you need to
convert it to decimal ? Do you need to convert it to ASCII decimal
so you can display it ?
Do you want to convert it from ASCII into a binary integer and put it
in a variable ? If so, the PCM and PCH compilers (for 16F and 18F PICs)
don't have an 'int48' data type. Only the PCD compiler has it. What
CCS compiler do you have ? What PIC are you using ? |
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Fri Nov 27, 2009 2:33 am |
|
|
As long as no arithmetic operations are performed on the data, there's no need to convert it to a number.
Compare and sort operations can be done on byte arrays and strings as well.
The ID won't be "readable" as a 15 digits decimal integer. |
|
|
Delfy_Coltech
Joined: 25 Nov 2009 Posts: 27 Location: Vietnam
|
|
Posted: Fri Nov 27, 2009 3:01 am |
|
|
PCM programmer wrote: | That's a 12-digit number in ASCII hex format. Why do you need to
convert it to decimal ? Do you need to convert it to ASCII decimal
so you can display it ?
Do you want to convert it from ASCII into a binary integer and put it
in a variable ? If so, the PCM and PCH compilers (for 16F and 18F PICs)
don't have an 'int48' data type. Only the PCD compiler has it. What
CCS compiler do you have ? What PIC are you using ? |
Thank you very much!
I'm using 16F877A pic and CCS version 4.0.18(PCW)
I want to convert it into decimal string. And send it to my software.
'Cos I buy the tags and know that the ID string in each tag is a decimal string as "2556296901"
I want the received ID string displaying in my software is "2556296901"
Can U help me?
Thanks again! _________________ -------------------------------------------------
Mechatronics Department, Coltech, VNUH
Hanoi, Vietnam.
------------------------------------------------- |
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Fri Nov 27, 2009 3:37 am |
|
|
Quote: | I buy the tags and know that the ID string in each tag is a decimal string as "2556296901" | You may want to read the tag specification more thoroughly. You can also get your pocket calculator
and convert the said number to hex. It's not in the above given hex string. As I mentioned, a 48-Bit number
would have more digits. Actually, it isn't a programming problem so far. |
|
|
Delfy_Coltech
Joined: 25 Nov 2009 Posts: 27 Location: Vietnam
|
|
Posted: Fri Nov 27, 2009 5:56 am |
|
|
FvM wrote: | Quote: | I buy the tags and know that the ID string in each tag is a decimal string as "2556296901" | You may want to read the tag specification more thoroughly. You can also get your pocket calculator
and convert the said number to hex. It's not in the above given hex string. As I mentioned, a 48-Bit number
would have more digits. Actually, it isn't a programming problem so far. |
Thanks alot!
Perhaps I made mistake when read the tag.
I'm checking again. _________________ -------------------------------------------------
Mechatronics Department, Coltech, VNUH
Hanoi, Vietnam.
------------------------------------------------- |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Fri Nov 27, 2009 7:02 am |
|
|
Quote: | I'm using 16F877A pic and CCS version 4.0.18(PCW) | This is an old CCS version and known to have many problems, see the version 4 Comments thread about problems in the first releases.
Downgrade to v3.249 or upgrade to anything above v4.070. |
|
|
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Fri Nov 27, 2009 9:17 am |
|
|
Delfy_Coltech wrote:
Quote: |
When I tested with tags using terminal. I received a string of data like:
\OA1900BA7FA37F\OD
I understand that "\OA" is start byte, "\OD" is stop byte.
And the real data is "1900BA7FA37F"
|
According to the datasheet, the output data structure in ASCII mode should be:
STX(02h) + 10 DATA bytes (ASCII) + 2 Checksum bytes + CR + LF + ETX(03h)
kind regards,
Humberto |
|
|
Delfy_Coltech
Joined: 25 Nov 2009 Posts: 27 Location: Vietnam
|
|
Posted: Fri Nov 27, 2009 10:48 am |
|
|
Quote: |
According to the datasheet, the output data structure in ASCII mode should be:
STX(02h) + 10 DATA bytes (ASCII) + 2 Checksum bytes + CR + LF + ETX(03h) |
==> So the real data is 1900BA7FA3 ? _________________ -------------------------------------------------
Mechatronics Department, Coltech, VNUH
Hanoi, Vietnam.
------------------------------------------------- |
|
|
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Fri Nov 27, 2009 11:00 am |
|
|
To print out the whole packet of real data, you must use "%x" option in the printf function to be able to see not printable characters like STX (02h) and ETX (03h).
If you are using a "sniffer" application to read the output string, you should try setting the HEX options instead of ASCII.
Humberto |
|
|
Delfy_Coltech
Joined: 25 Nov 2009 Posts: 27 Location: Vietnam
|
Thanks! |
Posted: Fri Nov 27, 2009 11:32 am |
|
|
Yes, thanks!
I know that. But now, I want to convert it into DEC string and send this string to PC.
How do I get it? If U have ever use this ID-20 Module
Could U share some CCS code? _________________ -------------------------------------------------
Mechatronics Department, Coltech, VNUH
Hanoi, Vietnam.
------------------------------------------------- |
|
|
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Fri Nov 27, 2009 12:44 pm |
|
|
I never used it, just read the datasheet, hence unfortunately I do not have some code to share related to this.
The way to help you is posting a short -full compilable- code and an explanation regarding with: what do you expect it should do and what you get.
Humberto |
|
|
|