View previous topic :: View next topic |
Author |
Message |
Grkan13
Joined: 06 Apr 2011 Posts: 14
|
Storing 2000 account number |
Posted: Fri Oct 04, 2013 10:03 am |
|
|
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
|
|
Posted: Fri Oct 04, 2013 10:07 am |
|
|
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
|
|
Posted: Fri Oct 04, 2013 5:39 pm |
|
|
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: 19553
|
|
Posted: Sat Oct 05, 2013 12:45 am |
|
|
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
|
|
Posted: Mon Oct 07, 2013 1:53 pm |
|
|
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: 9246 Location: Greensville,Ontario
|
|
Posted: Mon Oct 07, 2013 2:15 pm |
|
|
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
|
|
Posted: Tue Oct 22, 2013 3:40 pm |
|
|
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: 9246 Location: Greensville,Ontario
|
|
Posted: Wed Oct 23, 2013 5:36 am |
|
|
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: 19553
|
|
Posted: Wed Oct 23, 2013 7:32 am |
|
|
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'....
Best Wishes |
|
|
|