CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

RFID Reader using ID20- Help with reading tags?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Delfy_Coltech



Joined: 25 Nov 2009
Posts: 27
Location: Vietnam

View user's profile Send private message Visit poster's website

RFID Reader using ID20- Help with reading tags?
PostPosted: Wed Nov 25, 2009 9:13 pm     Reply with quote

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! Smile
_________________
-------------------------------------------------
Mechatronics Department, Coltech, VNUH
Hanoi, Vietnam.
-------------------------------------------------
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Nov 26, 2009 12:55 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Nov 27, 2009 2:33 am     Reply with quote

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

View user's profile Send private message Visit poster's website

PostPosted: Fri Nov 27, 2009 3:01 am     Reply with quote

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! Smile
_________________
-------------------------------------------------
Mechatronics Department, Coltech, VNUH
Hanoi, Vietnam.
-------------------------------------------------
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Fri Nov 27, 2009 3:37 am     Reply with quote

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

View user's profile Send private message Visit poster's website

PostPosted: Fri Nov 27, 2009 5:56 am     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Nov 27, 2009 7:02 am     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Nov 27, 2009 9:17 am     Reply with quote

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

View user's profile Send private message Visit poster's website

PostPosted: Fri Nov 27, 2009 10:48 am     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Nov 27, 2009 11:00 am     Reply with quote

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

View user's profile Send private message Visit poster's website

Thanks!
PostPosted: Fri Nov 27, 2009 11:32 am     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Nov 27, 2009 12:44 pm     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group