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

Storing 2000 account number

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



Joined: 06 Apr 2011
Posts: 14

View user's profile Send private message

Storing 2000 account number
PostPosted: Fri Oct 04, 2013 10:03 am     Reply with quote

Hello,

I need to make a system that's going to store 2000 account which has 12 hex digits, like "670072896FF3".

Each account is going to have 1 digit variable.

What i need is when the microcontroller read the user id card, its going to check card number and get the variable of that account and change it if necessary.

How can i calculate how much space I need for 2000 accounts? I need to use an EEPROM I guess but I'm not sure how big it should be?

Thanks.

Regards,
Gurkan.
oxo



Joined: 13 Nov 2012
Posts: 219
Location: France

View user's profile Send private message

PostPosted: Fri Oct 04, 2013 10:07 am     Reply with quote

Your 12 digits will store in 6 bytes. The one digit variable is 1 byte, so 7 bytes per account. Times 2000 equals 14000.
gpsmikey



Joined: 16 Nov 2010
Posts: 588
Location: Kirkland, WA

View user's profile Send private message

PostPosted: Fri Oct 04, 2013 5:39 pm     Reply with quote

Of course, that is ignoring whatever else information needs to be stored as part of the account as well (which we don't know). You will need to define a structure to store whatever information is needed for the account then you can calculate the total storage required.

mikey
_________________
mikey
-- you can't have too many gadgets or too much disk space !
old engineering saying: 1+1 = 3 for sufficiently large values of 1 or small values of 3
Ttelmah



Joined: 11 Mar 2010
Posts: 19339

View user's profile Send private message

PostPosted: Sat Oct 05, 2013 12:45 am     Reply with quote

The other question is how the data 'arrives' in the first case.
Is it just read from the cards, or is there some 'activation process', where an account is created, and data input, that is then exchanged with a particular card. If something like this is happening, is this going to involve (for example), a PC?. If so, then the unit is either going to have to interface to a PC, or the storage medium for all the card data, is going to need to be PC readable (SD card for example), which could significantly 'change' which medium you should choose.

Best Wishes
Grkan13



Joined: 06 Apr 2011
Posts: 14

View user's profile Send private message

PostPosted: Mon Oct 07, 2013 1:53 pm     Reply with quote

Hello again,

Thanks for your all replies.

Ok so for more clear information;

The system is going to be an vending machine. There will 1500 cards with 5 uses and 500 cards with 1 use.

In the future whole the account numbers of the cards is going to be kept online but for now we are not going to implement internet option.

So basically I need to put 2000 account numbers into Rom and after each use of the machine we need to deduct 1 use from the cards.

As I said I've never worked with external rom, just one really simple example with 8051 when I was at college. Can you suggest me a rom. I've checked 24LC32A from Microchip? Do you think it's easy to use? I'm open for any documents to read and analyze that you can offer.

Thanks again.

Regards,

Gurkan
temtronic



Joined: 01 Jul 2010
Posts: 9163
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Mon Oct 07, 2013 2:15 pm     Reply with quote

That EEPROM is too small.
EEPROM is usually specified in bits not bytes.
You need just over 14,000 Bytes, so a 16KBYTE EEPROM is needed. These usually say 128Kb(16KB x 8) meaning 128K bits arranged as 16,000 by 8 bit data.
A quick look at Digikey saw several Atmel pieces at less than $1. Choice depends on voltage,package and speed.

You'll also have to create a program or subroutine/function to download the card 'ID numbers' from a PC into the PIC. This will be slow but only needed once( to get the data in).

You should also have a routine to send the 'list' back to the PC to verify that they are correct !!

While you haven't told us which PIC you're going to use, look at the PIC18F46K22 if you're going to have several uses for PICs. It has lots of memory,internal peripherals,etc.While others may be cheaper using a common PIC does allow for better sharing of knowledge and code,making it easier for a group to learn from others.

hth
jay

hth
jay
Grkan13



Joined: 06 Apr 2011
Posts: 14

View user's profile Send private message

PostPosted: Tue Oct 22, 2013 3:40 pm     Reply with quote

Hello,

Thanks for the size suggestion. Microchip has 24LC128 series with 16kbyte.

I used 16f877a on this project before but i can go with 18f46k22 if its going to help me more.

And for the subroutine that's going to download ID numbers from computer. Is there any example about that? Should I use usb or serial port for that?

Thanks.

Regards,
Gurkan
temtronic



Joined: 01 Jul 2010
Posts: 9163
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Oct 23, 2013 5:36 am     Reply with quote

As you used the 877 before and have found a properly sized EEPROM you might want to go that route but I'd use the 18F46K22 for your project.Far more powerful than the now 'obsolete' 16F877.The 46 has lots of memeory, 2 UARTS, and more peripherals than you'll need.
With 64KB of pgm memory, you could use 16KB of it to store your 'account' numbers, as the 46 can 'program it's own memory.
As it has 2 UARTS , one coulde be the PC serial link, the other the 'card reader'.This allows for easy and very reliable communications using ISRs.
If you plan to do more than this project, consider the 46.As we all know, code always takes up more memory and a couple extras I/O pins or peripherals is nice too.

As for downloading the data into the PIC, use a USB<>TTL 'module' if the PC has USB ports. The module is about $3 USD and requires NO programming unlike a PIC with internal USB.

hth
jay
Ttelmah



Joined: 11 Mar 2010
Posts: 19339

View user's profile Send private message

PostPosted: Wed Oct 23, 2013 7:32 am     Reply with quote

There are 'downsides' to this approach though.
Remember the program memory does not support byte erase. So you have to work in pages. Makes the write code more complex, and the write life of the program memory is very much lower than EEPROM.

As the 'cheapest' way to do it, if a lot of devices are going to be used, then a bit of extra time on the code, would pay off, but for a small number of units, the external EEPROM makes the coding simpler.

You 'pays your money'.... Smile

Best Wishes
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